Documentation
¶
Index ¶
- type Authorizer
- type MapClaims
- type Middleware
- type Provider
- func (provider *Provider) CreateToken(userID, accountID, socialAccountID uint64) (string, time.Time, error)
- func (provider *Provider) ExtractTokenData(token *Token) (*TokenData, error)
- func (provider *Provider) Middleware() *jwtmiddleware.JWTMiddleware
- func (provider *Provider) MiddlewareOptions() *jwtmiddleware.Options
- type Token
- type TokenData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Authorizer ¶
type Authorizer[TUser user.Model, TAccount account.Model] struct { // contains filtered or unexported fields }
Authorizer handles JWT-based authorization for API requests.
func NewAuthorizer ¶
func NewAuthorizer[TUser user.Model, TAccount account.Model](jwtProvider *Provider, loader *accauth.Loader[TUser, TAccount]) *Authorizer[TUser, TAccount]
NewAuthorizer creates a new JWT authorizer instance.
func (*Authorizer[TUser, TAccount]) Authorize ¶
func (au *Authorizer[TUser, TAccount]) Authorize(w http.ResponseWriter, r *http.Request) (token string, usr TUser, acc TAccount, err error)
Authorize validates the JWT token from the request and retrieves associated user and account data.
func (*Authorizer[TUser, TAccount]) AuthorizerCode ¶
func (au *Authorizer[TUser, TAccount]) AuthorizerCode() string
AuthorizerCode returns the identifier for this authorizer.
type MapClaims ¶
MapClaims describes the Claims type that uses map[string]interface{} for JSON decoding
type Provider ¶
type Provider struct {
TokenLifetime time.Duration // Valid time period for tokens
Secret string // Secret key for signing
MiddlewareOpts *jwtmiddleware.Options // Middleware configuration
}
Provider manages JWT token creation and validation
func NewDefaultProvider ¶
NewDefaultProvider creates a new JWT provider with default settings
func (*Provider) CreateToken ¶
func (provider *Provider) CreateToken(userID, accountID, socialAccountID uint64) (string, time.Time, error)
CreateToken generates a new signed JWT token for the given user
func (*Provider) ExtractTokenData ¶
ExtractTokenData extracts and validates claims from a token
func (*Provider) Middleware ¶
func (provider *Provider) Middleware() *jwtmiddleware.JWTMiddleware
Middleware returns a configured JWT middleware handler
func (*Provider) MiddlewareOptions ¶
func (provider *Provider) MiddlewareOptions() *jwtmiddleware.Options
MiddlewareOptions returns configured middleware options with defaults