token

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: May 1, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(token string, v interface{}) error

Decode accepts a token string and unmarshals the header and payload segments into the given interface{}

func Gen

func Gen(params Claims, expMinutes time.Duration) string

Gen does what GenWithSecret does but gets the signing key from the env var TOKEN_SECRET

func GenWithSecret

func GenWithSecret(params Claims, secret []byte, expMinutes time.Duration) string

GenWithSecret generates a jwt token string from a payload, secret and exp duration

func Parse

func Parse(token string) (*jwt.Token, error)

Parse does what ParseWithSecret does but gets the signing key from the env var TOKEN_SECRET

func ParseWithSecret

func ParseWithSecret(token string, secret []byte) (*jwt.Token, error)

ParseWithSecret attempts to parse a token string given a custom siginin key. Then returns a Token if string/key is valid

func Test

func Test(token string) error

Test does what TestWithSecret does but gets the signing key from the env var TOKEN_SECRET

func TestWithSecret

func TestWithSecret(token string, secret []byte) error

TestWithSecret verifies a token and returns an error if the token is invalid

Types

type Claims

type Claims map[string]interface{}

Claims defines the structure for a token payload

Jump to

Keyboard shortcuts

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