jwt

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateToken

func CreateToken[T any](data *T, sessionToken string, sessionInterval time.Duration) (string, error)

CreateToken creates a new signed jwt token with the user information saved in the claims.

func ValidateToken

func ValidateToken[T any](tokenString, sessionToken string) (*T, error)

ValidateToken validates a given jwt token and returns the user from the claims or an error when the validation fails.

Types

type CustomClaims

type CustomClaims[T any] struct {
	Data *T `json:"data,omitempty"`
	goJWT.RegisteredClaims
}

CustomClaims is the struct which defines the claims for our jwt tokens.

Jump to

Keyboard shortcuts

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