token

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2019 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Claims

type Claims struct {
	jwt.StandardClaims
	Userid   string `json:"userid"`
	AuthTags string `json:"auth_tags"`
	ID       string `json:"id"`
	Key      string `json:"key"`
}

Claims is a set of fields to describe a user

type Tokenizer

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

Tokenizer is a token generator

func New

func New(secret, issuer string) *Tokenizer

New creates a new Tokenizer

func (*Tokenizer) Generate

func (t *Tokenizer) Generate(u *usermodel.Model, duration int64, subject, id, key string) (string, *Claims, error)

Generate returns a new jwt token from a user model

func (*Tokenizer) GenerateFromClaims

func (t *Tokenizer) GenerateFromClaims(claims *Claims, duration int64, subject, key string) (string, *Claims, error)

GenerateFromClaims creates a new jwt from a set of claims

func (*Tokenizer) GetClaims

func (t *Tokenizer) GetClaims(tokenString, subject string) (bool, *Claims)

GetClaims returns the tokens claims without validation

func (*Tokenizer) Validate

func (t *Tokenizer) Validate(tokenString, subject string) (bool, *Claims)

Validate returns whether a token is valid

Jump to

Keyboard shortcuts

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