token

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func Sign

func Sign(ctx context.Context, payload map[string]interface{}, secret string, timeout int64) (tokenString string, err error)

Sign signs the payload with the specified secret.

Types

type Payload added in v1.3.0

type Payload struct {
	UserID   uint64
	Username string
}

Payload is the data of the JSON web token.

func Parse

func Parse(tokenString string, secret string) (*Payload, error)

Parse validates the token with the specified secret, and returns the payloads if the token was valid.

func ParseRequest

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

ParseRequest gets the token from the header and pass it to the Parse function to parses the token.

Jump to

Keyboard shortcuts

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