Documentation ¶
Index ¶
- Constants
- Variables
- type Manager
- func (m *Manager) ApproveSession(ctx context.Context, sessionID, passcode string) error
- func (m *Manager) CheckAvailability(ctx context.Context, resourceKind, value string) (bool, error)
- func (m *Manager) CheckCredentials(ctx context.Context, email, password string) (*hub.CheckCredentialsOutput, error)
- func (m *Manager) CheckSession(ctx context.Context, sessionID string, duration time.Duration) (*hub.CheckSessionOutput, error)
- func (m *Manager) DeleteSession(ctx context.Context, sessionID string) error
- func (m *Manager) DeleteUser(ctx context.Context, code string) error
- func (m *Manager) DisableTFA(ctx context.Context, passcode string) error
- func (m *Manager) EnableTFA(ctx context.Context, passcode string) error
- func (m *Manager) GetProfile(ctx context.Context) (*hub.User, error)
- func (m *Manager) GetProfileJSON(ctx context.Context) ([]byte, error)
- func (m *Manager) GetUserID(ctx context.Context, email string) (string, error)
- func (m *Manager) RegisterDeleteUserCode(ctx context.Context) error
- func (m *Manager) RegisterPasswordResetCode(ctx context.Context, userEmail string) error
- func (m *Manager) RegisterSession(ctx context.Context, session *hub.Session) (*hub.Session, error)
- func (m *Manager) RegisterUser(ctx context.Context, user *hub.User) error
- func (m *Manager) ResetPassword(ctx context.Context, code, newPassword string) error
- func (m *Manager) SetupTFA(ctx context.Context) ([]byte, error)
- func (m *Manager) UpdatePassword(ctx context.Context, old, new string) error
- func (m *Manager) UpdateProfile(ctx context.Context, user *hub.User) error
- func (m *Manager) VerifyEmail(ctx context.Context, code string) (bool, error)
- func (m *Manager) VerifyPasswordResetCode(ctx context.Context, code string) error
- type ManagerMock
- func (m *ManagerMock) ApproveSession(ctx context.Context, sessionID, passcode string) error
- func (m *ManagerMock) CheckAvailability(ctx context.Context, resourceKind, value string) (bool, error)
- func (m *ManagerMock) CheckCredentials(ctx context.Context, email, password string) (*hub.CheckCredentialsOutput, error)
- func (m *ManagerMock) CheckSession(ctx context.Context, sessionID string, duration time.Duration) (*hub.CheckSessionOutput, error)
- func (m *ManagerMock) DeleteSession(ctx context.Context, sessionID string) error
- func (m *ManagerMock) DeleteUser(ctx context.Context, code string) error
- func (m *ManagerMock) DisableTFA(ctx context.Context, passcode string) error
- func (m *ManagerMock) EnableTFA(ctx context.Context, passcode string) error
- func (m *ManagerMock) GetProfile(ctx context.Context) (*hub.User, error)
- func (m *ManagerMock) GetProfileJSON(ctx context.Context) ([]byte, error)
- func (m *ManagerMock) GetUserID(ctx context.Context, email string) (string, error)
- func (m *ManagerMock) RegisterDeleteUserCode(ctx context.Context) error
- func (m *ManagerMock) RegisterPasswordResetCode(ctx context.Context, userEmail string) error
- func (m *ManagerMock) RegisterSession(ctx context.Context, session *hub.Session) (*hub.Session, error)
- func (m *ManagerMock) RegisterUser(ctx context.Context, user *hub.User) error
- func (m *ManagerMock) ResetPassword(ctx context.Context, code, newPassword string) error
- func (m *ManagerMock) SetupTFA(ctx context.Context) ([]byte, error)
- func (m *ManagerMock) UpdatePassword(ctx context.Context, old, new string) error
- func (m *ManagerMock) UpdateProfile(ctx context.Context, user *hub.User) error
- func (m *ManagerMock) VerifyEmail(ctx context.Context, code string) (bool, error)
- func (m *ManagerMock) VerifyPasswordResetCode(ctx context.Context, code string) error
Constants ¶
const ( // PasswordMinEntropyBits represents the minimum amount of entropy bits // required for a password. PasswordMinEntropyBits = 50 )
Variables ¶
var ( // ErrInvalidDeleteUserCode indicates that the delete user code provided is // not valid. ErrInvalidDeleteUserCode = errors.New("invalid delete user code") // ErrInvalidPassword indicates that the password provided is not valid. ErrInvalidPassword = errors.New("invalid password") // ErrInvalidPasswordResetCode indicates that the password reset code // provided is not valid. ErrInvalidPasswordResetCode = errors.New("invalid password reset code") // ErrNotFound indicates that the user does not exist. ErrNotFound = errors.New("user not found") )
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager provides an API to manage users.
func NewManager ¶
NewManager creates a new Manager instance.
func (*Manager) ApproveSession ¶ added in v0.20.0
ApproveSession approves a given session using the TFA passcode provided.
func (*Manager) CheckAvailability ¶
CheckAvailability checks the availability of a given value for the provided resource kind.
func (*Manager) CheckCredentials ¶
func (m *Manager) CheckCredentials( ctx context.Context, email, password string, ) (*hub.CheckCredentialsOutput, error)
CheckCredentials checks if the credentials provided are valid.
func (*Manager) CheckSession ¶
func (m *Manager) CheckSession( ctx context.Context, sessionID string, duration time.Duration, ) (*hub.CheckSessionOutput, error)
CheckSession checks if the user session provided is valid.
func (*Manager) DeleteSession ¶
DeleteSession deletes a user session from the database.
func (*Manager) DeleteUser ¶ added in v1.1.0
DeleteUser deletes a user account from the database. The confirmation code received by the user via email is expected to be provided.
func (*Manager) DisableTFA ¶ added in v0.20.0
DisableTFA disables two-factor authentication for the requesting user.
func (*Manager) EnableTFA ¶ added in v0.20.0
EnableTFA enables two-factor authentication for the requesting user. The user must have set it up first (see SetupTFA method).
func (*Manager) GetProfile ¶ added in v0.6.0
GetProfile returns the profile of the user doing the request.
func (*Manager) GetProfileJSON ¶
GetProfileJSON returns the profile of the user doing the request as a json object.
func (*Manager) RegisterDeleteUserCode ¶ added in v1.1.0
RegisterDeleteUserCode registers a code that allows the user doing the request to initiate the process to delete his account. A link containing the code will be emailed to the user.
func (*Manager) RegisterPasswordResetCode ¶ added in v0.16.0
RegisterPasswordResetCode registers a code that allows the user identified by the email provided to reset the password. A link containing the code will be emailed to the user to initiate the password reset process.
func (*Manager) RegisterSession ¶
RegisterSession registers a user session in the database.
func (*Manager) RegisterUser ¶
RegisterUser registers the user provided in the database. When the user is registered a verification email will be sent to the email address provided. The base url provided will be used to build the url the user will need to click to complete the verification. When a user is registered using oauth, the email is verified automatically and no email is sent.
func (*Manager) ResetPassword ¶ added in v0.16.0
ResetPassword resets the user password in the database.
func (*Manager) SetupTFA ¶ added in v0.20.0
SetupTFA sets up two-factor authentication for the requesting user. This generates a new TOTP key and some recovery codes for the user and stores them in the database. To complete the process, the user must enable TFA (see EnableTFA method).
func (*Manager) UpdatePassword ¶
UpdatePassword updates the user password in the database.
func (*Manager) UpdateProfile ¶
UpdateProfile updates the user profile in the database.
func (*Manager) VerifyEmail ¶
VerifyEmail verifies a user's email using the email verification code provided.
type ManagerMock ¶
ManagerMock is a mock implementation of the UserManager interface.
func (*ManagerMock) ApproveSession ¶ added in v0.20.0
func (m *ManagerMock) ApproveSession(ctx context.Context, sessionID, passcode string) error
ApproveSession implements the UserManager interface.
func (*ManagerMock) CheckAvailability ¶
func (m *ManagerMock) CheckAvailability(ctx context.Context, resourceKind, value string) (bool, error)
CheckAvailability implements the UserManager interface.
func (*ManagerMock) CheckCredentials ¶
func (m *ManagerMock) CheckCredentials( ctx context.Context, email, password string, ) (*hub.CheckCredentialsOutput, error)
CheckCredentials implements the UserManager interface.
func (*ManagerMock) CheckSession ¶
func (m *ManagerMock) CheckSession( ctx context.Context, sessionID string, duration time.Duration, ) (*hub.CheckSessionOutput, error)
CheckSession implements the UserManager interface.
func (*ManagerMock) DeleteSession ¶
func (m *ManagerMock) DeleteSession(ctx context.Context, sessionID string) error
DeleteSession implements the UserManager interface.
func (*ManagerMock) DeleteUser ¶ added in v1.1.0
func (m *ManagerMock) DeleteUser(ctx context.Context, code string) error
DeleteUser implements the UserManager interface.
func (*ManagerMock) DisableTFA ¶ added in v0.20.0
func (m *ManagerMock) DisableTFA(ctx context.Context, passcode string) error
DisableTFA implements the UserManager interface.
func (*ManagerMock) EnableTFA ¶ added in v0.20.0
func (m *ManagerMock) EnableTFA(ctx context.Context, passcode string) error
EnableTFA implements the UserManager interface.
func (*ManagerMock) GetProfile ¶ added in v0.6.0
GetProfile implements the UserManager interface.
func (*ManagerMock) GetProfileJSON ¶
func (m *ManagerMock) GetProfileJSON(ctx context.Context) ([]byte, error)
GetProfileJSON implements the UserManager interface.
func (*ManagerMock) RegisterDeleteUserCode ¶ added in v1.1.0
func (m *ManagerMock) RegisterDeleteUserCode(ctx context.Context) error
RegisterDeleteUserCode implements the UserManager interface.
func (*ManagerMock) RegisterPasswordResetCode ¶ added in v0.16.0
func (m *ManagerMock) RegisterPasswordResetCode(ctx context.Context, userEmail string) error
RegisterPasswordResetCode implements the UserManager interface.
func (*ManagerMock) RegisterSession ¶
func (m *ManagerMock) RegisterSession(ctx context.Context, session *hub.Session) (*hub.Session, error)
RegisterSession implements the UserManager interface.
func (*ManagerMock) RegisterUser ¶
RegisterUser implements the UserManager interface.
func (*ManagerMock) ResetPassword ¶ added in v0.16.0
func (m *ManagerMock) ResetPassword(ctx context.Context, code, newPassword string) error
ResetPassword implements the UserManager interface.
func (*ManagerMock) SetupTFA ¶ added in v0.20.0
func (m *ManagerMock) SetupTFA(ctx context.Context) ([]byte, error)
SetupTFA implements the UserManager interface.
func (*ManagerMock) UpdatePassword ¶
func (m *ManagerMock) UpdatePassword(ctx context.Context, old, new string) error
UpdatePassword implements the UserManager interface.
func (*ManagerMock) UpdateProfile ¶
UpdateProfile implements the UserManager interface.
func (*ManagerMock) VerifyEmail ¶
VerifyEmail implements the UserManager interface.
func (*ManagerMock) VerifyPasswordResetCode ¶ added in v0.16.0
func (m *ManagerMock) VerifyPasswordResetCode(ctx context.Context, code string) error
VerifyPasswordResetCode implements the UserManager interface.