Documentation ¶
Index ¶
- func CreateAccessToken(user *models.User, roles, scopes []string, hostName, nonce, loginMethod string) (string, int64, error)
- func CreateAdminAuthToken(tokenType string, c *gin.Context) (string, error)
- func CreateIDToken(user *models.User, roles []string, ...) (string, int64, error)
- func CreateRefreshToken(user *models.User, roles, scopes []string, hostname, nonce, loginMethod string) (string, int64, error)
- func CreateVerificationToken(email, tokenType, hostname, nonceHash, redirectURL string) (string, error)
- func GetAccessToken(gc *gin.Context) (string, error)
- func GetAdminAuthToken(gc *gin.Context) (string, error)
- func GetIDToken(gc *gin.Context) (string, error)
- func IsSuperAdmin(gc *gin.Context) bool
- func ParseJWTToken(token string) (jwt.MapClaims, error)
- func SignJWTToken(claims jwt.MapClaims) (string, error)
- func ValidateAccessToken(gc *gin.Context, accessToken string) (map[string]interface{}, error)
- func ValidateJWTClaims(claims jwt.MapClaims, hostname, nonce, subject string) (bool, error)
- func ValidateJWTTokenWithoutNonce(claims jwt.MapClaims, hostname, subject string) (bool, error)
- func ValidateRefreshToken(gc *gin.Context, refreshToken string) (map[string]interface{}, error)
- type JWTToken
- type SessionData
- type SessionOrAccessTokenData
- type Token
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateAccessToken ¶
func CreateAccessToken(user *models.User, roles, scopes []string, hostName, nonce, loginMethod string) (string, int64, error)
CreateAccessToken util to create JWT token, based on user information, roles config and CUSTOM_ACCESS_TOKEN_SCRIPT
func CreateAdminAuthToken ¶
CreateAdminAuthToken creates the admin token based on secret key
func CreateIDToken ¶
func CreateIDToken(user *models.User, roles []string, hostname, nonce, atHash, cHash, loginMethod string) (string, int64, error)
CreateIDToken util to create JWT token, based on user information, roles config and CUSTOM_ACCESS_TOKEN_SCRIPT For response_type (code) / authorization_code grant nonce should be empty for implicit flow it should be present to verify with actual state
func CreateRefreshToken ¶
func CreateRefreshToken(user *models.User, roles, scopes []string, hostname, nonce, loginMethod string) (string, int64, error)
CreateRefreshToken util to create JWT token
func CreateVerificationToken ¶
func CreateVerificationToken(email, tokenType, hostname, nonceHash, redirectURL string) (string, error)
CreateVerificationToken creates a verification JWT token
func GetAccessToken ¶
GetAccessToken returns the access token from the request (either from header or cookie)
func GetAdminAuthToken ¶
GetAdminAuthToken helps in getting the admin token from the request cookie
func GetIDToken ¶
GetIDToken returns the id token from the request header
func IsSuperAdmin ¶
IsSuperAdmin checks if user is super admin
func ParseJWTToken ¶
ParseJWTToken common util to parse jwt token
func SignJWTToken ¶
SignJWTToken common util to sing jwt token
func ValidateAccessToken ¶
Function to validate access token for authorizer apis (profile, update_profile)
func ValidateJWTClaims ¶
ValidateJWTClaims common util to validate claims
func ValidateJWTTokenWithoutNonce ¶
ValidateJWTTokenWithoutNonce common util to validate claims without nonce
Types ¶
type SessionData ¶
type SessionData struct { Subject string `json:"sub"` Roles []string `json:"roles"` Scope []string `json:"scope"` Nonce string `json:"nonce"` IssuedAt int64 `json:"iat"` ExpiresAt int64 `json:"exp"` LoginMethod string `json:"login_method"` }
SessionData
func CreateSessionToken ¶
func CreateSessionToken(user *models.User, nonce string, roles, scope []string, loginMethod string) (*SessionData, string, int64, error)
CreateSessionToken creates a new session token
func ValidateBrowserSession ¶
func ValidateBrowserSession(gc *gin.Context, encryptedSession string) (*SessionData, error)
type SessionOrAccessTokenData ¶
SessionOrAccessTokenData is a struct to hold session or access token data
func GetUserIDFromSessionOrAccessToken ¶
func GetUserIDFromSessionOrAccessToken(gc *gin.Context) (*SessionOrAccessTokenData, error)
GetUserIDFromSessionOrAccessToken returns the user id from the session or access token
type Token ¶
type Token struct { FingerPrint string `json:"fingerprint"` // Session Token FingerPrintHash string `json:"fingerprint_hash"` SessionTokenExpiresAt int64 `json:"expires_at"` RefreshToken *JWTToken `json:"refresh_token"` AccessToken *JWTToken `json:"access_token"` IDToken *JWTToken `json:"id_token"` }
Token object to hold the finger print and refresh token information