Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Middleware ¶
func Middleware(authenticator Authenticator) func(http.Handler) http.Handler
Middleware creates an authentication middleware
Types ¶
type Authenticator ¶
Authenticator defines the interface for authentication
type BasicAuthenticator ¶
BasicAuthenticator implements HTTP Basic authentication
func NewBasicAuthenticator ¶
func NewBasicAuthenticator(username, password string) *BasicAuthenticator
NewBasicAuthenticator creates a new basic authenticator
func (*BasicAuthenticator) Authenticate ¶
func (ba *BasicAuthenticator) Authenticate(r *http.Request) error
Authenticate validates basic authentication credentials
type BearerAuthenticator ¶
type BearerAuthenticator struct {
Token string
}
BearerAuthenticator implements Bearer token authentication
func NewBearerAuthenticator ¶
func NewBearerAuthenticator(token string) *BearerAuthenticator
NewBearerAuthenticator creates a new bearer token authenticator
func (*BearerAuthenticator) Authenticate ¶
func (ba *BearerAuthenticator) Authenticate(r *http.Request) error
Authenticate validates bearer token
type MultiAuthenticator ¶
type MultiAuthenticator struct {
Authenticators []Authenticator
}
MultiAuthenticator supports multiple authentication methods
func NewMultiAuthenticator ¶
func NewMultiAuthenticator(authenticators ...Authenticator) *MultiAuthenticator
NewMultiAuthenticator creates a new multi-authenticator
func (*MultiAuthenticator) Authenticate ¶
func (ma *MultiAuthenticator) Authenticate(r *http.Request) error
Authenticate tries each authenticator until one succeeds
Click to show internal directories.
Click to hide internal directories.