我正在尝试编写一个 Python 3 脚本,该脚本将通过 ssh 连接到远程服务器并使用 paramiko 模块运行命令。
远程服务器使用 Duo 2 因素身份验证,并在使用 ssh 连接时提示您选择身份验证模式:
$ ssh myuser@remoteserver.com
Duo two-factor login for myuser
Enter a passcode or select one of the following options:
1. Duo Push to +XXX XX-XXX-1111
2. Phone call to +XXX XX-XXX-1111
3. SMS passcodes to +XXX XX-XXX-1111
Passcode or option (1-3): 1
Success. Logging you in...
Run Code Online (Sandbox Code Playgroud)
当我在终端中使用 ssh 时,我只需按 1,然后按 Enter,将推送到我的手机,在其中确认连接,然后登录。
不幸的是,我无法在 Python 中做到这一点。这是我尝试使用的代码:
import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('remoteserver.com', port=22, username='myuser', password='mypassword')
stdin, stdout, stderr …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Postman 通过 Microsoft Graph API“获取用户访问令牌”;但是,我的组织最近启用了多因素身份验证,并且此调用现在失败,并指出:
\n\n"error": "invalid_grant",
"error_description": "AADSTS50076: Due to a configuration change made by your administrator, or because you moved to a new location, you must use multi-factor authentication to access...
\xc2\xa0\n使用 Postman 的 MS Graph API 的 Microsoft 文档写得很好,但缺少明确的说明如何将第二个因素传递给请求。
\n\n该错误指向https://login.microsoftonline.com/error?code=50076,但这只是提供了相同的信息。
\n\n我有 MS 身份验证器应用程序,它为我提供了这个关键/第二个因素;但是,我不知道如何将其添加到正文/标题中。 我正在尝试查找用于传递附加安全令牌的特定密钥名称(我尝试过诸如“token”、“pcToken”、“key”等)
\n\n。
\n\n\n\n\npostman azure-ad-graph-api multi-factor-authentication microsoft-graph-api
我正在关注https://cloud.google.com/identity-platform/docs/web/mfa#choosing_an_enrollment_pattern上看似过时的文档页面 当使用电子邮件+密码登录时,我希望捕获错误,然后执行以下操作
if (error.code === "auth/multi-factor-auth-required") {
const resolver = error.resolver
Run Code Online (Sandbox Code Playgroud)
但是当我注销该error对象时,没有 error.resolver 这样的属性:
FirebaseError: Firebase: Error (auth/multi-factor-auth-required). resolver: undefined
Run Code Online (Sandbox Code Playgroud) firebase firebase-authentication google-identity multi-factor-authentication
我一直在研究在我公司的应用程序中使用 webauthn 进行 MFA。当我开始研究它时,它看起来非常合适,并且我对我们的用户能够使用手机作为身份验证器的前景感到非常兴奋。
然而,一位拥有 iPhone 的同事向我指出,当他在https://webauthn.io/上尝试示例应用程序时,他无法选择他的 iPhone,并且只能选择将 Android 手机添加到他的帐户。和我们的许多用户一样,他在 Windows 计算机上使用 Chrome,但拥有 iPhone 12。
对我来说,这种情况不被支持似乎是不可想象的?许多用户使用 Windows 并拥有 iOS 设备。我错过了一些明显的东西吗?
我正在使用 boto3 和授权库来尝试对设备进行身份验证,以在识别后跳过多因素身份验证。我已经通过了用户/密码身份验证,但似乎无法找出验证设备的正确方法。以下是我的代码:
from warrant import aws_srp
from warrant.aws_srp import AWSSRP
import boto3
client = boto3.client('cognito-idp')
import datetime
username='xxx'
password='xxx'
client_id='xxx'
aws = AWSSRP(username=username, password=password, pool_id='xxx',
client_id=client_id, client=client)
auth_init = client.initiate_auth(
AuthFlow='USER_SRP_AUTH',
AuthParameters={
'USERNAME': username,
'SRP_A': aws_srp.long_to_hex(aws.large_a_value),
},
ClientId=client_id,
)
cr = aws.process_challenge(auth_init['ChallengeParameters'])
response = client.respond_to_auth_challenge(
ClientId=client_id,
ChallengeName=auth_init['ChallengeName'],
ChallengeResponses=cr
)
response = client.respond_to_auth_challenge(
ClientId=client_id,
ChallengeName='SMS_MFA',
Session=response['Session'],
ChallengeResponses={
'USERNAME': username,
'SMS_MFA_CODE':'xxx'
}
)
response_dev = client.confirm_device(
AccessToken=response['AuthenticationResult']['AccessToken'],
DeviceKey=response['AuthenticationResult']['NewDeviceMetadata']['DeviceKey'],
DeviceSecretVerifierConfig={
"PasswordVerifier": aws_srp.long_to_hex(aws.large_a_value),
"Salt": aws_srp.long_to_hex(aws.small_a_value)
}
)
response = client.update_device_status(
AccessToken=response['AuthenticationResult']['AccessToken'],
DeviceKey=device,
DeviceRememberedStatus='remembered' …Run Code Online (Sandbox Code Playgroud) python srp-protocol amazon-cognito boto3 multi-factor-authentication
我不知道我是否应该在这里问这个问题,也不知道我是否使用了正确的标签,但是......我需要在我正在开发的系统中添加一个 2FA,而我正在寻找2FA 的最佳可用选项,我们考虑向其添加 Microsoft Authenticator 支持(我们喜欢 Authy、Google Authenticator 等,但我们更喜欢这里的 Microsoft 解决方案)。似乎曾经存在一种将 Microsoft 的 2FA 添加到我们网站的方法,但是现在有没有办法在 2019 年做到这一点?如果是这样,它是免费的(我们有 Microsoft 开发者帐户......如果拥有它们是唯一的付费要求,我们没问题)
我正在使用 Cognito 用户池来验证我的 Web 应用程序。我现在一切正常,但现在我需要为它启用 MFA。这就是我现在的做法(提供的所有代码都是服务器端代码):
const cognito = new AWS.CognitoIdentityServiceProvider();
cognito.signUp({
ClientId,
Username: email,
Password,
}).promise();
Run Code Online (Sandbox Code Playgroud)
一封电子邮件被发送到用户的地址(在前面的函数调用中称为用户名),其中包含一个代码。
用户读取代码并将代码提供给下一个函数调用:
cognito.confirmSignUp({
ClientId,
ConfirmationCode,
Username: email,
ForceAliasCreation: false,
}).promise();
Run Code Online (Sandbox Code Playgroud)
const tokens = await cognito.adminInitiateAuth({
AuthFlow: 'ADMIN_NO_SRP_AUTH',
ClientId,
UserPoolId,
AuthParameters: {
'USERNAME': email,
'PASSWORD': password,
},
}).promise();
Run Code Online (Sandbox Code Playgroud)
我对这个过程很满意。但是现在我需要为此添加 TOTP MFA 功能。如果我想这样做,有人可以告诉我如何更改这些步骤吗?顺便说一句,我知道在创建用户池时需要为用户池启用 TOTP MFA。我只是询问它如何影响我的注册/登录过程。
我正在尝试生成用于 2 因素身份验证的 6 位代码,乍一看我可能会这样做:
Random random = new Random();
var securitycode = random.Next(1000000, 10000000);
Run Code Online (Sandbox Code Playgroud)
然而,这对我来说似乎有些不安全,因为如果您可以通过获取大量安全代码来找出种子,则可能有一种方法可以预测下一个数字。
我认为有更好的方法来获取安全代码,RNGCryptoServiceProvider但我对如何确保生成的代码是 6 位数字有点困惑
private string GenerateSecurityCode(int length)
{
var provider = new RNGCryptoServiceProvider();
var byteArray = new byte[8];
provider.GetBytes(byteArray);
var code = BitConverter.ToUInt32(byteArray, 0);
//how can I assure the code is 6 digits
}
Run Code Online (Sandbox Code Playgroud)
这是生成 MFA 代码的安全方法吗?如果不是,生成数字代码的好方法是什么?
c# security two-factor-authentication multi-factor-authentication