database

package
v0.0.0-...-0388672 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultUsername is the first user created in the system if no users exist
	DefaultUsername = "admin"
	// DefaultPassword is the default password for the DefaultUsername
	DefaultPassword = "ch@ng3me!"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	BCryptCost        int
	AllowRegistration bool
}

Config describes all the configuration options for a database backed auth

type DatabaseAuth

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

DatabaseAuth is an authentication backend powered by one of GoCrack's storage implementations

func Init

Init creates the authentication backend

func (*DatabaseAuth) CanUsersRegister

func (s *DatabaseAuth) CanUsersRegister() bool

CanUsersRegister indicates if the GoCrack administrator has allowed new user registration

func (*DatabaseAuth) CreateUser

func (s *DatabaseAuth) CreateUser(user storage.User) error

CreateUser creates a new user in the database

func (*DatabaseAuth) GenerateSecurePassword

func (s *DatabaseAuth) GenerateSecurePassword(password string) (string, error)

GenerateSecurePassword generates a cryptographically secure password string from a plaintext password

func (*DatabaseAuth) Login

func (s *DatabaseAuth) Login(username, password string) (*storage.User, error)

Login searches the database backend for a matching user record

func (*DatabaseAuth) UserCanChangePassword

func (s *DatabaseAuth) UserCanChangePassword() bool

UserCanChangePassword indicates that the user can change their password with this backend

type DatabaseAuthPlugin

type DatabaseAuthPlugin struct{}

DatabaseAuthPlugin implements Open which is used to register the GoCrack database authentication provider with the backend

func (*DatabaseAuthPlugin) Open

Open initializes the GoCrack database Authentication Provider

Jump to

Keyboard shortcuts

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