jwt

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Issuer is the JWT issuer claim
	Issuer string `json:"issuer"`
	// AccessExpirySeconds is the access token expiry in seconds
	AccessExpirySeconds int `json:"accessExpirySeconds"`
	// RefreshExpirySeconds is the refresh token expiry in seconds
	RefreshExpirySeconds int `json:"refreshExpirySeconds"`
	// SigningAlgorithm is the JWT signing algorithm (HS256, RS256, etc.)
	SigningAlgorithm string `json:"signingAlgorithm"`
	// IncludeAppIDClaim includes app_id in JWT claims
	IncludeAppIDClaim bool `json:"includeAppIDClaim"`
}

Config holds the JWT plugin configuration

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the default JWT plugin configuration

type CreateJWTKeyRequest added in v0.0.7

type CreateJWTKeyRequest struct {
	IsPlatformKey bool                   `json:"isPlatformKey"`
	Algorithm     string                 `json:"algorithm" validate:"required"`
	KeyType       string                 `json:"keyType" validate:"required"`
	Curve         string                 `json:"curve"`
	ExpiresAt     *time.Time             `json:"expiresAt"`
	Metadata      map[string]interface{} `json:"metadata"`
}

Request types

type ErrorResponse

type ErrorResponse = responses.ErrorResponse

ErrorResponse represents an error response for JWT operations - use shared response from core

type GenerateTokenRequest added in v0.0.7

type GenerateTokenRequest struct {
	UserID      string                 `json:"userId" validate:"required"`
	SessionID   string                 `json:"sessionId"`
	TokenType   string                 `json:"tokenType" validate:"required"`
	Scopes      []string               `json:"scopes"`
	Permissions []string               `json:"permissions"`
	Audience    []string               `json:"audience"`
	ExpiresIn   time.Duration          `json:"expiresIn"`
	Metadata    map[string]interface{} `json:"metadata"`
}

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler handles JWT-related HTTP requests

func NewHandler

func NewHandler(service *jwt.Service) *Handler

NewHandler creates a new JWT handler

func (*Handler) CreateJWTKey

func (h *Handler) CreateJWTKey(c forge.Context) error

CreateJWTKey creates a new JWT signing key

func (*Handler) GenerateToken

func (h *Handler) GenerateToken(c forge.Context) error

GenerateToken generates a new JWT token

func (*Handler) GetJWKS

func (h *Handler) GetJWKS(c forge.Context) error

GetJWKS returns the JSON Web Key Set

func (*Handler) ListJWTKeys

func (h *Handler) ListJWTKeys(c forge.Context) error

ListJWTKeys lists JWT signing keys

func (*Handler) VerifyToken

func (h *Handler) VerifyToken(c forge.Context) error

VerifyToken verifies a JWT token

type ListJWTKeysRequest added in v0.0.7

type ListJWTKeysRequest struct {
	Page          int   `query:"page"`
	Limit         int   `query:"limit"`
	Active        *bool `query:"active"`
	IsPlatformKey *bool `query:"is_platform_key"`
}

type Plugin

type Plugin struct {
	// contains filtered or unexported fields
}

Plugin implements the JWT authentication plugin

func NewPlugin

func NewPlugin(opts ...PluginOption) *Plugin

NewPlugin creates a new JWT plugin instance with optional configuration

func (*Plugin) GetHandler

func (p *Plugin) GetHandler() *Handler

GetHandler returns the JWT handler

func (*Plugin) ID

func (p *Plugin) ID() string

ID returns the plugin identifier

func (*Plugin) Init

func (p *Plugin) Init(authInst core.Authsome) error

Init initializes the JWT plugin

func (*Plugin) Migrate

func (p *Plugin) Migrate() error

Migrate runs plugin migrations (no-op for JWT - migrations handled at app level)

func (*Plugin) RegisterHooks

func (p *Plugin) RegisterHooks(_ *hooks.HookRegistry) error

RegisterHooks registers plugin hooks (no-op for JWT)

func (*Plugin) RegisterRoutes

func (p *Plugin) RegisterRoutes(router forge.Router) error

RegisterRoutes registers the JWT plugin's HTTP routes

func (*Plugin) RegisterServiceDecorators

func (p *Plugin) RegisterServiceDecorators(_ *registry.ServiceRegistry) error

RegisterServiceDecorators registers service decorators (no-op for JWT)

type PluginOption

type PluginOption func(*Plugin)

PluginOption is a functional option for configuring the JWT plugin

func WithAccessExpiry

func WithAccessExpiry(seconds int) PluginOption

WithAccessExpiry sets the access token expiry

func WithDefaultConfig

func WithDefaultConfig(cfg Config) PluginOption

WithDefaultConfig sets the default configuration for the plugin

func WithIncludeAppIDClaim

func WithIncludeAppIDClaim(include bool) PluginOption

WithIncludeAppIDClaim sets whether to include app_id claim

func WithIssuer

func WithIssuer(issuer string) PluginOption

WithIssuer sets the JWT issuer

func WithRefreshExpiry

func WithRefreshExpiry(seconds int) PluginOption

WithRefreshExpiry sets the refresh token expiry

func WithSigningAlgorithm

func WithSigningAlgorithm(algorithm string) PluginOption

WithSigningAlgorithm sets the signing algorithm

type VerifyTokenRequest added in v0.0.7

type VerifyTokenRequest struct {
	Token     string   `json:"token" validate:"required"`
	Audience  []string `json:"audience"`
	TokenType string   `json:"tokenType"`
}

Jump to

Keyboard shortcuts

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