jwt

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2025 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContextJWTKey = "user"
)
View Source
const EnvPrefix = "JWT"

Variables

View Source
var ErrJWTTokenNotFound = errors.New("jwt token not found")

Functions

This section is empty.

Types

type Config

type Config struct {
	PrivateKey string `env:"_PRIVATE_KEY,required,expand" envDefault:"${PWD}/testdata/test-jwt.key"`
	PublicKey  string `env:"_PUBLIC_KEY,required,expand" envDefault:"${PWD}/testdata/test-jwt.pem"`
}

func GetConfigFromEnv

func GetConfigFromEnv() (*Config, error)

func (Config) GetPrivateKey

func (c Config) GetPrivateKey() ([]byte, error)

func (Config) GetPublicKey

func (c Config) GetPublicKey() ([]byte, error)

type Payload

type Payload struct {
	UserID         string         `json:"user_id"`
	OrgID          string         `json:"org_id"`
	Role           model.UserRole `json:"role"`
	OrgSlug        string         `json:"org_slug"`
	OrgName        string         `json:"org_name"`
	UserName       string         `json:"user_name"`
	Scopes         model.Scopes   `json:"scopes"`
	ChangePassword bool           `json:"change_password"`
}

func DecodeClaims

func DecodeClaims(c *fiber.Ctx) (*Payload, error)

type Service

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

func NewJWT

func NewJWT(privateKey, publicKey []byte) (*Service, error)

func (*Service) Generate

func (j *Service) Generate(payload Payload) (accessToken, refreshToken string, err error)

func (*Service) GetSigningKey

func (j *Service) GetSigningKey() jwtware.SigningKey

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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