jwt

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2021 License: MIT Imports: 8 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
	Payload
}

Claims represents all the fields of jwt

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

type Signer added in v0.0.7

type Signer struct {
	Verifier
	// contains filtered or unexported fields
}

Signer

func NewSigner added in v0.0.7

func NewSigner(filename, keyId string) (*Signer, error)

func (*Signer) Sign added in v0.0.7

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

Sign signs the claims as a token string

type Verifier added in v0.0.7

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

Verifier ...

func NewVerifier added in v0.0.7

func NewVerifier(filename, keyId string) (*Verifier, error)

func (*Verifier) Verify added in v0.0.7

func (v *Verifier) Verify(issuer, token string) (*Claims, error)

Jump to

Keyboard shortcuts

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