Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( TokenCtxKey = &contextKey{"Token"} ErrorCtxKey = &contextKey{"Error"} CurrentUserCtxKey = &contextKey{"CurrentUser"} )
View Source
var ErrNoTokenFound = errors.New("no token found")
Functions ¶
func Authenticator ¶
func Authenticator(tv TokenVerifier, up UserProvider, logger *slog.Logger) func(http.Handler) http.Handler
Authenticator http middleware handler will verify a JWT string from a http request.
Authenticator will search for a JWT token in a http request, in the order:
- 'Authorization: BEARER T' request header
- Cookie 'jwt' value
The first JWT string that is found as a query parameter, authorization header or cookie header is then decoded by the `jwt-go` library and a *jwt.Token object is set on the request context. In the case of a signature decoding error the Authenticator will also set the error on the request context.
Types ¶
type TokenVerifier ¶
type TokenVerifier interface {
VerifyTokenStringWithES256(tokenString string) (*serviceJwt.Token, error)
}
Click to show internal directories.
Click to hide internal directories.