Documentation ¶
Index ¶
- Variables
- func Register(name string, f func(*yaml.Node, string) (Backend, error))
- type AuthLogContextFunc
- type Backend
- type ReadOnlyTx
- func (*ReadOnlyTx) AddEncryptedAppSpecificPassword(_ *pb.AppSpecificPassword) error
- func (*ReadOnlyTx) AddEncryptedRecoveryToken(_ *pb.RecoveryToken) error
- func (*ReadOnlyTx) AddVerificationToken(_ *pb.VerificationToken) error
- func (*ReadOnlyTx) AddWebAuthnRegistration(_ *pb.WebAuthnRegistration) error
- func (*ReadOnlyTx) Commit() error
- func (*ReadOnlyTx) DeleteAppSpecificPassword(_ *pb.AppSpecificPassword) error
- func (*ReadOnlyTx) DeleteRecoveryToken(_ *pb.RecoveryToken) error
- func (*ReadOnlyTx) DeleteTOTPSecret() error
- func (*ReadOnlyTx) DeleteVerificationToken(_ *pb.VerificationToken) error
- func (*ReadOnlyTx) DeleteWebAuthnRegistration(_ *pb.WebAuthnRegistration) error
- func (*ReadOnlyTx) GetVerificationToken(_ string, _ string) (*pb.VerificationToken, error)
- func (*ReadOnlyTx) Rollback() error
- func (*ReadOnlyTx) SetEncryptedPrimaryPassword(string) error
- func (*ReadOnlyTx) SetTOTPSecret(string) error
- func (*ReadOnlyTx) SetUserInfo(_ *pb.UserInfo) error
- func (*ReadOnlyTx) UpdateAppSpecificPassword(_ *pb.AppSpecificPassword) error
- func (*ReadOnlyTx) UpdateWebAuthnRegistration(_ *pb.WebAuthnRegistration) error
- type Spec
- type Tx
- type UnlockCredentials
- type User
- func (u *User) AddAppSpecificPassword(unlock *UnlockCredentials, password, service, name string) error
- func (u *User) AddRecoveryToken(unlock *UnlockCredentials, tokenType pb.RecoveryToken_Type, id, token string, ...) error
- func (u *User) DisableSecondFactorAuth() error
- func (u *User) SetPrimaryPassword(unlock *UnlockCredentials, password string) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is returned by GetUser when a user is not in the db. ErrNotFound = errors.New("not found") // ErrReadOnly implies that the backend can't be modified. ErrReadOnly = errors.New("read-only backend") )
var PasswordHasher = passwap.NewSwapper( argon2.NewArgon2id(argon2.RecommendedIDParams), )
Default password hasher.
Functions ¶
Types ¶
type Backend ¶
type Backend interface { Close() GetUserByID(context.Context, string) (*User, error) GetUserByName(context.Context, string) (*User, error) }
Backend provides access to the user database with a transactional API. The transaction is always scoped to a specific user, so it is "hidden" in the User object.
func WithAudit ¶
func WithAudit(b Backend, client apb.AuditClient, ctxFn AuthLogContextFunc) Backend
WithAudit wraps a Backend with audit logging of all changes to user data.
type ReadOnlyTx ¶
type ReadOnlyTx struct{}
ReadOnlyTx is an implementation of Tx that always returns ErrReadOnly.
func (*ReadOnlyTx) AddEncryptedAppSpecificPassword ¶
func (*ReadOnlyTx) AddEncryptedAppSpecificPassword(_ *pb.AppSpecificPassword) error
func (*ReadOnlyTx) AddEncryptedRecoveryToken ¶
func (*ReadOnlyTx) AddEncryptedRecoveryToken(_ *pb.RecoveryToken) error
func (*ReadOnlyTx) AddVerificationToken ¶
func (*ReadOnlyTx) AddVerificationToken(_ *pb.VerificationToken) error
func (*ReadOnlyTx) AddWebAuthnRegistration ¶
func (*ReadOnlyTx) AddWebAuthnRegistration(_ *pb.WebAuthnRegistration) error
func (*ReadOnlyTx) Commit ¶
func (*ReadOnlyTx) Commit() error
func (*ReadOnlyTx) DeleteAppSpecificPassword ¶
func (*ReadOnlyTx) DeleteAppSpecificPassword(_ *pb.AppSpecificPassword) error
func (*ReadOnlyTx) DeleteRecoveryToken ¶
func (*ReadOnlyTx) DeleteRecoveryToken(_ *pb.RecoveryToken) error
func (*ReadOnlyTx) DeleteTOTPSecret ¶
func (*ReadOnlyTx) DeleteTOTPSecret() error
func (*ReadOnlyTx) DeleteVerificationToken ¶
func (*ReadOnlyTx) DeleteVerificationToken(_ *pb.VerificationToken) error
func (*ReadOnlyTx) DeleteWebAuthnRegistration ¶
func (*ReadOnlyTx) DeleteWebAuthnRegistration(_ *pb.WebAuthnRegistration) error
func (*ReadOnlyTx) GetVerificationToken ¶
func (*ReadOnlyTx) GetVerificationToken(_ string, _ string) (*pb.VerificationToken, error)
func (*ReadOnlyTx) Rollback ¶
func (*ReadOnlyTx) Rollback() error
func (*ReadOnlyTx) SetEncryptedPrimaryPassword ¶
func (*ReadOnlyTx) SetEncryptedPrimaryPassword(string) error
func (*ReadOnlyTx) SetTOTPSecret ¶
func (*ReadOnlyTx) SetTOTPSecret(string) error
func (*ReadOnlyTx) SetUserInfo ¶
func (*ReadOnlyTx) SetUserInfo(_ *pb.UserInfo) error
func (*ReadOnlyTx) UpdateAppSpecificPassword ¶
func (*ReadOnlyTx) UpdateAppSpecificPassword(_ *pb.AppSpecificPassword) error
func (*ReadOnlyTx) UpdateWebAuthnRegistration ¶
func (*ReadOnlyTx) UpdateWebAuthnRegistration(_ *pb.WebAuthnRegistration) error
type Spec ¶
type Spec struct { Type string `yaml:"type" doc:"backend type"` Params yaml.Node `yaml:"params" doc:"backend-specific configuration"` }
Spec configures a userdb backend. Parameters are type-specific, their parsing deferred to the backend constructors.
type Tx ¶
type Tx interface { Commit() error Rollback() error SetEncryptedPrimaryPassword(string) error SetTOTPSecret(string) error DeleteTOTPSecret() error AddEncryptedRecoveryToken(*pb.RecoveryToken) error DeleteRecoveryToken(*pb.RecoveryToken) error AddEncryptedAppSpecificPassword(*pb.AppSpecificPassword) error UpdateAppSpecificPassword(*pb.AppSpecificPassword) error DeleteAppSpecificPassword(*pb.AppSpecificPassword) error AddWebAuthnRegistration(*pb.WebAuthnRegistration) error UpdateWebAuthnRegistration(*pb.WebAuthnRegistration) error DeleteWebAuthnRegistration(*pb.WebAuthnRegistration) error SetUserInfo(*pb.UserInfo) error GetVerificationToken(string, string) (*pb.VerificationToken, error) AddVerificationToken(*pb.VerificationToken) error DeleteVerificationToken(*pb.VerificationToken) error }
Tx is the transactional write API to the user database. Note that after calling these methods, the outer User object will not be updated to reflect the changes. The Tx object embeds the user identity.
This interface only accepts encrypted credentials (the various AddEncrypted* methods). The User type wraps this with an API that accepts cleartext secrets and encrypts them, with matching methods lacking the 'Encrypted' part.
FIXME: this is a Context-wrapping API (mostly due to the semantics of the underlying database/sql.Tx) and this is bad.
type UnlockCredentials ¶
type UnlockCredentials struct { AuthID *pb.AuthenticatorID Password string }
UnlockCredentials are used whenever we need to encrypt new credentials, in order for the API to eventually support password-derived encryption keys with transparent re-keying.
type User ¶
User object. Fields are conceptually read-only: manipulation is delegated to the underlying Tx interface. There are specific methods for credential manipulation, to ensure that the user invariants are preserved: like the ability to decrypt the user encryption key when changing passwords, etc.
func (*User) AddAppSpecificPassword ¶
func (u *User) AddAppSpecificPassword(unlock *UnlockCredentials, password, service, name string) error
AddAppSpecificPassword overrides the low-level method to manage encryption keys.
func (*User) AddRecoveryToken ¶
func (u *User) AddRecoveryToken(unlock *UnlockCredentials, tokenType pb.RecoveryToken_Type, id, token string, expiry time.Time) error
AddRecoveryToken overrides the low-level method to manage encryption keys.
func (*User) SetPrimaryPassword ¶
func (u *User) SetPrimaryPassword(unlock *UnlockCredentials, password string) error