jwt

package module
v0.0.0-...-d56f406 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2022 License: MIT Imports: 11 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ForgeToken

func ForgeToken(uid, email, role string, level int, referralID int, key *rsa.PrivateKey, customClaims jwt.MapClaims) (string, error)

ForgeToken creates a valid JWT signed by the given private key

Types

type Auth

type Auth struct {
	UID        string      `json:"uid"`
	State      string      `json:"state"`
	Email      string      `json:"email"`
	Username   string      `json:"username"`
	Role       string      `json:"role"`
	ReferralID json.Number `json:"referral_id"`
	Level      json.Number `json:"level"`
	Audience   []string    `json:"aud,omitempty"`

	jwt.StandardClaims
}

Auth struct represents parsed jwt information.

func ParseAndValidate

func ParseAndValidate(token string, key *rsa.PublicKey) (Auth, error)

ParseAndValidate parses token and validates it's jwt signature with given key.

type KeyStore

type KeyStore struct {
	PublicKey  *rsa.PublicKey
	PrivateKey *rsa.PrivateKey
}

func LoadOrGenerateKeys

func LoadOrGenerateKeys(privPath, pubPath string) (*KeyStore, error)

func (*KeyStore) GenerateKeys

func (ks *KeyStore) GenerateKeys() error

func (*KeyStore) LoadPrivateKey

func (ks *KeyStore) LoadPrivateKey(path string) error

func (*KeyStore) LoadPublicKeyFromFile

func (ks *KeyStore) LoadPublicKeyFromFile(path string) error

func (*KeyStore) LoadPublicKeyFromString

func (ks *KeyStore) LoadPublicKeyFromString(str string) error

func (*KeyStore) SavePrivateKey

func (ks *KeyStore) SavePrivateKey(path string) error

func (*KeyStore) SavePublicKey

func (ks *KeyStore) SavePublicKey(path string) error

Jump to

Keyboard shortcuts

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