auth

package
v0.0.0-...-fa930de Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateToken

func CreateToken(user models.User) (signedToken string, err error)

GenerateToken generates a JWT token GenerateToken takes an email as an argument and returns a signed JWT token and an error

func ExtractTokenID

func ExtractTokenID(r *http.Request) (uint, error)

ExtractTokenID extracts the token id from the http request r: the http request returns: the token id and an error if any

func Extractoken

func Extractoken(r *http.Request) string

ExtractToken extracts the token from the http request r: the http request returns: the token string

func Pretty

func Pretty(data interface{})

Pretty display the claims licely in the terminal data: the data to be displayed

func RefreshToken

func RefreshToken(user models.User) (signedtoken string, err error)

RefreshToken generates a refresh jwt token RefreshToken takes an email as an argument and returns a signed JWT token and an error

func ValidateToken

func ValidateToken(r *http.Request) error

ValidateToken validates the JWT token ValidateToken takes a signed JWT token as an argument and returns the JwtClaim and an error

Types

type JwtClaim

type JwtClaim struct {
	ID         uint
	Email      string
	Authorized bool
	jwt.RegisteredClaims
}

JwtClaim adds email as a claim to the token JwtClaim is a struct that holds the Email of the user, as well as the StandardClaims

Jump to

Keyboard shortcuts

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