Documentation ¶
Index ¶
- Variables
- func JWTAuthHandler(signingKey string, claimConverter ClaimConverter, contextSetter ContextSetter, ...) gin.HandlerFunc
- type ClaimConverter
- type ContextGetter
- type ContextSetter
- type ErrorHandler
- type MultiTokenExtractor
- type Oauth2TokenExtractor
- type Option
- type ScopedClaims
- type TokenExtractor
- type TokenStore
- type TokenType
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrNoTokenInRequest = errors.New("no token present in request")
)
Errors
Functions ¶
func JWTAuthHandler ¶
func JWTAuthHandler( signingKey string, claimConverter ClaimConverter, contextSetter ContextSetter, contextGetter ContextGetter, opts ...Option, ) gin.HandlerFunc
JWTAuthHandler returns a new JWT authentication Gin Handler Parameters:
- signingKey - the HMAC JWT token signing key
- claimConverter - converts the JWT token into a JWT claim object, which will be saved into the request context
- extractors (optional) - additional token extractors to use besides OAuth2Extractor
- tokenStore (optional) - checks if the incoming JWT Bearer token's ID is present in this TokenStore (can be nil, which pypasses the check)
Types ¶
type ClaimConverter ¶
type ClaimConverter func(*ScopedClaims) interface{}
ClaimConverter converts claims to another domain object for saving into Context
type ContextGetter ¶ added in v0.2.0
ContextGetter gets the resolved (and converted) claims from a context.
type ContextSetter ¶
ContextSetter adds the resolved (and converted) claims to a context.
type ErrorHandler ¶
ErrorHandler handles an error.
type MultiTokenExtractor ¶ added in v0.3.0
type MultiTokenExtractor []TokenExtractor
func (MultiTokenExtractor) ExtractToken ¶ added in v0.3.0
func (e MultiTokenExtractor) ExtractToken(req *http.Request) (string, error)
type Oauth2TokenExtractor ¶ added in v0.3.0
type Oauth2TokenExtractor struct{}
func (Oauth2TokenExtractor) ExtractToken ¶ added in v0.3.0
func (Oauth2TokenExtractor) ExtractToken(r *http.Request) (string, error)
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
func ErrorHandlerOption ¶
func ErrorHandlerOption(errorHandler ErrorHandler) Option
func TokenExtractorOption ¶ added in v0.3.0
func TokenExtractorOption(extractor TokenExtractor) Option
func TokenStoreOption ¶
func TokenStoreOption(tokenStore TokenStore) Option
type ScopedClaims ¶
type ScopedClaims struct { jwt.Claims Scope string `json:"scope,omitempty"` // Drone fields Type TokenType `json:"type,omitempty"` Text string `json:"text,omitempty"` }
ScopedClaims struct to store the scoped claim related things
type TokenExtractor ¶ added in v0.3.0
TokenExtractor is an interface for extracting a token from an HTTP request. The ExtractToken method should return a token string or an error. If no token is present, you must return ErrNoTokenInRequest.
type TokenStore ¶
Click to show internal directories.
Click to hide internal directories.