---
url: 'https://www.corbado.com/zh/glossary/authenticatorselection'
title: 'authenticatorSelection'
description: '了解 WebAuthn 中的 authenticatorSelection，这是一种定义认证器要求的方法，可增强 WebAuthn 的安全性和用户体验。'
lang: 'zh'
keywords: 'authenticatorselection, WebAuthn, 认证器选择, 用户验证'
---

# authenticatorSelection

## authenticatorSelection 是什么？

在 WebAuthn 中，[authenticatorSelection](https://www.corbado.com/glossary/authenticatorselection) 是
[PublicKeyCredentialCreationOptions](https://www.corbado.com/glossary/publickeycredentialcreationoptions)
对象的一个重要组成部分。该功能使信赖方 (RP) 能够在 `create()`
操作期间指定选择合适认证器的标准。其重要性在于：

- **定义认证器要求：** 规定了可以参与注册过程的认证器类型。
- **认证器附加方式：** 决定认证器是平台认证器（例如
  [Face ID](https://www.corbado.com/faq/is-face-id-passkey)、Touch
  ID、[Windows Hello](https://www.corbado.com/glossary/windows-hello)）还是跨平台（漫游）认证器。
- **用户验证：** 设置用户验证的要求（例如，“preferred”、“required”或“discouraged”）。

### 示例：

```json
    "authenticatorSelection": {
      "authenticatorAttachment": "platform",
      "residentKey": "required",
      "requireResidentKey": false,
      "userVerification": "required",
    }
```

继续阅读，了解 **authenticatorSelection** 的可能值和配置的详细信息。

## 核心要点

> - [authenticatorSelection](https://www.corbado.com/glossary/authenticatorselection)
>   用于在 WebAuthn 中指定选择认证器的要求。
> - 它包括认证器的附加方式和用户验证要求。
> - 通过精确控制认证过程来增强安全性。

---

WebAuthn 中的 [authenticatorSelection](https://www.corbado.com/glossary/authenticatorselection)
对于确保认证过程符合特定的安全要求和用户体验偏好至关重要。它为信赖方提供了根据其安全需求定制注册过程的灵活性。

以下是
[WebAuthn 规范](https://www.w3.org/TR/webauthn-2/#dictdef-authenticatorselectioncriteria)中指定的可能值的概述：

### authenticatorAttachment

可能的值：

- **Platform：** 认证器附加在客户端的平台上，因此不可移除。
- **Cross-platform：** 认证器不与客户端的平台绑定，可以在多个设备上使用。

### residentKey

此值指定信赖方是否希望创建可发现凭证。可能的值是：

- **required：** 认证器必须创建驻留密钥，如果无法创建，操作应失败。
- **preferred：** 认证器应尝试创建驻留密钥，如果无法创建，则应创建非驻留密钥。
- **discouraged：** 认证器必须创建非驻留密钥，如果无法创建，操作应失败。

### requireResidentKey

此值仅用于与 WebAuthn 级别 1 的向后兼容，如果 residentKey 设置为 "required"，则此值设置为 "true"。

### userVerification

此值表示操作是否需要用户验证。可能的值是：

- **required：** 操作必须验证用户。
- **preferred：** 操作应验证用户，但也可以在没有验证的情况下继续（标准值）。
- **discouraged：** 操作不应验证用户。

**警告：**
如果设置为 "preferred"，认证器可能会在认证过程中跳过用户验证。请在[这篇文章](https://web.dev/articles/passkey-form-autofill#fetch_a_challenge_from_the_rp_server)中阅读有关此问题的更多信息。

---

## authenticatorSelection 常见问题解答

### 在 WebAuthn 中，authenticatorSelection 有什么作用？

WebAuthn 中的 authenticatorSelection 允许信赖方指定适合其认证过程的认证器类型，包括对用户验证的要求和认证器的类型。

### authenticatorSelection 如何影响认证中的用户体验？

它通过确定所用认证器的类型（平台或漫游）并设置用户验证的级别来影响用户体验，从而影响认证过程的便捷性和安全性。

### authenticatorSelection 中的 authenticatorAttachment 设置有什么影响？

The authenticatorAttachment setting in authenticatorSelection dictates whether a fixed
[platform authenticator](https://www.corbado.com/glossary/platform-authenticator) or a removable
cross-[platform authenticator](https://www.corbado.com/glossary/platform-authenticator) is required, affecting
the physical and functional characteristics of the authentication process.
