Documentation
¶
Index ¶
Constants ¶
View Source
const ( // BearerWord the bearer key word for authorization BearerWord string = "Bearer" // BearerFormat authorization token format BearerFormat string = "Bearer %s" // AuthorizationKey holds the key used to store the token in the request header AuthorizationKey = "Authorization" // Reason holds the error reason. Reason = "UNAUTHORIZED" )
View Source
const ( ContextTypeGrpc = iota ContextTypeMicro )
Variables ¶
This section is empty.
Functions ¶
func AuthFromMD ¶
func AuthFromMD(ctx context.Context, ctxType ContextType) (string, error)
AuthFromMD .
func MDWithAuth ¶
MDWithAuth .
Types ¶
type Authenticator ¶
type Authenticator interface {
// Authenticate returns a claims info and nil error (if available).
Authenticate(ctx context.Context, ctxType ContextType) (Claims, error)
// CreateIdentityWithContext injects user claims into context.
CreateIdentityWithContext(ctx context.Context, ctxType ContextType, claims Claims) (context.Context, error)
// CreateIdentity inject user claims into token string.
CreateIdentity(claims Claims) (string, error)
}
Authenticator interface
type ContextType ¶
type ContextType int
Click to show internal directories.
Click to hide internal directories.