Documentation
¶
Index ¶
- Variables
- func GenerateJWT(username, email string, uuid uuid.UUID, jwtKey []byte, validFor time.Duration) (string, error)
- func GetUserUuidFromCtx(ctx context.Context) (uuid.UUID, error)
- func HttpAllowOnlyAdmins(adminAPIKey []byte) func(http.Handler) http.Handler
- func HttpJwtAuthentication(jwtKey []byte, opts ...JwtAuthOption) func(next http.Handler) http.Handler
- func IsAdmin(ctx context.Context) bool
- type ClaimsKeyType
- type JwtAuthOption
- type JwtClaims
- type PasswordChangedAtLookup
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrEmptyJwtClaims = errors.New("empty jwt claims found in context")
View Source
var ErrNoJwtClaims = errors.New("no jwt claims found in context")
Functions ¶
func GenerateJWT ¶
func HttpAllowOnlyAdmins ¶
HttpAllowOnlyAdmins allows requests authenticated either by an admin JWT or by the server-to-server admin API key.
func HttpJwtAuthentication ¶
func HttpJwtAuthentication(jwtKey []byte, opts ...JwtAuthOption) func(next http.Handler) http.Handler
HttpJwtAuthentication validates JWT token and adds the claims to the request context. Pass WithSecureCookie and optionally WithPasswordChangedAtLookup.
Types ¶
type JwtAuthOption ¶ added in v1.1.1
type JwtAuthOption func(*jwtAuthConfig)
func WithPasswordChangedAtLookup ¶ added in v1.1.1
func WithPasswordChangedAtLookup(lookup PasswordChangedAtLookup) JwtAuthOption
func WithSecureCookie ¶ added in v1.1.1
func WithSecureCookie(secure bool) JwtAuthOption
Click to show internal directories.
Click to hide internal directories.