jwt

package
v0.13.2 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Generator

type Generator struct {
	ApplicationID string
	PrivateKey    []byte
	TTL           time.Duration
	Subject       string
	Paths         []Path
	JTI           uuid.UUID
	NBF           int64
	// contains filtered or unexported fields
}

Generator is what makes a token. Set the fields you need, then generate. The token is also stored in `token` once generated.

func NewGenerator

func NewGenerator(ApplicationID string, PrivateKey []byte) *Generator

NewGenerator takes your application ID and private key to create a generator

func NewGeneratorFromFilename

func NewGeneratorFromFilename(ApplicationID string, PrivateKeyFileName string) (*Generator, error)

NewGeneratorFromFilename takes your application ID and the filename of your private key to create a token generator

func (*Generator) AddPath

func (g *Generator) AddPath(path Path) *Generator

AddPath adds an entry to the ACL "paths" field

func (*Generator) GenerateToken

func (g *Generator) GenerateToken() (string, error)

GenerateToken assembles and returns the JWT token

func (*Generator) GetClaims

func (g *Generator) GetClaims() jwt.MapClaims

GetClaims returns the body claims for the generated token

func (*Generator) GetHeader

func (g *Generator) GetHeader() map[string]interface{}

GetHeader gives access to the header fields `alg` and `typ` of the generated token

type Path

type Path struct {
	Path string
}

Path represents each path in the ACL structure

Jump to

Keyboard shortcuts

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