Documentation
¶
Index ¶
- func APIKeyAuthN(authenticator KeyAuthenticator) func(http.HandlerFunc) http.HandlerFunc
- func AuthN(authenticator Authenticator) func(http.HandlerFunc) http.HandlerFunc
- func KeyFromContext(ctx context.Context) *schema.Key
- func NewAPIKeyAuth(authenticator KeyAuthenticator) *apiKeyAuth
- func NewBearerAuth(authenticator Authenticator) *bearerAuth
- func SessionFromContext(ctx context.Context) *schema.Session
- func UserFromContext(ctx context.Context) *schema.UserInfo
- type Authenticator
- type KeyAuthenticator
- type Policy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func APIKeyAuthN ¶ added in v0.0.11
func APIKeyAuthN(authenticator KeyAuthenticator) func(http.HandlerFunc) http.HandlerFunc
func AuthN ¶
func AuthN(authenticator Authenticator) func(http.HandlerFunc) http.HandlerFunc
AuthN returns an HTTP middleware that authenticates either a locally issued bearer token or an API key supplied via X-API-Key. If any check fails, a 401 Unauthorized response is returned.
func KeyFromContext ¶ added in v0.0.11
KeyFromContext returns the authenticated API key stored by the auth middleware.
func NewAPIKeyAuth ¶ added in v0.0.11
func NewAPIKeyAuth(authenticator KeyAuthenticator) *apiKeyAuth
func NewBearerAuth ¶
func NewBearerAuth(authenticator Authenticator) *bearerAuth
func SessionFromContext ¶
SessionFromContext returns the authenticated session stored by the auth middleware.
Types ¶
type Authenticator ¶ added in v0.0.11
type Authenticator interface {
Issuer() (string, error)
AuthenticateBearer(ctx context.Context, token string) (*schema.UserInfo, *schema.Session, error)
AuthenticateKey(ctx context.Context, token string) (*schema.UserInfo, *schema.Key, error)
}
Authenticator validates bearer tokens and API keys and returns the authenticated principal material used by downstream handlers.
Click to show internal directories.
Click to hide internal directories.