authentication

package
v0.8.5 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: LGPL-3.0 Imports: 12 Imported by: 0

README

What does this directory DO?

The primary authentication.go file defines structures and methods for PasswordSession, PasswordInfo, and Token. It also provides the ValidatePassword() method used to confirm user passwords, and a CompileLocksmithPassword() function to generate a hashed password.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateRandomBytes

func GenerateRandomBytes(n int) ([]byte, error)

GenerateRandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func GenerateRandomString

func GenerateRandomString(n int) (string, error)

GenerateRandomString returns a securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func GenerateRandomStringURLSafe

func GenerateRandomStringURLSafe(n int) (string, error)

GenerateRandomStringURLSafe returns a URL-safe, base64 encoded securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func ValidatePassword

func ValidatePassword(locksmithPassword PasswordInfo, inputPassword string) (bool, error)

Types

type PasswordInfo

type PasswordInfo struct {
	Password            string                `json:"password" bson:"password"`
	Salt                string                `json:"salt" bson:"salt"`
	WebAuthnCredentials []webauthn.Credential `json:"webauthn" bson:"webauthn"`
}

func CompileLocksmithPassword

func CompileLocksmithPassword(password string, saltString ...string) (PasswordInfo, error)

func PasswordInfoFromMap

func PasswordInfoFromMap(passinfo map[string]interface{}) PasswordInfo

func (PasswordInfo) ToMap added in v0.3.0

func (p PasswordInfo) ToMap() map[string]interface{}

type PasswordSession

type PasswordSession struct {
	Token     string `json:"token" bson:"token"`
	ExpiresAt int64  `json:"expire" bson:"expire"`
}

func PasswordSessionFromJson

func PasswordSessionFromJson(data string) (PasswordSession, error)

func (PasswordSession) FromMap added in v0.3.0

func (p PasswordSession) FromMap(input map[string]interface{}) PasswordSession

func (PasswordSession) IsExpired

func (p PasswordSession) IsExpired() bool

func (PasswordSession) Marshal

func (p PasswordSession) Marshal() ([]byte, error)

func (PasswordSession) ToMap added in v0.3.0

func (p PasswordSession) ToMap() map[string]interface{}

type PasswordSessions added in v0.3.0

type PasswordSessions []PasswordSession

func (PasswordSessions) FromMap added in v0.3.0

func (p PasswordSessions) FromMap(input []map[string]interface{}) []PasswordSession

func (PasswordSessions) ToMap added in v0.3.0

func (p PasswordSessions) ToMap() []map[string]interface{}

type Token

type Token struct {
	Token    string
	Username string
}

func ParseToken

func ParseToken(cookieValue string) (Token, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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