auth

package
v0.20.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateChatToken

func GenerateChatToken(info ChatToken, secret string, expiresIn time.Duration) (string, time.Time, error)

GenerateChatToken creates a signed JWT for chat route reply.

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 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 ChatToken

type ChatToken struct {
	BotID             string
	ChatID            string
	RouteID           string
	UserID            string
	ChannelIdentityID string
}

ChatToken holds the claims for a chat-based JWT used for route-based reply.

func ChatTokenFromContext

func ChatTokenFromContext(c echo.Context) (ChatToken, error)

ChatTokenFromContext extracts the chat token claims from context.

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