Documentation ¶
Index ¶
- Variables
- type AuthenticatorService
- type CodeChannel
- type CodeKind
- type CodeOptions
- type IdentityService
- type Logger
- type OTPCodeService
- type OTPSender
- type Service
- func (s *Service) CodeLength(target string, channel CodeChannel, kind CodeKind) int
- func (s *Service) InspectState(target string, channel CodeChannel, kind CodeKind) (*otp.State, error)
- func (s *Service) IsRateLimitError(err error, target string, channel CodeChannel, kind CodeKind) bool
- func (s *Service) ResetPassword(code string, newPassword string) error
- func (s *Service) ResetPasswordWithTarget(target string, code string, newPassword string, channel CodeChannel, ...) error
- func (s *Service) SendCode(loginID string, options *CodeOptions) error
- func (s *Service) SetPassword(userID string, newPassword string) (err error)
- func (s *Service) VerifyCode(code string) (state *otp.State, err error)
- func (s *Service) VerifyCodeWithTarget(target string, code string, codeChannel CodeChannel, kind CodeKind) (state *otp.State, err error)
Constants ¶
This section is empty.
Variables ¶
var ErrFeatureDisabled = SendCodeFailed.NewWithCause("forgot password is disabled", apierrors.StringCause("FeatureDisabled"))
var ErrInvalidCode = PasswordResetFailed.NewWithCause("invalid code", apierrors.StringCause("InvalidCode"))
var ErrUsedCode = PasswordResetFailed.NewWithCause("used code", apierrors.StringCause("UsedCode"))
var ErrUserNotFound = SendCodeFailed.NewWithCause("specified user not found", apierrors.StringCause("UserNotFound"))
var PasswordResetFailed = apierrors.Invalid.WithReason("PasswordResetFailed")
var SendCodeFailed = apierrors.Invalid.WithReason("ForgotPasswordFailed")
Functions ¶
This section is empty.
Types ¶
type AuthenticatorService ¶
type AuthenticatorService interface { List(userID string, filters ...authenticator.Filter) ([]*authenticator.Info, error) New(spec *authenticator.Spec) (*authenticator.Info, error) WithSpec(ai *authenticator.Info, spec *authenticator.Spec) (bool, *authenticator.Info, error) Update(info *authenticator.Info) error Create(authenticatorInfo *authenticator.Info, markVerified bool) error Delete(info *authenticator.Info) error }
type CodeChannel ¶
type CodeChannel string
const ( CodeChannelUnknown CodeChannel = "" CodeChannelEmail CodeChannel = "email" CodeChannelWhatsapp CodeChannel = "whatsapp" CodeChannelSMS CodeChannel = "sms" )
type CodeOptions ¶
type CodeOptions struct { AuthenticationFlowType string AuthenticationFlowName string AuthenticationFlowJSONPointer jsonpointer.T Kind CodeKind Channel CodeChannel }
type IdentityService ¶
type OTPCodeService ¶
type OTPCodeService interface { GenerateOTP(kind otp.Kind, target string, form otp.Form, opt *otp.GenerateOptions) (string, error) VerifyOTP(kind otp.Kind, target string, otp string, opts *otp.VerifyOptions) error InspectState(kind otp.Kind, target string) (*otp.State, error) LookupCode(purpose otp.Purpose, code string) (target string, err error) ConsumeCode(purpose otp.Purpose, target string) error }
type OTPSender ¶
type OTPSender interface { Prepare(channel model.AuthenticatorOOBChannel, target string, form otp.Form, typ otp.MessageType) (*otp.PreparedMessage, error) Send(msg *otp.PreparedMessage, opts otp.SendOptions) error }
type Service ¶
type Service struct { Logger Logger Config *config.AppConfig FeatureConfig *config.FeatureConfig Identities IdentityService Authenticators AuthenticatorService OTPCodes OTPCodeService OTPSender OTPSender }
func (*Service) CodeLength ¶
func (s *Service) CodeLength(target string, channel CodeChannel, kind CodeKind) int
func (*Service) InspectState ¶
func (s *Service) InspectState(target string, channel CodeChannel, kind CodeKind) (*otp.State, error)
InspectState is for external use. It DOES NOT report dummy code as invalid.
func (*Service) IsRateLimitError ¶
func (*Service) ResetPassword ¶
ResetPassword consumes code and reset password to newPassword. If the code is valid, the password is reset to newPassword. newPassword is checked against the password policy so password policy error may also be returned.
func (*Service) ResetPasswordWithTarget ¶
func (s *Service) ResetPasswordWithTarget(target string, code string, newPassword string, channel CodeChannel, kind CodeKind) error
ResetPasswordWithTarget is same as ResetPassword, except target is passed by caller.
func (*Service) SendCode ¶
func (s *Service) SendCode(loginID string, options *CodeOptions) error
SendCode uses loginID to look up Email Login IDs and Phone Number Login IDs. For each looked up login ID, a code is generated and delivered asynchronously.
func (*Service) SetPassword ¶
SetPassword ensures the user identified by userID has the specified password. It perform necessary mutation to make this happens.