jwtauth

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2019 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JWTAuth

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

JWTAuth - jwt Authenticate

func New

func New(store Storer, opts ...Option) *JWTAuth

New - Create an authentication instance

func (*JWTAuth) DestroyToken

func (a *JWTAuth) DestroyToken(ctx context.Context, tokenString string) error

DestroyToken - Destroy token

func (*JWTAuth) GenerateToken

func (a *JWTAuth) GenerateToken(ctx context.Context, userUUID string) (auth.TokenInfo, error)

GenerateToken - Generate token

func (*JWTAuth) ParseUserUUID

func (a *JWTAuth) ParseUserUUID(ctx context.Context, tokenString string) (string, error)

ParseUserUUID - Resolve user UUID

func (*JWTAuth) Release

func (a *JWTAuth) Release() error

Release - Release resources

type Option

type Option func(*options)

Option - Defining parameter items

func SetExpired

func SetExpired(expired int) Option

SetExpired - Set the token expiration time (in seconds, default 7200)

func SetKeyfunc

func SetKeyfunc(keyFunc jwt.Keyfunc) Option

SetKeyfunc - Set the callback function of the verification key

func SetSigningKey

func SetSigningKey(key interface{}) Option

SetSigningKey - Set signature key

func SetSigningMethod

func SetSigningMethod(method jwt.SigningMethod) Option

SetSigningMethod - Set signature method

type Storer

type Storer interface {
	// Store token data and specify expiration time
	Set(ctx context.Context, tokenString string, expiration time.Duration) error
	// Check if the token exists
	Check(ctx context.Context, tokenString string) (bool, error)
	// Close storage
	Close() error
}

Storer - Token storage interface

Directories

Path Synopsis
store

Jump to

Keyboard shortcuts

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