clef/instant2fa

Instant2FA 的 PHP 客户端。

1.0.1 2016-11-30 18:37 UTC

This package is not auto-updated.

Last update: 2024-09-28 20:20:02 UTC


README

PHP 客户端用于 Instant2FA

安装

使用 composer 安装

composer require clef/instant2fa

需要 PHP 5.4 或更高版本。

用法

请参阅我们的 集成指南,详细了解集成过程。集成过程大约需要一小时。

以下是您将使用的方法示例

$instant2fa = new \Instant2FA\Instant2FA([
    'access_key' => ACCESS_KEY,
    'access_secret' => ACCESS_SECRET
]);
                                
$distinct_id = "A_UNIQUE_ID_FOR_A_GIVEN_USER";

// To show hosted 2FA settings:
$hosted_page_url = $instant2fa->create_settings($distinct_id);

// To show a hosted verification page:
try {
    $hosted_page_url = $instant2fa->create_verification($distinct_id);
    // Redirect to 2FA verification page
} catch (\Instant2FA\Error\MFANotEnabled $e) {
    // Log the user in as normal
}

// To see whether a user successfully completed 2FA verification:
$succeeded = $instant2fa->confirm_verification($distinct_id, $request->input('instant2faToken'));