jwt

package
v1.0.0-beta.71 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(token string) (map[string]any, error)

--------------------------------------------------------------------------- Decode: No signature verification — just read claims from any JWT ---------------------------------------------------------------------------

func DecodeTo

func DecodeTo[T any](token string) (*T, error)

--------------------------------------------------------------------------- DecodeTo: Decode into a provided generic struct (no signature validation) ---------------------------------------------------------------------------

func Validate

func Validate[T any](tokenStr, jwtSecret string) (*T, error)

--------------------------------------------------------------------------- Validate: Verify JWT signature using JWT secret ---------------------------------------------------------------------------

Types

type AuthMethodRef

type AuthMethodRef struct {
	Method    string `json:"method"`
	Timestamp int64  `json:"timestamp"`
}

type JWTClaims

type JWTClaims struct {
	Audience     string          `json:"aud"`
	ExpiresAt    int64           `json:"exp"`
	IssuedAt     int64           `json:"iat"`
	Issuer       string          `json:"iss"`
	Subject      string          `json:"sub"`
	Email        string          `json:"email"`
	Phone        string          `json:"phone"`
	AppMetadata  map[string]any  `json:"app_metadata"`
	UserMetadata map[string]any  `json:"user_metadata"`
	Role         string          `json:"role"`
	AAL          string          `json:"aal"`
	AMR          []AuthMethodRef `json:"amr"`
	SessionID    string          `json:"session_id"`
}

func (*JWTClaims) ExpiryTime

func (c *JWTClaims) ExpiryTime() time.Time

func (*JWTClaims) IssuedTime

func (c *JWTClaims) IssuedTime() time.Time

Jump to

Keyboard shortcuts

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