Documentation ¶
Overview ¶
Package basic implements a simple auth provider and backend that identifies a user via username & password combination.
Index ¶
- func ValidateBasicAuth(ctx context.Context) error
- type Config
- type HashedPassword
- type Provider
- type Store
- func (b *Store) CreateTx(ctx context.Context, tx *sql.Tx, userID, username string, ...) error
- func (b *Store) NewHashedPassword(ctx context.Context, password string) (HashedPassword, error)
- func (b *Store) UpdateTx(ctx context.Context, tx *sql.Tx, userID string, oldPass ValidatedPassword, ...) error
- func (b *Store) Validate(ctx context.Context, username, password string) (string, error)
- func (b *Store) ValidatePassword(ctx context.Context, password string) (ValidatedPassword, error)
- type ValidatedPassword
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateBasicAuth ¶ added in v0.31.0
ValidateBasicAuth returns an access denied error for non-admins when basic auth is disabled in configs.
Types ¶
type HashedPassword ¶ added in v0.31.0
type HashedPassword interface { Hash() string // contains filtered or unexported methods }
HashedPassword is an interface that can be used to store a password.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider implements the auth.IdentityProvider interface.
func NewProvider ¶
NewProvider creates a new Provider with the associated config.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store can create new user/pass links and validate a username and password. bcrypt is used for password storage & verification.
func NewStore ¶
NewStore creates a new DB. Error is returned if the prepared statements fail to register.
func (*Store) CreateTx ¶
func (b *Store) CreateTx(ctx context.Context, tx *sql.Tx, userID, username string, password HashedPassword) error
CreateTx should add a new entry for the username/password combination linking to userID. An error is returned if the username is not unique or the userID is invalid. Must have same user or admin role.
func (*Store) NewHashedPassword ¶ added in v0.31.0
NewHashedPassword will hash the given password and return a Password object.
func (*Store) UpdateTx ¶ added in v0.31.0
func (b *Store) UpdateTx(ctx context.Context, tx *sql.Tx, userID string, oldPass ValidatedPassword, newPass HashedPassword) error
UpdateTx updates a user's password. oldPass is required if the current context is not an admin.
func (*Store) ValidatePassword ¶ added in v0.31.0
ValidatePassword will validate the password of the currently authenticated user.
type ValidatedPassword ¶ added in v0.31.0
type ValidatedPassword interface { UserID() string // contains filtered or unexported methods }
ValidatedPassword represents a validated password for a UserID.