auth

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateToken

func GenerateToken(userID, secret string, expiresIn time.Duration) (string, time.Time, error)

GenerateToken creates a signed JWT for the user.

func JWTMiddleware

func JWTMiddleware(secret string, skipper middleware.Skipper, validators ...UserSessionValidator) echo.MiddlewareFunc

JWTMiddleware returns a JWT auth middleware configured for HS256 tokens.

func RawTokenFromContext added in v0.21.0

func RawTokenFromContext(c echo.Context) string

RawTokenFromContext returns the token the middleware validated, as it arrived, whether from the Authorization header or the token query parameter. It is empty when the request carries no valid token.

func RefreshTokenFromContext

func RefreshTokenFromContext(c echo.Context, secret string, defaultExpiresIn time.Duration) (string, time.Time, error)

RefreshTokenFromContext extracts the current token from context and issues a new one with the same claims but a renewed expiration time.

func UserIDFromContext

func UserIDFromContext(c echo.Context) (string, error)

UserIDFromContext extracts the user id from JWT claims.

Types

type UserSessionValidator

type UserSessionValidator func(ctx context.Context, userID string) error

UserSessionValidator revalidates an account-backed JWT against current server-side account state before the request reaches a handler.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL