jwt

package
v2.0.0-beta4 Latest Latest
Warning

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

Go to latest
Published: May 12, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoPrivKeyFile  = errors.New("private key file unreadable")
	ErrInvalidPrivKey = errors.New("RSA private key invalid")
	ErrNoPubKeyFile   = errors.New("public key file unreadable")
	ErrInvalidPubKey  = errors.New("RSA public key invalid")
)

Functions

func GetKey

func GetKey(key string) ([]byte, error)

func GetRSAPrivateKey

func GetRSAPrivateKey(key string) (*rsa.PrivateKey, error)

func GetRSAPublicKey

func GetRSAPublicKey(key string) (*rsa.PublicKey, error)

func RegisteredClaims

func RegisteredClaims(iss string, sub uuid.UUID, aud jwt.ClaimStrings, ttl time.Duration) jwt.RegisteredClaims

Types

type Config

type Config struct {
	PrivateKey      string        `mapstructure:"private_key"`
	AccessTokenTTL  time.Duration `mapstructure:"access_token_ttl"`
	RefreshTokenTTL time.Duration `mapstructure:"refresh_token_ttl"`
	// contains filtered or unexported fields
}

func (*Config) GetPrivateKey

func (cfg *Config) GetPrivateKey() *rsa.PrivateKey

func (*Config) GetPublicKey

func (cfg *Config) GetPublicKey() *rsa.PublicKey

func (*Config) Init

func (cfg *Config) Init()

type Signer

type Signer interface {
	Sign(claims jwt.Claims) (string, error)
}

func NewSigner

func NewSigner(key *rsa.PrivateKey) Signer

type UserClaims

type UserClaims struct {
	jwt.RegisteredClaims
	Username string          `json:"username,omitempty"`
	Email    string          `json:"email,omitempty"`
	Roles    []string        `json:"roles,omitempty"`
	OTP      bool            `json:"otp"`
	Meta     json.RawMessage `json:"meta,omitempty"`
}

func (UserClaims) UserID

func (c UserClaims) UserID() uuid.UUID

func (UserClaims) Valid

func (c UserClaims) Valid() error

Jump to

Keyboard shortcuts

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