token

package
v0.0.0-...-dfe2c77 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(key string, identityKey string, expiration time.Duration)

The Init module sets the package-level configuration named "config". This "config" will be used for token issuance and parsing in the subsequent parts of this package.

func Parse

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

Parse uses the specified key 'key' to parse the token. If the parsing is successful, it returns the token context; otherwise, an error is reported.

func ParseRequest

func ParseRequest(ctx context.Context) (string, error)

ParseRequest retrieves the token from the request header and passes it to the Parse function for token parsing.

func Sign

func Sign(identityKey string) (string, time.Time, error)

The Sign module issues tokens using the jwtSecret. The claims in the token will store the subject that was passed in.

Types

type Config

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

token Config

Jump to

Keyboard shortcuts

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