utils

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2024 License: MIT Imports: 15 Imported by: 1

Documentation

Index

Constants

View Source
const CancelRequestKey = "cancel_request"

Variables

This section is empty.

Functions

func Assert

func Assert(condition bool, message string)

func CancelRequest

func CancelRequest(r *http.Request) error

func DecodeAndComparePasswords

func DecodeAndComparePasswords(plainTextPassword string, encodedPassword string, encodedSalt string, config AuthConfig) (bool, error)

func DecodeJwt

func DecodeJwt(rawToken string) (string, error)

func GenerateAuthCookie

func GenerateAuthCookie(userId int) (*http.Cookie, error)

TODO: More Generic: Update to Take in a value

func GenerateEncodedSaltAndPasswordHash

func GenerateEncodedSaltAndPasswordHash(password string, config AuthConfig) (encodedPassword string, encodedSalt string, err error)

func GenerateJwt

func GenerateJwt(userId string) (string, error)

func GeneratePasswordHash

func GeneratePasswordHash(password string, salt []byte, config AuthConfig) []byte

func GenerateSalt

func GenerateSalt(length int32) ([]byte, error)

func GetFunctionName

func GetFunctionName(function any) string

func ReadEnv

func ReadEnv()

Types

type AuthConfig

type AuthConfig struct {
	Time    uint32
	Memory  uint32
	Threads uint8
	KeyLen  uint32
	SaltLen int32
}

type UserJwt

type UserJwt struct {
	UserId    string
	ExpiresAt string
}

Jump to

Keyboard shortcuts

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