utils

package
v0.0.0-...-ee0b071 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

CheckPasswordHash compares a hashed password with its plain text equivalent

func GenerateJWT

func GenerateJWT(username, role string) (string, error)

GenerateJWT generates a JWT token for a user

func GenerateRandomKey

func GenerateRandomKey(length int) ([]byte, error)

GenerateRandomKey creates a secure random key of specified length

func HashPassword

func HashPassword(password string) (string, error)

HashPassword hashes a plain text password

func InitializeJWTKey

func InitializeJWTKey(key []byte)

InitializeJWTKey sets the JWT signing key

Types

type Claims

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

Claims defines the JWT payload

func VerifyJWT

func VerifyJWT(tokenString string) (*Claims, error)

VerifyJWT parses and validates a JWT token

Jump to

Keyboard shortcuts

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