basicauth

package
v0.0.0-...-113b215 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0, BSD-2-Clause Imports: 6 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DerivePasswordKey

func DerivePasswordKey(password []byte, salt []byte) ([]byte, error)

DerivePasswordKey calculates the key based on password and salt.

func SaltGenerator

func SaltGenerator(length int) ([]byte, error)

SaltGenerator generates a crypto-secure random salt.

func VerifyPassword

func VerifyPassword(password []byte, salt []byte, storedPasswordKey []byte) (bool, error)

VerifyPassword verifies if the password is correct.

Types

type BasicAuth

type BasicAuth struct {
	// contains filtered or unexported fields
}

func NewBasicAuth

func NewBasicAuth(username string, passwordHashHex string, passwordSaltHex string) (*BasicAuth, error)

func (*BasicAuth) VerifyUsernameAndPassword

func (b *BasicAuth) VerifyUsernameAndPassword(username string, password string) bool

func (*BasicAuth) VerifyUsernameAndPasswordBytes

func (b *BasicAuth) VerifyUsernameAndPasswordBytes(username string, passwordBytes []byte) bool

type BasicAuthManager

type BasicAuthManager struct {
	// contains filtered or unexported fields
}

BasicAuthManager is the same as BasicAuth but for multiple users.

func NewBasicAuthManager

func NewBasicAuthManager(usersWithPasswordsHex map[string]string, passwordSaltHex string) (*BasicAuthManager, error)

func (*BasicAuthManager) Exists

func (b *BasicAuthManager) Exists(username string) bool

func (*BasicAuthManager) VerifyUsernameAndPassword

func (b *BasicAuthManager) VerifyUsernameAndPassword(username string, password string) bool

func (*BasicAuthManager) VerifyUsernameAndPasswordBytes

func (b *BasicAuthManager) VerifyUsernameAndPasswordBytes(username string, passwordBytes []byte) bool

Jump to

Keyboard shortcuts

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