Class: Gitlab::Auth::Otp::Strategies::FortiAuthenticator::ManualOtp

Inherits:
Base
  • Object
show all
Defined in:
lib/gitlab/auth/otp/strategies/forti_authenticator/manual_otp.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Gitlab::Auth::Otp::Strategies::Base

Instance Method Details

#validate(otp_code) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/gitlab/auth/otp/strategies/forti_authenticator/manual_otp.rb', line 9

def validate(otp_code)
  @otp_code = otp_code

  response = Gitlab::HTTP.post(
    auth_url,
    headers: { 'Content-Type': 'application/json' },
    body: body.to_json,
    basic_auth: api_credentials)

  # Successful authentication results in HTTP 200: OK
  # Manual OTP - https://docs.fortinet.com/document/fortiauthenticator/6.2.0/rest-api-solution-guide/704555/authentication-auth
  response.ok? ? success : error_from_response(response)
rescue StandardError => ex
  Gitlab::AppLogger.error(ex)
  error(ex.message)
end