auth

package
v0.0.0-...-f3f7782 Latest Latest
Warning

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

Go to latest
Published: May 7, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateToken

func GenerateToken(claims Claims) (string, error)

GenerateToken generates a signed JWT token string representing the user Claims.

Types

type Claims

type Claims struct {
	UserID string `json:"id"`
	Email  string `json:"username"`
	jwt.StandardClaims
}

Claims Create a struct that will be encoded to a JWT. We add jwt.StandardClaims as an embedded type, to provide fields like expiry time

func NewClaims

func NewClaims(id, email string, now time.Time, expires time.Duration) Claims

NewClaims constructs a Claims value for the identified user. The Claims expire within a specified duration of the provided time. Additional fields of the Claims can be set after calling NewClaims is desired.

func ParseClaims

func ParseClaims(tknStr string) (Claims, error)

Jump to

Keyboard shortcuts

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