如何为 Microsoft Authenticator 应用程序配置 otphp?

问题描述 投票:0回答:1

我正在开发一个 Laravel 项目,想要使用一次性密码创建一个自己的双因素身份验证。

所以我选择了Spomky-Labs otphp库并且有一些像这样的代码:

$secretB32 = Base32::encode('slkopnucji6vl34utmehqla5mbkb4grvmet7uvs7dtnko6v4bqwhfk3v');
$otp = TOTP::createFromSecret($secretB32);
$otp->setDigest('sha1');
$otp->setPeriod(60);
$otp->setLabel('Project name');
$otp->setDigits(6);
// Echos the provisioning URI to make QR code from.
echo $otp->getProvisioningUri();
echo '<br /><br />';
// Echoes the six digits One Time Password
echo $otp->now(); // Works with FreeOTP App but not with Microsoft Authenticator

由配置 URI 生成的 QR 码与 FreeOTP 应用程序完美配合,但它不适用于 Microsoft Authenticator 应用程序,我更喜欢该应用程序,因为它的外观更专业。

Microsoft Authenticator 甚至无法识别 60 秒的时间段。我假设我错误地设置了 Spomky 的库,尤其是算法。

有人做过这个工作吗?预先感谢!

PS:我也对任何其他 PHP 库开放。

php erlang-otp two-factor-authentication authenticator
1个回答
0
投票

绝大多数 OTP 应用程序仅支持 6 位数字、30 秒、SHA1 哈希的默认参数。 FreeOTP 是我发现的唯一一个支持我所尝试的所有功能的软件,1Password 紧随其后。 这里是我几年前制作的网格,显示了我尝试过的所有组合。

如果您不介意要求用户使用特定的 OTP 应用程序,则可以使用这些默认值以外的值。

如果您不想对用户施加此限制,请将参数保留为 6 位数字、30 秒和 SHA1 哈希。

© www.soinside.com 2019 - 2024. All rights reserved.