我有一个角11项目,它实现了一个WebAuthn注册。后端是SpringBoot 2.4
WebAuthn登录应该在项目的两个部分工作,“主”和“查看器”域设置相当复杂:
主要工程
Urls
查看器项目
Urls
(
代码
environment.ts
prodUrls: ['company-project.com'],
webauthn: {
name: "Company DEV",
rpId: "localhost"
}environment.prod.ts (在构建中替换)
prodUrls: ['company-project.com'],
webauthn: {
name: "Company Prod",
rpId: "plattform.intra.company.com" // gets overridden by values in "prodUrls"
}webauthn.service.ts
private _getRelyingPartyInfo(): RelyingParty {
let rpId = environment.webauthn.rpId;
/**
* Check if the Hostname matches one of our Prod Hostnames
* and use this instead
*/
environment.prodUrls.forEach((url, index) => {
if (location.hostname.indexOf(url) > -1) {
rpId = environment.prodUrls[index];
}
});
const rp = {
id: rpId,
name: environment.webauthn.name
};
return rp;
}问题
localhost (后端和本地前端)。
WebAuthnException消息: rpIdHash与预先配置的rpId的哈希不匹配。
company-project.com作为rpId (害怕部署,因为它在暂存上不起作用)我试过的
为了进行暂存,我将rpId更改为develop.plattform.intra.company.com,我可以在"main“中注册和登录。登录“查看器”也会引发一个错误。
规范并没有非常具体地说明什么应该工作:https://www.w3.org/TR/webauthn/#relying-party-identifier,它只说明什么不能工作。我想,多个子域使分期的事情变得复杂了吗?
什么是用于分期的正确的rpId,以及company-project.com作为rpId应该在prod上工作的假设是否正确?
发布于 2021-02-18 20:39:22
为了进行暂存,我将
更改为develop.plattform.intra.company.com,我可以注册并在"main“中登录。登录“查看器”也会引发一个错误。
得到断言的代码是什么?您可能还会遇到this other question。您需要将get断言RP设置为用于注册的相同RP ID。如果您不这样做,它将默认为原点,这对于您的子域将是不同的。
https://stackoverflow.com/questions/66008413
复制相似问题