You are here

class AuthenticationAPIHandler in Google Authenticator / 2 Factor Authentication - 2FA 8.2

Same name and namespace in other branches
  1. 8 src/AuthenticationAPIHandler.php \Drupal\miniorange_2fa\AuthenticationAPIHandler

Hierarchy

Expanded class hierarchy of AuthenticationAPIHandler

10 files declare their use of AuthenticationAPIHandler
authenticate_user.php in src/Form/authenticate_user.php
This is used to authenticate user during login.
configure_google_authenticator.php in src/Form/configure_google_authenticator.php
configure_kba.php in src/Form/configure_kba.php
configure_qrcode_authentication.php in src/Form/configure_qrcode_authentication.php
miniorange_2fa_inline_registration.php in src/Form/miniorange_2fa_inline_registration.php
Page 1: Select Email address. Page 2: Verify OTP. Page 3: Select Auth Method. Page 4: Configure Auth Method. Page 5: Configure KBA.

... See full list

File

src/AuthenticationAPIHandler.php, line 5

Namespace

Drupal\miniorange_2fa
View source
class AuthenticationAPIHandler {
  private $customerId;
  private $apiKey;
  public function __construct($customerId, $apiKey) {
    $this->apiKey = $apiKey;
    $this->customerId = $customerId;
  }
  public function challenge(MiniorangeUser $user) {
    $fields = array(
      'customerKey' => $user
        ->getCustomerId(),
      'username' => $user
        ->getUsername(),
      'email' => $user
        ->getEmail(),
      'phone' => $user
        ->getPhone(),
      'authType' => $user
        ->getAuthType(),
      'transactionName' => MoAuthConstants::$TRANSACTION_NAME,
    );
    $json = json_encode($fields);
    $url = MoAuthConstants::getBaseUrl() . MoAuthConstants::$AUTH_CHALLENGE_API;
    return MoAuthUtilities::callService($this->customerId, $this->apiKey, $url, $json);
  }
  public function validate(MiniorangeUser $user, $txId, $token, $answers = NULL) {
    $fields = array(
      'customerKey' => $user
        ->getCustomerId(),
      'username' => $user
        ->getUsername(),
      'txId' => $txId,
      'token' => str_replace(" ", "", $token),
      'authType' => $user
        ->getAuthType(),
      'answers' => $answers,
    );
    $json = json_encode($fields);
    $url = MoAuthConstants::getBaseUrl() . MoAuthConstants::$AUTH_VALIDATE_API;
    return MoAuthUtilities::callService($this->customerId, $this->apiKey, $url, $json);
  }
  public function getAuthStatus($txId) {
    $fields = array(
      'txId' => $txId,
    );
    $json = json_encode($fields);
    $url = MoAuthConstants::getBaseUrl() . MoAuthConstants::$AUTH_STATUS_API;
    return MoAuthUtilities::callService($this->customerId, $this->apiKey, $url, $json);
  }
  public function getGoogleAuthSecret(MiniorangeUser $user) {
    $fields = array(
      'customerKey' => $user
        ->getCustomerId(),
      'username' => $user
        ->getUsername(),
      'googleAuthenticatorName' => \Drupal::config('miniorange_2fa.settings')
        ->get('mo_auth_google_auth_app_name') == '' ? 'miniOrangeAuth' : \Drupal::config('miniorange_2fa.settings')
        ->get('mo_auth_google_auth_app_name'),
    );
    $json = json_encode($fields);
    $url = MoAuthConstants::getBaseUrl() . MoAuthConstants::$AUTH_GET_GOOGLE_AUTH_API;
    return MoAuthUtilities::callService($this->customerId, $this->apiKey, $url, $json);
  }
  public function register(MiniorangeUser $user, $registrationType, $secret, $token, $quesAnsList) {
    $fields = array(
      'customerKey' => $user
        ->getCustomerId(),
      'username' => $user
        ->getUsername(),
      'registrationType' => $registrationType,
      'secret' => $secret,
      'otpToken' => str_replace(" ", "", $token),
      'questionAnswerList' => $quesAnsList,
    );
    $json = json_encode($fields);
    $url = MoAuthConstants::getBaseUrl() . MoAuthConstants::$AUTH_REGISTER_API;
    return MoAuthUtilities::callService($this->customerId, $this->apiKey, $url, $json);
  }
  public function getRegistrationStatus($txId) {
    $fields = array(
      'txId' => $txId,
    );
    $json = json_encode($fields);
    $url = MoAuthConstants::getBaseUrl() . MoAuthConstants::$AUTH_REGISTRATION_STATUS_API;
    return MoAuthUtilities::callService($this->customerId, $this->apiKey, $url, $json);
  }

}

Members