MCPcopy Create free account
hub / github.com/bytebase/bytebase / checkMFALockout

Method checkMFALockout

backend/api/v1/auth_service.go:838–849  ·  view source on GitHub ↗

checkMFALockout checks if the user has exceeded the MFA failure rate limit. Returns an error if the user is locked out due to too many failed MFA attempts.

(ctx context.Context, email string)

Source from the content-addressed store, hash-verified

836// checkMFALockout checks if the user has exceeded the MFA failure rate limit.
837// Returns an error if the user is locked out due to too many failed MFA attempts.
838func (s *AuthService) checkMFALockout(ctx context.Context, email string) error {
839 count, err := s.countRecentLoginFailures(ctx, email, mfaLockoutWindow, errMsgInvalidMFACode, errMsgInvalidRecoveryCode)
840 if err != nil {
841 return connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to count recent MFA failures"))
842 }
843
844 if count >= mfaMaxFailedAttempts {
845 return connect.NewError(connect.CodeResourceExhausted, errors.Errorf(errMsgTooManyMFA))
846 }
847
848 return nil
849}
850
851func challengeMFACode(user *store.UserMessage, mfaCode string) error {
852 if !validateWithCodeAndSecret(mfaCode, user.MFAConfig.OtpSecret) {

Callers 2

completeMFALoginMethod · 0.95
SwitchWorkspaceMethod · 0.95

Calls 2

ErrorfMethod · 0.80

Tested by

no test coverage detected