Documentation
¶
Index ¶
- Constants
- func BearerAuthMiddleware(validator TokenValidator, next http.Handler) http.Handler
- func ExtractBearer(authHeader string) (string, error)
- func HasAllScopes(current []string, required []string) bool
- func JoinScopes(s []string) string
- func RequireScopes(required []string, next http.Handler) http.Handler
- func SignHS256(secret []byte, issuer, audience, subject string, scopes []string, ...) (string, time.Time, error)
- type AuthConfig
- type JWTValidator
- type TokenValidator
Constants ¶
View Source
const ( CtxSubjectKey = "auth.subject" CtxScopesKey = "auth.scopes" )
Variables ¶
This section is empty.
Functions ¶
func BearerAuthMiddleware ¶
func BearerAuthMiddleware(validator TokenValidator, next http.Handler) http.Handler
func ExtractBearer ¶
func HasAllScopes ¶
func JoinScopes ¶
Types ¶
type AuthConfig ¶
type AuthConfig struct {
Issuer string `json:"issuer"`
Audience string `json:"audience"`
HS256Secret string `json:"hs256_secret"`
JWKSURL string `json:"jwks_url"`
RSAPublicPEM string `json:"rsa_public_pem"`
}
func LoadAuthConfig ¶
func LoadAuthConfig(jsonPath string) (AuthConfig, error)
func LoadAuthConfigFromBytes ¶
func LoadAuthConfigFromBytes(jsonBytes []byte) (AuthConfig, error)
type JWTValidator ¶
type TokenValidator ¶
type TokenValidator interface {
Validate(token string) (subject string, scopes []string, expiry time.Time, err error)
}
func NewValidatorFromConfig ¶
func NewValidatorFromConfig(cfg AuthConfig) (TokenValidator, error)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.