Documentation
¶
Index ¶
Constants ¶
const ( // BluelinkAPIKeyHeaderName is the name of the header // used to pass the API key for authentication. BluelinkAPIKeyHeaderName = "Bluelink-Api-Key" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Checker ¶
type Checker interface {
// Check carries out an authentication check
// using the provided request headers.
// It returns an error of the `auth.Error` type
// if the check fails, or nil if it succeeds.
// Other error types should be considered
// as internal server errors.
Check(ctx context.Context, headers http.Header) error
}
Checker provides an interface for carrying out an authentication check given a set of request headers.
func LoadJWTService ¶
func LoadJWTService(config *core.AuthConfig) (Checker, error)
LoadJWTService loads a new instance of an auth.Checker that validates JSON Web Tokens (JWTs). This will use configuration from the provided auth.Config to wire up an appropriate JWT validator. This will make requests to the issuer URL as a part of the load process to determine how the JWKS URI should be configured.
func NewAPIKeyService ¶
func NewAPIKeyService(config *core.AuthConfig) Checker
NewAPIKeyService creates a new service that checks if the provided API key is valid against a list of known API keys.
func NewMultiAuthChecker ¶
NewMultiAuthChecker creates a new instance of a Checker that combines multiple authenication methods where they are applied in the order that they are configured. As soon as a checker succeeds (returns nil instead of an error), any subsequent checkers are skipped. If all checkers fail, the last error is returned.
func NewSigV1Service ¶
func NewSigV1Service( keyPairs map[string]string, clock core.Clock, options *sigv1.VerifyOptions, ) Checker
NewSigV1Service creates a new instance of the Bluelink Signature V1 service. It takes a map of key pairs (key ID -> secret key), a clock for time verification, and options for customising configuration such as clock skew. Options can be nil, in which case default options will be used.
type Error ¶
type Error struct {
ChildErr error
}
Error is a type that represents an error that occurs during authentication. It is used to distinguish between authentication errors and other types of errors such as network or implementation errors.
type JWKSProvider ¶
JWKSProvider provides an interface for a provider that can provide a JSON Web Key Set (JWKS) for validating JSON Web Tokens (JWTs).
type JWTValidator ¶
type JWTValidator interface {
ValidateToken(ctx context.Context, tokenString string) (interface{}, error)
}
JWTValidator provides an interface for a token validator that is compatible with the auth0 JWT middleware.
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
func NewMiddleware ¶
func NewMiddleware(checker Checker, excludeRoutes []*mux.Route) (*Middleware, error)
NewMiddleware creates a new middleware carries out authentication checks using the provided Checker that uses HTTP headers as the source of authentication data.
func (*Middleware) Middleware ¶
func (m *Middleware) Middleware(next http.Handler) http.Handler