jwt

package
v0.0.0-...-ce299e0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RolePowerUser = 5
	RoleReadOnly  = 1
	RoleNone      = 0
)

Variables

View Source
var JwtSigningKey []byte

Functions

func CreateToken

func CreateToken(username string, level int) (string, error)

CreateToken creates a new JWT token.

func TokenAudienceFromRequest

func TokenAudienceFromRequest(r *http.Request) string

func TokenRole

func TokenRole(tokenString string) (int, error)

func ValidateToken

func ValidateToken(tokenString string) (bool, error)

Types

type Claims

type Claims struct {
	Username string `json:"username"`
	Role     int    `json:"role"`
	jwt.StandardClaims
}

Claims will be used to encode the JWT

Jump to

Keyboard shortcuts

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