Documentation
¶
Index ¶
- Constants
- func AddToTokenCache(key string, value TokenInfo) bool
- func AuthenticateLDAPUser(username string, password string) error
- func AuthenticationRequired() gin.HandlerFunc
- func InitTokenCache() error
- func IsAPIKeyAuth(gc *gin.Context) bool
- func IsBasicAuth(gc *gin.Context) bool
- func IsCookieAuth(gc *gin.Context) bool
- func IsOAuth2(gc *gin.Context) bool
- func Log(gc *gin.Context, statusCode int, user *LogUserInfo, ctxInfo *LogContextInfo)
- func OAuth2Logout(token *TokenJSON, headers map[string]string) error
- func OAuth2Options(gc *gin.Context)
- func OutputWithLog(gc *gin.Context, statusCode int, user *LogUserInfo, ctxInfo *LogContextInfo, ...)
- func RemoveFromTokenCache(key string)
- func TestLDAPConnection(gc *gin.Context)
- func UpdateLDAPSettings(li *LdapInfo)
- func UpdateLocalSettings(li *LocalAuthInfo)
- func UpdateOAuth2Settings(oi *OAuth2Info)
- type IntrospectResponse
- type LdapInfo
- type LocalAuthInfo
- type LogContextInfo
- type LogUserInfo
- type NGSupportInfo
- type NGUserSupportInfo
- type OAuth2Info
- type TokenInfo
- type TokenJSON
- type UserInfo
Constants ¶
const ( // NextGISAuthType NextGIS auth type NextGISAuthType = 1 // KeycloakAuthType Keycloak auth type KeycloakAuthType = 2 // CustomAuthType Custom auth type CustomAuthType = 3 // BlitzAuthType Blitz auth type BlitzAuthType = 4 )
const ( NextGISPlanFree = 0 NextGISPlanMini = 1 NextGISPlanPremium = 2 )
Variables ¶
This section is empty.
Functions ¶
func AddToTokenCache ¶ added in v0.6.8
AddToTokenCache Add value to token cache
func AuthenticateLDAPUser ¶
AuthenticateLDAPUser Authenticate LDAP User
func AuthenticationRequired ¶ added in v1.2.0
func AuthenticationRequired() gin.HandlerFunc
AuthenticationRequired check if authenticate required
func InitTokenCache ¶ added in v0.6.8
func InitTokenCache() error
InitTokenCache Initialise token cache
func IsAPIKeyAuth ¶ added in v1.2.0
IsAPIKeyAuth Check if this is API key authentication
func IsBasicAuth ¶ added in v1.2.0
IsBasicAuth Check if this is basic authentication
func IsCookieAuth ¶ added in v1.2.0
IsCookieAuth Check if this is cookie based authentication
func Log ¶ added in v0.8.1
func Log(gc *gin.Context, statusCode int, user *LogUserInfo, ctxInfo *LogContextInfo)
Log Write to log
func OAuth2Logout ¶ added in v0.9.0
OAuth2Logout Logout from oauth
func OAuth2Options ¶
OAuth2Options Get oauth options: endpoint, cleint_id, etc. @Summary Get oauth options: endpoint, cleint_id, etc. @Tags admin @Produce json @Success 200 {object} oauth2Options @Router /api/oauth2/options [get]
func OutputWithLog ¶ added in v0.8.0
func OutputWithLog(gc *gin.Context, statusCode int, user *LogUserInfo, ctxInfo *LogContextInfo, abort bool, obj interface{})
OutputWithLog Form log reccord and finish route
func RemoveFromTokenCache ¶ added in v0.6.8
func RemoveFromTokenCache(key string)
RemoveFromTokenCache Remove token from cache
func TestLDAPConnection ¶
TestLDAPConnection test connection to LDAP server
func UpdateLDAPSettings ¶ added in v0.3.0
func UpdateLDAPSettings(li *LdapInfo)
UpdateLDAPSettings Update LDAP settings
func UpdateLocalSettings ¶ added in v0.3.0
func UpdateLocalSettings(li *LocalAuthInfo)
UpdateLocalSettings Update local setting
func UpdateOAuth2Settings ¶ added in v0.3.0
func UpdateOAuth2Settings(oi *OAuth2Info)
UpdateOAuth2Settings Update oauth2 setting
Types ¶
type IntrospectResponse ¶ added in v0.3.1
type IntrospectResponse struct {
Active bool `json:"active" binding:"required"`
Exp int64 `json:"exp"`
Scopes string `json:"scope"`
Username string `json:"username"`
NGID string `json:"nextgis_guid"`
}
IntrospectResponse Introspect response information
func TokenIntrospection ¶
func TokenIntrospection(token *TokenJSON) (*IntrospectResponse, error)
TokenIntrospection Token introspection
type LdapInfo ¶
type LdapInfo struct {
Enable bool `form:"enable" json:"enable"` // LDAP_LOGIN
BaseDN string `form:"base_dn" json:"base_dn"` // LDAP_BASE_DN
UserFilter string `form:"user_filter" json:"user_filter"` // LDAP_USER_FILTER
UserAttribute string `form:"user_attr" json:"user_attr"` // LDAP_USER_ATTR
URL string `form:"url" json:"url"` // LDAP_URL
TLS string `form:"tls" json:"tls"` // LDAP_TLS
TLSNoVerify bool `form:"tls_no_verify" json:"tls_no_verify"` // LDAP_TLS_NO_VERIFY
TLSCertPath string `form:"tls_cert_path" json:"tls_cert_path"` // LDAP_TLS_CERT_PATH
TLSKeyPath string `form:"tls_key_path" json:"tls_key_path"` // LDAP_TLS_KEY_PATH
TLSCaCertPath string `form:"tls_cacert_path" json:"tls_cacert_path"` // LDAP_TLS_CACERT_PATH
DN string `form:"dn" json:"dn"` // LDAP_DN
DNPassword string `form:"dn_password" json:"dn_password"` // LDAP_DN_PWD
GroupFilter string `form:"group_filter" json:"group_filter"` // LDAP_GROUP_FILTER
GroupAttribute string `form:"group_attr" json:"group_attr"` // LDAP_GROUP_ATTR
DefaultGroupID int `form:"default_group_id" json:"default_group_id"` // LDAP_DEFAULT_GROUP_ID
UpdateGroups bool `form:"update_groups" json:"update_groups"` // LDAP_UPDATE_GROUPS
}
LdapInfo LDAP Info structure
type LocalAuthInfo ¶ added in v0.3.0
type LocalAuthInfo struct {
Enable bool `form:"enable" json:"enable"` // LOCAL_LOGIN
Log bool `form:"log" json:"log"` // LOG
LogEdits bool `form:"log_edits" json:"log_edits"` // LOG_ONLY_EDITS
DefaultLang string `form:"default_lang" json:"default_lang"` // DEFAULT_LANGUAGE
AdminGroup string `form:"admin_group" json:"admin_group"` // ADMIN_GROUP_NAME
}
LocalAuthInfo Local Info structure
func (*LocalAuthInfo) Fill ¶ added in v1.2.0
func (li *LocalAuthInfo) Fill()
Fill Fill LocalAuthInfo structure by values
type LogContextInfo ¶ added in v0.8.0
LogContextInfo Context information struct
type LogUserInfo ¶ added in v0.8.0
type LogUserInfo struct {
ID uint `json:"id"`
KeyName string `json:"keyname"`
DisplayName string `json:"display_name"`
OAuthSubj string `json:"oauth_subject"`
}
LogUserInfo User information struct
type NGSupportInfo ¶
type NGSupportInfo struct {
Supported bool `json:"supported"`
StartDate string `json:"start_date"`
EndDate string `json:"end_date"`
NGID string `json:"nextgis_guid"`
Sign string `json:"sign"`
}
NGSupportInfo Support information
func GetSupportInfo ¶
func GetSupportInfo(token *TokenJSON) (*NGSupportInfo, error)
GetSupportInfo Get support information
type NGUserSupportInfo ¶
type NGUserSupportInfo struct {
Username string `json:"username"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
Supported bool `json:"supported"`
StartDate string `json:"start_date"`
EndDate string `json:"end_date"`
NGID string `json:"nextgis_guid" binding:"required"`
Email string `json:"email"`
EmailConfirmed bool `json:"email_confirmed"`
}
NGUserSupportInfo NextGIS user and support information
func GetUserSuppotInfo ¶
func GetUserSuppotInfo(ngID string) (*NGUserSupportInfo, error)
GetUserSuppotInfo Get user and support information
type OAuth2Info ¶
type OAuth2Info struct {
Enable bool `form:"enable" json:"enable"` // OAUTH_LOGIN
Endpoint string `form:"endpoint" json:"endpoint"` // OAUTH2_ENDPOINT
ClientID string `form:"client_id" json:"client_id"` // OAUTH2_CLIENT_ID
ClientSecret string `form:"client_secret" json:"client_secret"` // OAUTH2_CLIENT_SECRET
Scope string `form:"scope" json:"scope"` // OAUTH2_SCOPE
Type int `form:"type" json:"type"` // OAUTH2_TYPE
TokenEndpoint string `form:"token_endpoint" json:"token_endpoint"` // OAUTH2_TOKEN_ENDPOINT
AuthEndpoint string `form:"auth_endpoint" json:"auth_endpoint"` // OAUTH2_AUTH_ENDPOINT
UserInfoEndpoint string `form:"userinfo_endpoint" json:"userinfo_endpoint"` // OAUTH2_USERINFO_ENDPOINT
IntrospectionEndpoint string `form:"introspection_endpoint" json:"introspection_endpoint"` // OAUTH2_INTROSPECTION_ENDPOINT
SubjAttribute string `form:"subj_attr" json:"subj_attr"` // OAUTH2_PROFILE_SUBJ_ATTR
KeynameAttribute string `form:"keyname_attr" json:"keyname_attr"` // OAUTH2_PROFILE_KEYNAME_ATTR
FirstnameAttribute string `form:"firstname_attr" json:"firstname_attr"` // OAUTH2_PROFILE_FIRSTNAME_ATTR
LastnameAttribute string `form:"lastname_attr" json:"lastname_attr"` // OAUTH2_PROFILE_LASTNAME_ATTR
CreateGroups bool `form:"create_groups" json:"create_groups"` // OAUTH2_CREATE_GROUPS
UpdateGroups bool `form:"update_groups" json:"update_groups"` // OAUTH2_UPDATE_GROUPS
UserAutocreate bool `form:"user_autocreate" json:"user_autocreate"` // OAUTH2_USER_AUTOCREATE
LogoutEndpoint string `form:"logout_endpoint" json:"logout_endpoint"` // OAUTH2_LOGOUT_ENDPOINT
GroupsJWTKey string `form:"groups_jwt_key" json:"groups_jwt_key"` // OAUTH2_GROUPS_JWT_KEY
}
OAuth2Info OAuth2 Information
type TokenInfo ¶ added in v0.6.9
TokenInfo token info
func GetFromTokenCache ¶ added in v0.6.8
GetFromTokenCache Get value from token cache
type TokenJSON ¶
type TokenJSON struct {
AccessToken string `json:"access_token"`
TokenType string `json:"token_type"`
RefreshToken string `json:"refresh_token"`
ExpiresIn int `json:"expires_in"`
}
TokenJSON Token information
func GetTokenByClientSecret ¶ added in v0.15.1
GetTokenByClientSecret Get access token for client id and client secret
func RefreshToken ¶ added in v0.5.0
RefreshToken Refresh access token
func (*TokenJSON) FromSession ¶ added in v0.6.0
FromSession Set token from session
type UserInfo ¶ added in v0.3.0
type UserInfo struct {
Username string `json:"username"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
ID string `json:"guid"`
Locale string `json:"locale"`
Email string `json:"email"`
EmailConfirmed bool `json:"email_confirmed"`
Plan int `json:"subscription_plan"`
WebGISList []string `json:"available_webgises"`
Roles []string `json:"roles"`
}
UserInfo User information
func GetLDAPUserDetails ¶
GetLDAPUserDetails Get LDAP user details
func GetUserInfo ¶
GetUserInfo Get user information