Documentation ¶
Overview ¶
Package auth implements the application's authentication system.
Index ¶
- func CreateToken(claims map[string]any, expiry time.Duration) (string, error)
- func DecodeHashValidator(validator string) string
- func GenerateSelectorAndValidator() (string, string)
- func ParseToken(token string) (int64, error)
- func VerifyPassword(password string, encodedHash HashedPassword) bool
- type HashedPassword
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateToken ¶
CreateToken creates a JWT token.
func DecodeHashValidator ¶ added in v1.1.0
DecodeHashValidator decodes an encoded hashed validator using SHA-256.
func GenerateSelectorAndValidator ¶
GenerateSelectorAndValidator creates a selector and validator pair. The selector is a unique ID, and the validator is a random token.
func ParseToken ¶
ParseToken parses the JWT token for the userID.
func VerifyPassword ¶
func VerifyPassword(password string, encodedHash HashedPassword) bool
VerifyPassword verifies whether the plain text password and the hashed password are equal.
Types ¶
type HashedPassword ¶
type HashedPassword string
HashedPassword is the type for a hashed password. It ensures that we do not forget to pass a hashed string to functions that require such variable.
func HashPassword ¶
func HashPassword(password string) (HashedPassword, error)
HashPassword hashes a plain text password using argon2.
func (HashedPassword) String ¶
func (h HashedPassword) String() string
String represents the HashedPassword as a string.