auth

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: AGPL-3.0 Imports: 8 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) echo.MiddlewareFunc

JWTMiddleware returns a JWT auth middleware configured for HS256 tokens.

func RefreshTokenFromContext added in v0.1.1

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.

Jump to

Keyboard shortcuts

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