utils

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2025 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashPassword

func HashPassword(password string) (string, error)

HashPassword hashes password using Argon2ID

func NewUserTokenWithExpiration added in v0.1.1

func NewUserTokenWithExpiration(
	userID uint64,
	role model.UserRole,
	secret string,
	expiresAt time.Time,
) (*userpb.UserToken, error)

NewUserTokenWithExpiration creates a new UserToken with a custom expiration time.

func VerifyPassword

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

VerifyPassword verifies a password against its hash

Types

type PasswordConfig

type PasswordConfig struct {
	// contains filtered or unexported fields
}

Password hashing configuration

type UserTokenClaims

type UserTokenClaims struct {
	jwt.MapClaims
}

func NewUserTokenClaims

func NewUserTokenClaims(userID uint64, role model.UserRole) UserTokenClaims

NewUserTokenClaims creates a new UserTokenClaims with a default 24-hour expiration. Deprecated: This function uses a hardcoded 24-hour expiration time. Use NewUserTokenClaimsWithExpiration instead to specify a custom expiration time.

func NewUserTokenClaimsWithExpiration added in v0.1.1

func NewUserTokenClaimsWithExpiration(
	userID uint64,
	role model.UserRole,
	expiresAt time.Time,
) UserTokenClaims

NewUserTokenClaimsWithExpiration creates a new UserTokenClaims with a custom expiration time.

func ValidateUserToken

func ValidateUserToken(tokenString, secret string) (*UserTokenClaims, error)

func (UserTokenClaims) GetAudience

func (c UserTokenClaims) GetAudience() (jwt.ClaimStrings, error)

func (UserTokenClaims) GetExpirationTime

func (c UserTokenClaims) GetExpirationTime() (*jwt.NumericDate, error)

func (UserTokenClaims) GetIssuedAt

func (c UserTokenClaims) GetIssuedAt() (*jwt.NumericDate, error)

func (UserTokenClaims) GetIssuer

func (c UserTokenClaims) GetIssuer() (string, error)

func (UserTokenClaims) GetNotBefore

func (c UserTokenClaims) GetNotBefore() (*jwt.NumericDate, error)

func (UserTokenClaims) GetSubject

func (c UserTokenClaims) GetSubject() (string, error)

Jump to

Keyboard shortcuts

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