token

package
v0.0.0-...-49bf833 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMissingHeader = errors.New("the length of the `Authorization` header is zero")

ErrMissingHeader represent the error when the `Authorization` header is empty

Functions

func Init

func Init(key string, identityKey string)

Init sets the package-level config, which will used for token issuing and parsing in this package

func Parse

func Parse(tokenString string, key string) (string, error)

Parse uses the specified key to parse the token. If successful, it returns the token context; otherwise, it returns an error tokenString is the token to be parsed key is the secret key used to sign the token

func ParseRequest

func ParseRequest(c *gin.Context) (string, error)

ParseRequest is used to parse the token from the Authorization header and passes it to the Parse function for Token parsing

func Sign

func Sign(identityKey string) (string, error)

Sign issues a token using jwtSecret the token's claims will contain the provided subject

Types

type Config

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

Config is the configuration for the token package

Jump to

Keyboard shortcuts

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