You are here

AuthenticationType.php in Google Authenticator / 2 Factor Authentication - 2FA 8

Same filename and directory in other branches
  1. 8.2 src/AuthenticationType.php

Contains Authentication type class.

File

src/AuthenticationType.php
View source
<?php

/**
 * @file
 * Contains Authentication type class.
 */
namespace Drupal\miniorange_2fa;


/**
/**
* @file
* This class represents authentication type.
*/
class AuthenticationType {
  public static $SMS_AND_EMAIL = array(
    'id' => 'otp-over-sms-and-email',
    'name' => 'OTP Over SMS and EMAIL',
    'code' => 'SMS AND EMAIL',
    'description' => 'You will receive a one time passcode on your mobile phone and email. You have to enter the otp on your screen to login. Supported in Desktops, Laptops, Smartphones, Feature Phones.',
    'supported-for' => array(
      'Laptops Phones',
    ),
    'challenge' => TRUE,
    'oob' => FALSE,
  );
  public static $SMS = array(
    'id' => 'otp-over-sms',
    'name' => 'OTP Over SMS',
    'code' => 'SMS',
    'description' => 'You will receive a one time passcode via SMS on your phone. You have to enter the otp on your screen to login. Supported in Smartphones, Feature Phones.',
    'supported-for' => array(
      'Feature Phones',
    ),
    'challenge' => TRUE,
    'oob' => FALSE,
  );
  public static $OTP_OVER_EMAIL = array(
    'id' => 'otp-over-email',
    'name' => 'OTP Over Email',
    'code' => 'EMAIL',
    'description' => 'You will receive a one time passcode via an email. You have to enter the otp on your screen to login. Supported in Smartphones, Feature Phones.',
    'supported-for' => array(
      'Laptops',
    ),
    'challenge' => TRUE,
    'oob' => FALSE,
  );
  public static $OTP_OVER_PHONE = array(
    'id' => 'otp-over-phone',
    'name' => 'OTP Over Phone Call',
    'code' => 'PHONE VERIFICATION',
    'description' => 'You will receive a one time passcode via phone call. You have to enter the otp on your screen to login. Supported in Smartphones, Feature Phones.',
    'supported-for' => array(
      'Landline',
    ),
    'challenge' => TRUE,
    'oob' => FALSE,
  );
  public static $EMAIL = array(
    'id' => 'email',
    'name' => 'OTP Over Email',
    'code' => 'EMAIL',
    'description' => 'You will receive a one time passcode via Email. You have to enter the otp on your screen to login. Supported in Smartphones, Feature Phones.',
    'supported-for' => array(
      'Laptops',
    ),
    'challenge' => TRUE,
    'oob' => FALSE,
  );

  // Out of band Email
  public static $EMAIL_VERIFICATION = array(
    'id' => 'email-verification',
    'name' => 'Email Verification',
    'code' => 'OUT OF BAND EMAIL',
    'description' => 'You will receive an email with link. You have to click the <em>ACCEPT</em> or <em>DENY</em> link to verify your email. Supported in Desktops, Laptops, Smartphones.',
    'supported-for' => array(
      'Laptops',
    ),
    'challenge' => TRUE,
    'oob' => TRUE,
  );
  public static $GOOGLE_AUTHENTICATOR = array(
    'id' => 'google-authenticator',
    'name' => 'Google Authenticator',
    'code' => 'GOOGLE AUTHENTICATOR',
    'description' => 'You have to enter code generated by <em>Google Authenticator App</em> to login. Supported in Smartphones only.',
    'supported-for' => array(
      'Smartphones',
    ),
    'challenge' => FALSE,
    'oob' => FALSE,
  );
  public static $QR_CODE = array(
    'id' => 'qrcode-authentication',
    'name' => 'QR Code Authentication',
    'code' => 'MOBILE AUTHENTICATION',
    'description' => 'You have to scan the QR Code from your phone using <em>miniOrange Authenticator App</em> to login. Supported in Smartphones only.',
    'supported-for' => array(
      'Smartphones',
    ),
    'challenge' => TRUE,
    'oob' => TRUE,
  );
  public static $KBA = array(
    'id' => 'kba-authentication',
    'name' => 'Security Questions (KBA)',
    'code' => 'KBA',
    'description' => 'You have to answers some knowledge based security questions which are only known to you to authenticate yourself. Supported in Desktops, Laptops, Smartphones.',
    'supported-for' => array(
      'Laptops',
    ),
    'challenge' => TRUE,
    'oob' => FALSE,
  );
  public static $SOFT_TOKEN = array(
    'id' => 'soft-token',
    'name' => 'Soft Token',
    'code' => 'SOFT TOKEN',
    'description' => 'You have to enter code generated by <em>miniOrange Authenticator App</em> to login. Supported in Smartphones only.',
    'supported-for' => array(
      'Smartphones',
    ),
    'challenge' => FALSE,
    'oob' => FALSE,
  );
  public static $PUSH_NOTIFICATIONS = array(
    'id' => 'push-notifications',
    'name' => 'Push Notifications',
    'code' => 'PUSH NOTIFICATIONS',
    'description' => 'You will receive a push notification on your phone. You have to <em>ACCEPT</em> or <em>DENY</em> it to login. Supported in Smartphones only.',
    'supported-for' => array(
      'Smartphones',
    ),
    'challenge' => TRUE,
    'oob' => TRUE,
  );
  public static function getAuthType($code) {
    $arr = array(
      "SMS_AND_EMAIL" => AuthenticationType::$SMS_AND_EMAIL,
      "OTP_OVER_EMAIL" => AuthenticationType::$OTP_OVER_EMAIL,
      "EMAIL" => AuthenticationType::$EMAIL,
      "SMS" => AuthenticationType::$SMS,
      "EMAIL_VERIFICATION" => AuthenticationType::$EMAIL_VERIFICATION,
      "GOOGLE_AUTHENTICATOR" => AuthenticationType::$GOOGLE_AUTHENTICATOR,
      "QR_CODE" => AuthenticationType::$QR_CODE,
      "KBA" => AuthenticationType::$KBA,
      "SOFT_TOKEN" => AuthenticationType::$SOFT_TOKEN,
      "PUSH_NOTIFICATIONS" => AuthenticationType::$PUSH_NOTIFICATIONS,
      "PHONE_VERIFICATION" => AuthenticationType::$OTP_OVER_PHONE,
    );
    foreach ($arr as $authType) {
      if (strcasecmp($authType['code'], $code) == 0) {
        return $authType;
      }
    }
    return NULL;
  }

}

Classes

Namesort descending Description
AuthenticationType @file This class represents authentication type.