auth

package
v0.0.0-...-51ece97 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComparePasswords

func ComparePasswords(pwHash string, plain []byte) bool

func CreateJWT

func CreateJWT(secret string, userID int, expiresInSeconds int) (string, error)

func GenerateSessionID

func GenerateSessionID() (string, error)

Creates a 32-byte (256-bit) long unique session IDs using rand.Read() Returns it and saves it to the database. with P(n) approx. 1 - e^(-4.32*10^-42) probabilyt for a collision and should therefore be reliable for this use case.

Ensuring uniqueness is important to enable storing IDs as map keys for O(1) lookups in most cases.

func HashPassword

func HashPassword(pw string) (string, error)

func ValidateJWT

func ValidateJWT(tokenString string, secret string) (jwt.MapClaims, error)

func ValidateSession

func ValidateSession(s types.Session) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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