jwt

package
v0.0.0-...-ef8624d Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeKey         = "type"
	AccessTokenTTL  = time.Minute * 60 //TODO: lower value
	RefreshTokenTTL = time.Hour * (30 * 24)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

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

func NewBuilder

func NewBuilder(signer Signer) *Builder

func (*Builder) Build

func (b *Builder) Build(payload Payload) (Pair, error)

type Claims

type Claims struct {
	Type string
	Payload
	jwt.RegisteredClaims
}

type EdDSAParser

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

func NewEdDSAParser

func NewEdDSAParser(publicKey, jwtType string) (*EdDSAParser, error)

func (*EdDSAParser) Parse

func (p *EdDSAParser) Parse(tokenString string) (*Payload, error)

Parse and validate token

type EdDSASigner

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

func (*EdDSASigner) Sign

func (s *EdDSASigner) Sign(claims Claims) (string, error)

type Factory

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

func NewFactory

func NewFactory(privateKey string) (*Factory, error)

func (*Factory) NewBuilder

func (g *Factory) NewBuilder() *Builder

type Pair

type Pair struct {
	RefreshToken string
	AccessToken  string
	IssuedAt     time.Time
}

type Parser

type Parser interface {
	Parse(token string) (*Payload, error)
}

type Payload

type Payload struct {
	UserID uint
	Roles  []string
}

type Signer

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

func NewEdDSASigner

func NewEdDSASigner(privateKey string) (Signer, error)

Jump to

Keyboard shortcuts

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