Documentation ¶
Index ¶
- Constants
- func ExtractToken(r *http.Request, headerKeyInput ...string) string
- func GetCurrentUserID(ctx context.Context) int
- func GetSecretKey() string
- func GetTestJWT(userID int) string
- func HostMiddleware() gin.HandlerFunc
- func IsValidSecretKey(input string) bool
- func JWTOrSecretKeyAuthMiddleware(getCurrentUser func(*gin.Context) error) gin.HandlerFunc
- func SecretKeyAuthMiddleware(headerKeyInput ...string) gin.HandlerFunc
- func TokenAuthMiddleware(validateUser ValidateUserFunc, validateAPIKey ValidateAPIKey) gin.HandlerFunc
- func TokenValid(r *http.Request) error
- type RawToken
- type User
- type ValidateAPIKey
- type ValidateUserFunc
Constants ¶
View Source
const ( AuthorizationHeader = "Authorization" SecretKeyHeader = "x-access-token" APIKeyHeader = "x-api-key" )
Variables ¶
This section is empty.
Functions ¶
func GetCurrentUserID ¶
func GetSecretKey ¶
func GetSecretKey() string
func GetTestJWT ¶
func HostMiddleware ¶
func HostMiddleware() gin.HandlerFunc
func IsValidSecretKey ¶
func JWTOrSecretKeyAuthMiddleware ¶
func JWTOrSecretKeyAuthMiddleware(getCurrentUser func(*gin.Context) error) gin.HandlerFunc
func SecretKeyAuthMiddleware ¶
func SecretKeyAuthMiddleware(headerKeyInput ...string) gin.HandlerFunc
func TokenAuthMiddleware ¶
func TokenAuthMiddleware(validateUser ValidateUserFunc, validateAPIKey ValidateAPIKey) gin.HandlerFunc
func TokenValid ¶
Types ¶
type RawToken ¶
type RawToken struct { Authorized bool `json:"authorized"` UserID int `json:"userId"` OrgType string `json:"orgType"` OrgID int `json:"orgId"` FirstName string `json:"given_name"` LastName string `json:"family_name"` Email string `json:"email"` Role string `json:"role"` Audience string `json:"aud"` Expiration int64 `json:"exp"` IAT float64 `json:"iat"` Issuer string `json:"iss"` Sub string `json:"sub"` JTI string `json:"jti"` EmailVerified bool `json:"email_verified"` Hd string `json:"hd"` Data string `json:"data"` }
type User ¶
type User struct { ID int `json:"id,omitempty"` Username string `json:"username,omitempty"` Email string `json:"email,omitempty"` FirstName string `json:"firstName,omitempty"` LastName string `json:"lastName,omitempty"` CreatedAt time.Time `json:"createdAt,omitempty"` UpdatedAt time.Time `json:"updatedAt,omitempty"` }
type ValidateUserFunc ¶
Click to show internal directories.
Click to hide internal directories.