vix*_*cis 8 javascript webauthn
我正在尝试在我的网站上设置 WebAuthn 身份验证流程,但遇到了问题。我希望我的用户能够在主网站 (www.domain.com) 上注册他们的设备,以便可以通过用户设置轻松访问。身份验证本身通过 IdP (sso.domain.com) 在不同的子域上进行。这就是麻烦开始的地方。
我尝试过以下几件事:
如果我正确理解规范,传递“scoutswechel.be”实际上应该有效,因为两个域都是主域的子域(如果我在这里错了,请纠正我)。
我使用 PHP 准备挑战,并通过 ajax 调用将它们传递到页面。我的 PHP 脚本返回以下值:
{
"publicKey":{
"challenge":[105,107,101,103,105,49,119,115,98,108,119,109,48,109,105,53],
"user":{
"name":"walter",
"displayName":"Wouter Henderickx",
"id":[49,48,51]
},
"rp":{
"id":"scoutswechel.be",
"name":"scoutswechel.be"
},
"pubKeyCredParams":[
{
"alg":-7,
"type":"public-key"
}
],
"authenticatorSelection":{
"authenticatorAttachment":"cross-platform",
"requireResidentKey":false,
"userVerification":"preferred"
},
"attestation":null,
"timeout":60000,
"excludeCredentials":[],
"extensions":{
"exts":true
}
},
"b64challenge":"aWtlZ2kxd3NibHdtMG1pNQ"
}Run Code Online (Sandbox Code Playgroud)
然后,我将质询和 user.id 转换为 Uint8Array 并将公钥部分传递给:
navigator.credentials.create({publicKey: key.publicKey}).
then(function (aNewCredentialInfo) {
do.stuff()
})Run Code Online (Sandbox Code Playgroud)
我该怎么办?我可以将哪些值传递给 rp.id 以使其在两个子域中正常工作?
最后,我想通了。这些都是我的实施问题: