FedCM 更新:针对自动重新进行身份验证的源试用

针对 FedCM 推出了几项更新,包括针对自动重新身份验证推出新的源试用。

Federated Credential Management API (FedCM) 是 用于实现可保护隐私的身份联合的 Web API。借助身份联合, RP(依赖方)依靠 IdP(身份提供方)向用户提供 账号,而无需使用新的用户名和密码。

FedCM 是一个专门构建的 API,可让浏览器了解 RP 和 IdP 之间交换信息的 共享信息和权限级别,并防止意外滥用行为。

更新

Chrome 的 FedCM 实现有一些更新:

如需了解该 API 的所有过往更新,请参阅 Federated Credential Management API 更新

最新版 FedCM 包含新的自动重新身份验证功能,该功能支持在用户使用 FedCM 进行初始身份验证后返回时自动重新进行身份验证。从 Chrome 112 开始,自动重新身份验证功能以源试用的形式开始提供。

自动重新验证

目前,在用户通过 IdP 在 RP 上创建联合账号之后 通过 FedCM发送成功 他们需要在界面中完成相同步骤所需的网站 也就是说,他们需要明确确认并重新进行身份验证, 继续登录流程。作为主要的 FedCM 的目标是防止隐蔽跟踪,这种用户体验 (UX) 在用户之前是合理的 联合账号,但是在用户创建联合账号之后,账号就会变得不必要和繁琐。 已经走过一次了用户授予允许通信的权限后 因此在 RP 和 IdP 之间 强制用户再次明确确认其 之前已确认。因此,Chrome 推出了 RP 可为回访用户选择的用户体验。

FedCM 自动重新身份验证 (简称“auto-reauthn”)自动对用户重新进行身份验证(如果 RP 选择接受), 当用户使用 FedCM 完成初始身份验证后返回时返回。“最初的 身份验证”这是指用户创建账号或登录 RP 的 网站,方法是点按 FedCM 登录对话框中的“以...的身份登录...”按钮 我们第一次在同一个浏览器实例上使用它们

<ph type="x-smartling-placeholder">
</ph> 用户点按以创建账号或进行身份验证的对话框。
用户为创建账号或进行身份验证而点按的对话框。

RP 可以通过使用 autoReauthn: true 调用 navigator.credentials.get() 来请求自动重新验证。

const cred = await navigator.credentials.get({
  identity: {
    providers: [{
      configURL: "https://idp.example/fedcm.json",
      clientId: "1234",
    }],
    // NOTE: We are exploring different API options to expose this
    // functionality here:
    // https://github.com/fedidcg/FedCM/issues/429#issuecomment-1426358523
    // You should expect that, as a result of the origin trial, we'll
    // learn more from developers and browser vendors what works best here.
    autoReauthn: true, // default to false
  },
});

使用此调用时,系统会在以下条件下进行自动重新身份验证:

  • FedCM 可供使用。例如,用户也没有停用 FedCM 。
  • 在此浏览器中,用户仅使用一个 FedCM 账号登录网站。
  • 用户已使用该账号登录 IdP。
  • 过去 10 分钟内未发生自动重新验证。

当满足上述条件时,系统将尝试自动对 用户在 FedCM navigator.credentials.get() 被调用后立即启动。

<ph type="x-smartling-placeholder">
</ph>
用户正在使用 FedCM 自动重新向 RP 进行身份验证

试试看

您可以在本地尝试通过Chrome 浏览器 标记chrome://flags#fedcm-auto-re-authn”已开启 Chrome 112 或更高版本。

出于测试目的,您可以移除 浏览器数据。

  1. 导航到 chrome://history
  2. 在搜索记录框中,输入 RP 的来源。
  3. 点击三点状图标 ⋮,然后选择从历史记录中移除
  4. 重启 Chrome。

参与源试用

您还可以通过加入第三方 源试用(从 Chrome 112 开始提供) Chrome 114。

Origin trials allow you to try new features and give feedback on their usability, practicality, and effectiveness to the web standards community. For more information, see the Origin Trials Guide for Web Developers. To sign up for this or another origin trial, visit the registration page.

To register for the third-party origin trial and activate the feature on third-parties:

  1. Go to the origin trial registration page.
  2. Click the Register button and fill out the form to request a token
  3. Enter the serving origin as Web Origin.
  4. Check Third-party matching to inject the token with JavaScript on other origins.
  5. Click Submit.
  6. Embed the issued token on a third-party.

To embed the token to a third-party, add the following code to your JavaScript library or SDK served from the registered website's origin.

const tokenElement = document.createElement('meta');
tokenElement.httpEquiv = 'origin-trial';
tokenElement.content = 'TOKEN_GOES_HERE';
document.head.appendChild(tokenElement);

Replace TOKEN_GOES_HERE with your own token.

互动和分享反馈

如果您有反馈或在测试期间遇到任何问题,可以通过 crbug.com 分享反馈 (位于 Blink>Identity>FedCM 组件下)。

拍摄者:Alex Perz 已开启 不启动