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, cookieSecure ...bool) func(next http.Handler) http.Handler
- func IsAdmin(ctx context.Context) bool
- type ClaimsKeyType
- type JwtClaims
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, cookieSecure ...bool) func(next http.Handler) http.Handler
HttpJwtAuthentication validates JWT token and adds the claims to the request context. Optional cookieSecure parameter controls the Secure flag when clearing invalid tokens.
Types ¶
Click to show internal directories.
Click to hide internal directories.