auth

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ROLE_ADMIN      string = "ADMIN"
	ROLE_ZONE_ADMIN string = "ZONE_ADMIN"
)

Variables

This section is empty.

Functions

func CurrentUser

func CurrentUser(c *gin.Context) (string, error)

Extract the current user from the token

func CurrentUserRoles added in v0.7.0

func CurrentUserRoles(c *gin.Context) ([]string, error)

func ExtractToken

func ExtractToken(c *gin.Context) string

Extract the JWT Token from the Gin Context

func GenerateToken

func GenerateToken(username string, roles []string) (string, error)

func HasRole

func HasRole(context *gin.Context, role string) bool

func HashPassword

func HashPassword(password string) (string, error)

func JWTMiddleware

func JWTMiddleware() gin.HandlerFunc

func ValidatePassword

func ValidatePassword(hashedPassword, currPassword string) bool

func ValidateToken

func ValidateToken(c *gin.Context) error

Validate if the JWT token is valid, is from this issuer, and is signed with the approriate secret Will return an error if anything is off with the token

Types

This section is empty.

Jump to

Keyboard shortcuts

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