auth

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package auth implements the application's authentication system.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateToken

func CreateToken(claims map[string]any, expiry time.Duration) (string, error)

CreateToken creates a JWT token.

func DecodeHashValidator added in v1.1.0

func DecodeHashValidator(validator string) string

DecodeHashValidator decodes an encoded hashed validator using SHA-256.

func GenerateSelectorAndValidator

func GenerateSelectorAndValidator() (string, string)

GenerateSelectorAndValidator creates a selector and validator pair. The selector is a unique ID, and the validator is a random token.

func HashValidator

func HashValidator(validator string) string

HashValidator creates a hashed validator using SHA-256.

func ParseToken

func ParseToken(token string) (int64, error)

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.

Jump to

Keyboard shortcuts

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