jwt

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2021 License: Apache-2.0 Imports: 6 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, c Context, secret string) (tokenString string, err error)

Sign signs the context with the specified secret.

Types

type Context

type Context struct {
	UserID   uint64
	Username string
	Uuid     string
	Email    string
	IsAdmin  uint64
}

ctx is the context of the JSON web token.

func Parse

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

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

func ParseRequest

func ParseRequest(head http.Header, secret string) (*Context, 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