jwt

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authorizer

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

func NewAuthorizer

func NewAuthorizer(jwtProvider *Provider) *Authorizer

func (*Authorizer) Authorize

func (au *Authorizer) Authorize(w http.ResponseWriter, r *http.Request) (token string, usr *model.User, acc *model.Account, err error)

func (*Authorizer) AuthorizerCode

func (au *Authorizer) AuthorizerCode() string

type MapClaims

type MapClaims = jwt.MapClaims

MapClaims describes the Claims type that uses the map[string]interface{} for JSON decoding This is the default claims type if you don't supply one

type Middleware

type Middleware = jwtmiddleware.JWTMiddleware

Middleware object type

type Provider

type Provider struct {
	// TokenLifetime defineds the valid time-period of token
	TokenLifetime time.Duration

	// Secret of session generation
	Secret string

	// MiddlewareOpts to get middelware procedure
	MiddlewareOpts *jwtmiddleware.Options
}

Provider to JWT constructions

func NewDefaultProvider

func NewDefaultProvider(secret string, tokenLifetime time.Duration, isDebug bool) *Provider

NewDefaultProvider returns new provider

func (*Provider) CreateToken

func (provider *Provider) CreateToken(userID, accountID, socialAccountID uint64) (string, time.Time, error)

CreateToken new token for user ID

func (*Provider) ExtractTokenData

func (provider *Provider) ExtractTokenData(token *Token) (*TokenData, error)

ExtractTokenData into the token struct

func (*Provider) Middleware

func (provider *Provider) Middleware() *jwtmiddleware.JWTMiddleware

Middleware returns middleware object with custom validation procedure

func (*Provider) MiddlewareOptions

func (provider *Provider) MiddlewareOptions() *jwtmiddleware.Options

MiddlewareOptions returns the options of middelware

type Token

type Token = jwt.Token

Token of JWT session

type TokenData

type TokenData struct {
	UserID          uint64
	AccountID       uint64
	SocealAccountID uint64
	ExpireAt        int64
}

TokenData extracted from token

Jump to

Keyboard shortcuts

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