jwt

package
v0.0.0-...-626c64f Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2020 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Token Types
	TokenTypeAccess  = "access_token"
	TokenTypeRefresh = "refresh_token"
	TokenTypeConfirm = "confirm_token"
	// AuthType
	AuthTypeBearer = "bearer"
	// Roles
	RoleUser     = "user"
	RoleBusiness = "business"
	RoleAdmin    = "admin"
)

Variables

This section is empty.

Functions

func Create

func Create(claims Claims) (string, *apierror.Error)

Create generates a new JWT, returns it as a string

func Init

func Init(conf *config.Configuration) (err error)

Init initializes jwt, loads public and private key

Types

type Claims

type Claims struct {
	_jwt.StandardClaims
	// UserID is the User ID
	UserID string `json:"uid"`
	// EmailOK Email was confirmed i.e. user is valid
	EmailOK bool `json:"eok"`
	// Role user role "admin"|"user"|"business"
	Role string `json:"rol"`
	// TokenType is either an access_token, refresh_token, confirm_token
	TokenType string `json:"ttp"`
	// AuthType is the type of auth for the JWT (for now always "bearer")
	AuthType string `json:"ath"`
}

Claims extends the StandarClaims

func New

func New() Claims

New Creates New set of JWT Claims

func Verify

func Verify(jwtStr string) (*Claims, *apierror.Error)

Verify parses token to see if is a valid JWT It only validates "standard" JWT claims, we still need to validate Zale claims

func (Claims) Valid

func (c Claims) Valid() error

Valid is called by JWT Parser method

Jump to

Keyboard shortcuts

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