我一直在开发一款使用webauthn-ruby gem for 2FA的rails 7应用程序.在前端,我们使用WebAuthnJSON.登录时,首先有一个使用邮箱/密码的步骤,之后我们会找到现有的凭据,用户将需要使用WebAuthn进行身份验证.
我遇到的问题是,无论我使用什么设置,在Windows(Chrome)中,用户在进行身份验证时,总是会被提示输入安全密钥(USB)或其他设置,提示他们登录Windows Hello.取消该步骤后,您将进入正常的Chrome模式,在该模式下您可以 Select 要进行身份验证的设备.我们想跳过Windows的步骤,或者更确切地说,让用户可以设置Android设备,但不知道如何设置.
这个问题可以在https://webauthn.cedarcode.com/上转载.
但是,如果您在https://webauthn.io上测试,则不会出现此问题.
这是因为这个gem,还是与WebAuthnJSON有关,还是设置不正确?
使用默认设置和几乎任何其他设置都会发生这种情况.
服务器注册:
create_options = WebAuthn::Credential.options_for_create(
exclude: @authenticatable.webauthn_credentials.pluck(:external_id),
user: {
id: @authenticatable.webauthn_id,
display_name: @authenticatable.email,
name: @authenticatable.full_name
},
pub_key_cred_params: [
{
type: 'public-key',
alg: -7 # "ES256" as registered in the IANA COSE 算法rithms registry
},
{
type: 'public-key',
alg: -257 # Value registered by this specification for "RS256"
}
],
authenticator_selection: {
resident_key: 'required', # This setting specifically makes windows hello not pop-up
user_verification: 'preferred'
},
attestation: 'none'
)
客户端注册:
WebAuthnJSON.get({ "publicKey": data }).then(async function(credential) {
const request = new FetchRequest("post", _this.callbackValue, { body: JSON.stringify(credential) })
const response = await request.perform()
if (response.ok) {
const data = await response.json
window.Turbo.visit(data.redirect, { action: 'replace' })
} else {
console.log("An error occured while authenticating Webauthn", response);
}
}).catch(function(error) {
console.log("An error occured while authenticating Webauthn", error);
});
服务器身份验证:
get_options = WebAuthn::Credential.options_for_get(
allow: @authenticatable.webauthn_credentials.pluck(:external_id),
user_verification: 'discouraged'
)
客户端身份验证:
WebAuthnJSON.get({ "publicKey": data }).then(async function(credential) {
const request = new FetchRequest("post", _this.callbackValue, { body: JSON.stringify(credential) })
const response = await request.perform()
if (response.ok) {
const data = await response.json
window.Turbo.visit(data.redirect, { action: 'replace' })
} else {
console.log("An error occured while authenticating Webauthn", response);
}
}).catch(function(error) {
console.log("An error occured while authenticating Webauthn", error);
});
具体地说,在注册时将服务器中的Resident_Key设置为Required会从注册流程中删除该步骤,但不会删除身份验证中的Windows Hello或安全密钥步骤,因此我的问题仍然存在.