authx

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2021 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth struct {

	// Key used for signing
	Key string `yaml:"key"`

	// Identifies principal that issued the JWT
	Iss string `yaml:"iss"`

	// Identifies the recipients that the JWT is intended for
	Aud []string `yaml:"aud"`

	// Identifies the subject of the JWT.
	Sub string `yaml:"sub"`

	// Identifies the time on which the JWT will start to be accepted for processing
	Nbf int64 `yaml:"nbf"`

	// Identifies the expiration time on and after which the JWT must not be accepted for processing
	Exp int64 `yaml:"exp"`
}

func (*Auth) Create

func (x *Auth) Create(jti string, data map[string]interface{}) (tokenString string, err error)

Create create authentication token

  • jti Case-sensitive unique identifier of the token even among different issuers
  • data Custom claims

func (*Auth) Verify

func (x *Auth) Verify(tokenString string) (claims jwt.MapClaims, err error)

Verify Authentication

  • tokenString The token string

type Authx

type Authx struct {

	// Multi-scene authentication
	Scenes map[string]*Auth
}

func New

func New(scenes map[string]*Auth) *Authx

New create authentication

  • scenes Multi-scene authentication, the key is equal to subject

func (*Authx) Make

func (x *Authx) Make(name string) *Auth

Make obtain scene authorization

  • name Scene name

Jump to

Keyboard shortcuts

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