Documentation ¶
Index ¶
- Variables
- type Dispatcher
- type LoginStorer
- type Service
- func (g *Service) ChangeEmail(ctx context.Context, id uuid.UUID, email string) error
- func (g *Service) ChangePassword(ctx context.Context, id uuid.UUID, password string) error
- func (g *Service) ConfirmUser(ctx context.Context, token string) error
- func (g *Service) DisableMFA(ctx context.Context, userID uuid.UUID) error
- func (g *Service) EmailToID(ctx context.Context, email string) (uuid.UUID, bool)
- func (g *Service) EnableMFA(ctx context.Context, userID uuid.UUID, secret string) (string, error)
- func (g *Service) InRole(ctx context.Context, id uuid.UUID, role string) bool
- func (g *Service) InviteUser(ctx context.Context, email string) error
- func (g *Service) IsMFAEnabled(ctx context.Context, userID uuid.UUID) bool
- func (g *Service) ProvisionMFA(ctx context.Context, userID uuid.UUID) (string, string, error)
- func (g *Service) RecoverPassword(ctx context.Context, email string, token string) (uuid.UUID, error)
- func (g *Service) RegisterFromInvite(ctx context.Context, email string, password string, phone *string, ...) (uuid.UUID, error)
- func (g *Service) RegisterUser(ctx context.Context, email string, password string, phone *string) (uuid.UUID, error)
- func (g *Service) TriggerPasswordRecovery(ctx context.Context, id uuid.UUID) error
- type SignedInUser
- type SigninService
- func (g *SigninService) CanLogin(ctx context.Context, userID uuid.UUID) (bool, error)
- func (g *SigninService) InitializeMFA(ctx context.Context, email string) error
- func (g *SigninService) SignIn(ctx context.Context, email string, password string) (*SignedInUser, error)
- func (g *SigninService) SignInByIDFromToken(ctx context.Context, userID uuid.UUID, tokenType string) (*SignedInUser, error)
- func (g *SigninService) SignInMFA(ctx context.Context, email string, password string, otp string) (*SignedInUser, error)
- func (g *SigninService) UserFromSubject(ctx context.Context, userID uuid.UUID) (*SignedInUser, error)
- func (g *SigninService) Validate(ctx context.Context, id uuid.UUID, password string) error
- type UserLocker
Constants ¶
This section is empty.
Variables ¶
var ( ErrInviteOnly = errors.New( "behaivoural setting is set to only accept invited members", ) ErrTokenGenTimeout = errors.New("could not generate a token within given cycles") ErrEntityAlreadyExists = errors.New("entity already exists in system") ErrTokenExpired = errors.New("supplied token has expired") ErrEntityInvalidTransition = errors.New("entity does not support transition") ErrPasswordGuidelines = errors.New("password doesnt match password guidlines") )
var ( ErrEntityDoesNotExist = errors.New("entity does not exist") ErrEntityOperationForbidden = errors.New("entity does not support operation") ErrInvalidCredentials = errors.New("invalid credentials") ErrMFARequired = errors.New("entity requires mfa") ErrInvalidOTP = errors.New( "supplied one time password was not correct or already consumed", ) )
Functions ¶
This section is empty.
Types ¶
type Dispatcher ¶
type LoginStorer ¶
type LoginStorer interface { }
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func New ¶
func New(store *db.DataStore, logger *zap.Logger, cfg *config.Configuration, mailer *mailing.Mailer, dispatcher Dispatcher, manager *manage.UserService) *Service
func (*Service) ChangeEmail ¶
ChangeEmail changes the users email address, this will not trigger a reconfirm, be vary of that
func (*Service) ChangePassword ¶
ChangePassword sets a new password for the supplied user id
func (*Service) ConfirmUser ¶
ConfirmUser confirms a user account with the supplied token
func (*Service) DisableMFA ¶
DisableMFA disables multi factor for a user IF the user has multifactor enabled
func (*Service) EnableMFA ¶
EnableMFA enables multi factor auth for a user, this should only be called after ProvisionMFA it returns a recovery code which the user should note in case of device loss to still access his account
func (*Service) InviteUser ¶
InviteUser is a user initiaized invite without roles and apps
func (*Service) IsMFAEnabled ¶
IsMFAEnabled check if user has mfa enabled
func (*Service) ProvisionMFA ¶
ProvisionMFA returns a new secret and a otpauth:// url if success
func (*Service) RecoverPassword ¶
func (g *Service) RecoverPassword( ctx context.Context, email string, token string, ) (uuid.UUID, error)
RecoverPassword is used to reset the password from the token obtained from the recovery mail
func (*Service) RegisterFromInvite ¶
func (g *Service) RegisterFromInvite( ctx context.Context, email string, password string, phone *string, inviteCode string, ) (uuid.UUID, error)
RegisterFromInvite registers a user from an invite, which means the user will automatically be granted roles and application permissions from the invite
type SigninService ¶
type SigninService struct {
// contains filtered or unexported fields
}
func NewSignInService ¶
func NewSignInService(store *db.DataStore, log *zap.Logger, cfg *config.BehaviourConfiguration, dispatcher Dispatcher, userLocker UserLocker) *SigninService
func (*SigninService) CanLogin ¶
CanLogin checks if a user is eligble to login (not lockedout, not banned, not unconfirmed)
func (*SigninService) InitializeMFA ¶
func (g *SigninService) InitializeMFA(ctx context.Context, email string) error
InitializeMFA marks a otp as pending
func (*SigninService) SignIn ¶
func (g *SigninService) SignIn( ctx context.Context, email string, password string, ) (*SignedInUser, error)
SignIn signs in a user with the supplied credentials
func (*SigninService) SignInByIDFromToken ¶
func (g *SigninService) SignInByIDFromToken( ctx context.Context, userID uuid.UUID, tokenType string, ) (*SignedInUser, error)
SignInByIDFromToken creates a signed in user after the supplied token type has been validated - do not use this without validating the token before!
func (*SigninService) SignInMFA ¶
func (g *SigninService) SignInMFA( ctx context.Context, email string, password string, otp string, ) (*SignedInUser, error)
SignInMFA signs in the user with the credentials and the OTP
func (*SigninService) UserFromSubject ¶
func (g *SigninService) UserFromSubject( ctx context.Context, userID uuid.UUID, ) (*SignedInUser, error)
UserFromSubject returns a user by id, this should be only used in special cases