jwt

package
v0.0.0-...-0f828a4 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2021 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateJwt

func CreateJwt(claim Claim) (string, error)

Creates a new JWT that contains the provided Claim signed by the key from the configuration.

func ParseJwt

func ParseJwt(tokenStr string) (jwt.Claims, error)

Parses a JWT by first converting the supplied token string into a jwt.Token and then checking if the token is valid.

Types

type Claim

type Claim interface {
	ToClaim() ClaimOptions
}

Something that can be encoded into JWT claims.

type ClaimOptions

type ClaimOptions struct {
	Claim jwt.MapClaims
	Exp   time.Duration
}

Contains options for the JWT creation.

type UserClaim

type UserClaim struct {
	UserId uint
}

func NewUserClaim

func NewUserClaim(userId uint) UserClaim

Returns a new UserClaim instance.

func (*UserClaim) ToClaim

func (uc *UserClaim) ToClaim() ClaimOptions

Jump to

Keyboard shortcuts

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