Documentation ¶
Index ¶
- Constants
- func AuthMiddleware(config *AuthConfig) gin.HandlerFunc
- func CreateToken(privateKey string, tokenClaims jwt.Claims) (string, error)
- func ParseToken(publicKey string, tokenString string, tokenClaims jwt.Claims) error
- func SetAuthContext(context *gin.Context, authContext *AuthContext)
- type AuthClaims
- type AuthConfig
- type AuthContext
Constants ¶
View Source
const HEADER_PREFIX = "Bearer "
Variables ¶
This section is empty.
Functions ¶
func AuthMiddleware ¶
func AuthMiddleware(config *AuthConfig) gin.HandlerFunc
func CreateToken ¶
func ParseToken ¶
func SetAuthContext ¶
func SetAuthContext(context *gin.Context, authContext *AuthContext)
Types ¶
type AuthClaims ¶
type AuthConfig ¶
type AuthConfig struct { Enabled bool `json:"enabled" yaml:"enabled"` IncludeUrls []string `json:"includeUrls" yaml:"include-urls"` ExcludeUrls []string `json:"excludeUrls" yaml:"exclude-urls"` PublicKey string `json:"publicKey" yaml:"public-key"` PrivateKey string `json:"privateKey" yaml:"private-key"` TokenIssuer string `json:"tokenIssuer" yaml:"token-issuer"` TokenValidity int64 `json:"tokenValidity" yaml:"token-validity"` }
type AuthContext ¶
type AuthContext struct { Claims *AuthClaims Scopes []string }
func GetAuthContext ¶
func GetAuthContext(context *gin.Context) *AuthContext
func (*AuthContext) HasAndScope ¶
func (context *AuthContext) HasAndScope(scopes ...string) bool
func (*AuthContext) HasAnyScope ¶
func (context *AuthContext) HasAnyScope(scopes ...string) bool
func (*AuthContext) HasScope ¶
func (context *AuthContext) HasScope(scope string) bool
Click to show internal directories.
Click to hide internal directories.