Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Key authentication errors distinguish missing from rejected credentials. ErrKeyMissing = errors.New("keyauth: key missing") ErrKeyInvalid = errors.New("keyauth: key invalid") )
Functions ¶
func New ¶
func New(configs ...Config) zinc.Middleware
New authenticates requests with an API key. Config.Validator is required; state is published only after successful validation.
Types ¶
type Config ¶
type Config struct {
Extractor Extractor
Validator Validator
SuccessHandler zinc.HandlerFunc
ErrorHandler func(*zinc.Context, error) error
}
Config controls key extraction, validation, and failure handling.
type Credentials ¶
Credentials contains a key supplied for validation.
type Extractor ¶
type Extractor func(*zinc.Context) (Credentials, error)
Extractor reads key credentials from a request.
func FromAuthorizationHeader ¶
func FromAuthorizationHeader() Extractor
FromAuthorizationHeader extracts a Bearer key.
func FromHeader ¶
FromHeader extracts an unprefixed key from header.
func FromHeaderPrefix ¶
FromHeaderPrefix extracts a key after a case-insensitive prefix.
Click to show internal directories.
Click to hide internal directories.