Documentation ¶
Index ¶
- Constants
- Variables
- type ActivateTOTPGuard
- type ActivateUsersGuard
- type Activated
- type AlreadySignedUp
- type ChangePasswordGuard
- type ChangeRolesGuard
- type ChangeTOTPTelGuard
- type ChoosePasswordGuard
- type CreateRoleGuard
- type DeleteRoleGuard
- type DisableTOTPGuard
- type Email
- type GoogleSignInBehaviour
- type Hasher
- type InviteUserGuard
- type Invited
- type Password
- type PasswordChanged
- type PasswordChosen
- type PasswordReset
- type Permission
- type ReadWriter
- type Reader
- type RecoveryCode
- type RecoveryCodesRegenerated
- type RegenerateRecoveryCodesGuard
- type ResetPasswordGuard
- type ResetTOTPGuard
- type Role
- type RoleDesc
- type RoleFilter
- type RoleName
- type RolesChanged
- type Service
- func (s *Service) ActivateTOTP(ctx context.Context, guard ActivateTOTPGuard, userID int) error
- func (s *Service) ActivateUser(ctx context.Context, guard ActivateUsersGuard, userID int) error
- func (s *Service) ApproveTOTPResetRequest(ctx context.Context, userID int) error
- func (s *Service) ChangePassword(ctx context.Context, guard ChangePasswordGuard, userID int, ...) error
- func (s *Service) ChangeRoles(ctx context.Context, guard ChangeRolesGuard, userID int, roleIDs []int, ...) error
- func (s *Service) ChangeTOTPTel(ctx context.Context, guard ChangeTOTPTelGuard, userID int, newTel string) error
- func (s *Service) CheckSignInThrottle(attempts int, lastAttemptAt time.Time) error
- func (s *Service) ChoosePassword(ctx context.Context, guard ChoosePasswordGuard, userID int, ...) error
- func (s *Service) CreateRole(ctx context.Context, guard CreateRoleGuard, name, description string, ...) (*Role, error)
- func (s *Service) DeleteRole(ctx context.Context, guard DeleteRoleGuard, roleID int) (*Role, error)
- func (s *Service) DenyTOTPResetRequest(ctx context.Context, userID int) error
- func (s *Service) DisableTOTP(ctx context.Context, guard DisableTOTPGuard, userID int, password string) error
- func (s *Service) InviteUser(ctx context.Context, guard InviteUserGuard, email string) (*User, error)
- func (s *Service) RegenerateRecoveryCodes(ctx context.Context, guard RegenerateRecoveryCodesGuard, userID int, ...) ([]string, error)
- func (s *Service) RequestTOTPReset(ctx context.Context, email string) error
- func (s *Service) ResetPassword(ctx context.Context, guard ResetPasswordGuard, userID int, ...) error
- func (s *Service) ResetTOTP(ctx context.Context, guard ResetTOTPGuard, userID int, password string) error
- func (s *Service) SetupTOTP(ctx context.Context, guard SetupTOTPGuard, userID int) error
- func (s *Service) SignInWithGoogle(ctx context.Context, email string, behaviour GoogleSignInBehaviour) (bool, error)
- func (s *Service) SignInWithPassword(ctx context.Context, email, password string) error
- func (s *Service) SignInWithRecoveryCode(ctx context.Context, userID int, recoveryCode string) error
- func (s *Service) SignInWithTOTP(ctx context.Context, userID int, totp string) error
- func (s *Service) SignUp(ctx context.Context, email string) (*User, error)
- func (s *Service) UpdateRole(ctx context.Context, guard UpdateRoleGuard, roleID int, ...) (*Role, error)
- func (s *Service) VerifyTOTP(ctx context.Context, guard VerifyTOTPGuard, userID int, ...) ([]string, error)
- func (s *Service) VerifyUser(ctx context.Context, email, password, passwordCheck string, ...) error
- type SetupTOTPGuard
- type SignInAttemptLog
- type SignInThrottleError
- type SignedInWithGoogle
- type SignedInWithPassword
- type SignedInWithRecoveryCode
- type SignedInWithTOTP
- type SignedUp
- type SignedUpWithGoogle
- type TOTP
- type TOTPDisabled
- type TOTPKey
- type TOTPMethod
- type TOTPReset
- type TOTPResetRequestApproved
- type TOTPResetRequestDenied
- type TOTPResetRequested
- type TOTPTelChanged
- type Tel
- type UpdateRoleGuard
- type User
- func (u *User) Activate() error
- func (u *User) ActivateTOTP() error
- func (u *User) ApproveTOTPResetRequest() error
- func (u *User) ChangePassword(oldPassword, newPassword Password, hasher Hasher) error
- func (u *User) ChangeRoles(roles []*Role, grants, denials []Permission) error
- func (u *User) ChangeTOTPTel(newTel Tel) error
- func (u *User) ChoosePassword(newPassword Password, hasher Hasher) error
- func (u *User) DenyTOTPResetRequest() error
- func (u *User) DisableTOTP(password Password, hasher Hasher) error
- func (u *User) GenerateTOTP() (string, error)
- func (u *User) HasActivatedTOTP() bool
- func (u *User) HasVerifiedTOTP() bool
- func (u *User) InviteUser() error
- func (u *User) IsSuper() bool
- func (u *User) Permissions() []string
- func (u *User) RegenerateRecoveryCodes(totp TOTP) ([]string, error)
- func (u *User) RequestTOTPReset() error
- func (u *User) ResetPassword(newPassword Password, hasher Hasher) error
- func (u *User) ResetTOTP(password Password, hasher Hasher) error
- func (u *User) SetupTOTP() error
- func (u *User) SignInWithGoogle() error
- func (u *User) SignInWithPassword(password Password, hasher Hasher) (rehashed bool, _ error)
- func (u *User) SignInWithRecoveryCode(code RecoveryCode) error
- func (u *User) SignInWithTOTP(totp TOTP) error
- func (u *User) SignUp() error
- func (u *User) SignUpWithGoogle() error
- func (u *User) Verify(password Password, hasher Hasher) error
- func (u *User) VerifyTOTP(totp TOTP, method TOTPMethod) ([]string, error)
- type UserFilter
- type Verified
- type VerifyTOTPGuard
- type VerifyUserBehaviour
- type Writer
Constants ¶
View Source
const ( MaxFreeSignInAttempts = 3 MaxSignInThrottleDelay = app.SignInThrottleTTL / 2 )
View Source
const ( SignInMethodNone = "" SignInMethodWebform = "Webform" SignInMethodGoogle = "Google" )
Variables ¶
View Source
var ( ErrNotVerified = errors.New("account is not verified") ErrNotActivated = errors.New("account is not activated") ErrInvalidPassword = errors.New("invalid password") )
View Source
var ErrGoogleSignUpDisabled = errors.New("Google sign up disabled")
View Source
var ErrSignInThrottled = errors.New("sign in throttled")
Functions ¶
This section is empty.
Types ¶
type ActivateTOTPGuard ¶
type ActivateUsersGuard ¶
type ActivateUsersGuard interface {
CanActivateUsers() bool
}
type AlreadySignedUp ¶
type AlreadySignedUp struct {
Email string
}
type ChangePasswordGuard ¶
type ChangeRolesGuard ¶
type ChangeTOTPTelGuard ¶
type ChoosePasswordGuard ¶
type CreateRoleGuard ¶
type CreateRoleGuard interface {
CanCreateRoles() bool
}
type DeleteRoleGuard ¶
type DeleteRoleGuard interface {
CanDeleteRoles() bool
}
type DisableTOTPGuard ¶
type GoogleSignInBehaviour ¶
type GoogleSignInBehaviour byte
const ( GoogleSignInOnly GoogleSignInBehaviour = iota GoogleAllowSignUp GoogleAllowSignUpActivate )
type InviteUserGuard ¶
type InviteUserGuard interface {
CanInviteUsers() bool
}
type Password ¶
type Password struct {
// contains filtered or unexported fields
}
func NewPassword ¶
type PasswordChanged ¶
type PasswordChanged struct {
Email string
}
type PasswordChosen ¶
type PasswordChosen struct {
Email string
}
type PasswordReset ¶
type PasswordReset struct {
Email string
}
type Permission ¶
type Permission string
func NewPermission ¶
func NewPermission(name string) (Permission, error)
func (Permission) String ¶
func (n Permission) String() string
type ReadWriter ¶
type Reader ¶
type Reader interface { FindRoleByID(ctx context.Context, id int) (*Role, error) FindRoleByName(ctx context.Context, name string) (*Role, error) CountUsersByRoleID(ctx context.Context, roleID int) (int, error) FindUserByID(ctx context.Context, id int) (*User, error) FindUserByEmail(ctx context.Context, email string) (*User, error) FindSignInAttemptLogByEmail(ctx context.Context, email string) (*SignInAttemptLog, error) }
type RecoveryCode ¶
type RecoveryCode string
func NewRandomRecoveryCode ¶
func NewRandomRecoveryCode() (RecoveryCode, error)
func NewRecoveryCode ¶
func NewRecoveryCode(code string) (RecoveryCode, error)
func (RecoveryCode) EqualHash ¶
func (c RecoveryCode) EqualHash(rhs []byte) bool
func (RecoveryCode) String ¶
func (c RecoveryCode) String() string
type RecoveryCodesRegenerated ¶
type RecoveryCodesRegenerated struct {
Email string
}
type ResetPasswordGuard ¶
type ResetTOTPGuard ¶
type RoleFilter ¶
type RolesChanged ¶
type RolesChanged struct {
Email string
}
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func (*Service) ActivateTOTP ¶
func (*Service) ActivateUser ¶
func (*Service) ApproveTOTPResetRequest ¶
func (*Service) ChangePassword ¶
func (*Service) ChangeRoles ¶
func (*Service) ChangeTOTPTel ¶
func (*Service) CheckSignInThrottle ¶
func (*Service) ChoosePassword ¶
func (*Service) CreateRole ¶
func (*Service) DeleteRole ¶
func (*Service) DenyTOTPResetRequest ¶
func (*Service) DisableTOTP ¶
func (*Service) InviteUser ¶
func (*Service) RegenerateRecoveryCodes ¶
func (*Service) RequestTOTPReset ¶
func (*Service) ResetPassword ¶
func (*Service) SignInWithGoogle ¶
func (*Service) SignInWithPassword ¶
func (*Service) SignInWithRecoveryCode ¶
func (*Service) SignInWithTOTP ¶
func (*Service) UpdateRole ¶
func (*Service) VerifyTOTP ¶
func (*Service) VerifyUser ¶
type SetupTOTPGuard ¶
type SignInAttemptLog ¶
type SignInThrottleError ¶
type SignInThrottleError struct { InLast string Delay time.Duration UnlockAt time.Time UnlockIn string }
func (SignInThrottleError) Error ¶
func (t SignInThrottleError) Error() string
type SignedInWithGoogle ¶
type SignedInWithGoogle struct {
Email string
}
type SignedInWithPassword ¶
type SignedInWithPassword struct {
Email string
}
type SignedInWithRecoveryCode ¶
type SignedInWithRecoveryCode struct {
Email string
}
type SignedInWithTOTP ¶
type SignedInWithTOTP struct {
Email string
}
type SignedUpWithGoogle ¶
type SignedUpWithGoogle struct {
Email string
}
type TOTPDisabled ¶
type TOTPDisabled struct {
Email string
}
type TOTPMethod ¶
type TOTPMethod string
const ( TOTPMethodNone TOTPMethod = "" TOTPMethodApp TOTPMethod = "app" TOTPMethodSMS TOTPMethod = "sms" )
func NewTOTPMethod ¶
func NewTOTPMethod(method string) (TOTPMethod, error)
func (TOTPMethod) String ¶
func (t TOTPMethod) String() string
type TOTPResetRequestApproved ¶
type TOTPResetRequestApproved struct {
Email string
}
type TOTPResetRequestDenied ¶
type TOTPResetRequestDenied struct {
Email string
}
type TOTPResetRequested ¶
type TOTPResetRequested struct {
Email string
}
type TOTPTelChanged ¶
type UpdateRoleGuard ¶
type UpdateRoleGuard interface {
CanUpdateRoles() bool
}
type User ¶
type User struct { aggregate.Root ID int Email string HashedPassword []byte TOTPMethod string TOTPTel string TOTPKey []byte TOTPAlgorithm string TOTPDigits int TOTPPeriod time.Duration TOTPVerifiedAt time.Time TOTPActivatedAt time.Time TOTPResetRequestedAt time.Time TOTPResetApprovedAt time.Time InvitedAt time.Time SignedUpAt time.Time VerifiedAt time.Time ActivatedAt time.Time LastSignedInAt time.Time LastSignedInMethod string HashedRecoveryCodes [][]byte Roles []*Role Grants []string Denials []string }
func (*User) ActivateTOTP ¶
func (*User) ApproveTOTPResetRequest ¶
func (*User) ChangePassword ¶
func (*User) ChangeRoles ¶
func (u *User) ChangeRoles(roles []*Role, grants, denials []Permission) error
func (*User) ChangeTOTPTel ¶
func (*User) ChoosePassword ¶
func (*User) DenyTOTPResetRequest ¶
func (*User) GenerateTOTP ¶
func (*User) HasActivatedTOTP ¶
func (*User) HasVerifiedTOTP ¶
func (*User) InviteUser ¶
func (*User) Permissions ¶
func (*User) RegenerateRecoveryCodes ¶
func (*User) RequestTOTPReset ¶
func (*User) ResetPassword ¶
func (*User) SignInWithGoogle ¶
func (*User) SignInWithPassword ¶
func (*User) SignInWithRecoveryCode ¶
func (u *User) SignInWithRecoveryCode(code RecoveryCode) error
func (*User) SignInWithTOTP ¶
func (*User) SignUpWithGoogle ¶
func (*User) VerifyTOTP ¶
func (u *User) VerifyTOTP(totp TOTP, method TOTPMethod) ([]string, error)
type UserFilter ¶
type VerifyTOTPGuard ¶
type VerifyUserBehaviour ¶
type VerifyUserBehaviour byte
const ( VerifyUserOnly VerifyUserBehaviour = iota VerifyUserActivate )
type Writer ¶
type Writer interface { AddRole(ctx context.Context, role *Role) error SaveRole(ctx context.Context, role *Role) error RemoveRole(ctx context.Context, roleID int) error AddUser(ctx context.Context, user *User) error SaveUser(ctx context.Context, user *User) error SaveSignInAttemptLog(ctx context.Context, log *SignInAttemptLog) error }
Source Files ¶
- cmd_activate_totp.go
- cmd_activate_user.go
- cmd_approve_totp_reset_request.go
- cmd_change_password.go
- cmd_change_roles.go
- cmd_change_totp_telephone.go
- cmd_choose_password.go
- cmd_create_role.go
- cmd_delete_role.go
- cmd_deny_totp_reset_request.go
- cmd_disable_totp.go
- cmd_edit_role.go
- cmd_invite_user.go
- cmd_regen_recovery_codes.go
- cmd_request_totp_reset.go
- cmd_reset_password.go
- cmd_reset_totp.go
- cmd_setup_totp.go
- cmd_sign_in_google.go
- cmd_sign_in_password.go
- cmd_sign_in_recovery_code.go
- cmd_sign_in_totp.go
- cmd_sign_up.go
- cmd_verify_totp.go
- cmd_verify_user.go
- ent_role.go
- ent_sign_in_attempt_log.go
- ent_user.go
- events.go
- service.go
- val_email.go
- val_password.go
- val_permission.go
- val_recovery_code.go
- val_role_desc.go
- val_role_name.go
- val_tel.go
- val_totp.go
- val_totp_key.go
- val_totp_method.go
Click to show internal directories.
Click to hide internal directories.