auth

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2025 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateAccessToken

func GenerateAccessToken(userID, email, role, secret string, expiry time.Duration) (string, error)

GenerateAccessToken generates a JWT access token

func GenerateRefreshToken

func GenerateRefreshToken() (string, error)

GenerateRefreshToken generates a random refresh token

func HashPassword

func HashPassword(password string) (string, error)

HashPassword hashes a password using argon2id

func HashRefreshToken

func HashRefreshToken(token string) string

HashRefreshToken hashes a refresh token for storage

func VerifyPassword

func VerifyPassword(password, encoded string) (bool, error)

VerifyPassword verifies a password against a hash

Types

type Claims

type Claims struct {
	UserID string `json:"user_id"`
	Email  string `json:"email"`
	Role   string `json:"role"`
	jwt.RegisteredClaims
}

Claims represents JWT claims

func ValidateAccessToken

func ValidateAccessToken(tokenString, secret string) (*Claims, error)

ValidateAccessToken validates a JWT access token

Jump to

Keyboard shortcuts

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