jwt

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadKeyFile

func LoadKeyFile(filename string) error

LoadKeyFile loads private key file

func SignedToken

func SignedToken(keyId string, claims Claims) (string, error)

SignedToken signs the claims as a token string

Types

type Claims

type Claims struct {
	jwt.StandardClaims
	Payload
}

Claims represents all the fields of jwt

func VerifyToken

func VerifyToken(keyId, issuer, token string) (*Claims, error)

VerifyToken parses and verifies the token string

func (Claims) Valid

func (c Claims) Valid() error

Valid checks whether the claims is valid

type Payload

type Payload struct {
	Salt   string   `json:"salt,omitempty"`
	Ver    string   `json:"ver,omitempty"`
	Uid    int64    `json:"uid,omitempty"`
	IP     string   `json:"ip,omitempty"`
	Loc    string   `json:"loc,omitempty"`
	Chan   int      `json:"chan,omitempty"`
	Os     string   `json:"os,omitempty"`
	Flags  int64    `json:"flags,omitempty"`
	Scopes []string `json:"scopes,omitempty"`

	Name   string `json:"name,omitempty"`
	Avatar string `json:"avatar,omitempty"`
	Gender int    `json:"gender,omitempty"`

	Accounts map[string]string `json:"accounts"`
}

Payload holds the custom fields of jwt

func (*Payload) AddScopes

func (p *Payload) AddScopes(scopes ...string)

AddScopes appends a score

func (Payload) HasScope

func (p Payload) HasScope(scope string) bool

HasScope checks whether the payload has specified scope

Jump to

Keyboard shortcuts

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