Authing 文档文档
快速开始
概念
使用指南
开发集成 V2 arrow
  • V2 文档
  • V3 文档
元数据
应用集成
身份自动化
加入 APN
开发集成
多租户(内测版)
控制台文档
多租户控制台
租户控制台
Saas 应用 Demo
快速开始
概念
使用指南
开发集成 V2 arrow
  • V2 文档
  • V3 文档
元数据
应用集成
身份自动化
加入 APN
开发集成
多租户(内测版)
控制台文档
多租户控制台
租户控制台
Saas 应用 Demo
旧版
开发集成
  • JavaScript SDK 索引
  • 单点登录(SSO)
  • 登录组件 (Guard)

  • 多因素认证组件(MFA)

  • JavaScript / Node.js

  • Java / Kotlin

  • Python

  • C#

  • PHP

  • Go

  • Ruby
  • Delphi
  • Android

  • iOS

    • 快速开始
    • 托管页
    • 超组件

    • APIs

    • 第三方身份源

    • 典型场景

    • 私有化部署
    • 生物认证
    • iOS Guard 更新日志
    • 返回码对照表
  • Flutter

  • 微信小程序
  • 微信网页授权
  • React Native
  • 框架集成

  • Radius
  • 错误代码

¶ WebAuthn 生物认证

更新时间: 2025-05-14 08:32:28
编辑

¶ 集成 WebAuthn 登录

¶ 第一步:在 Authing 管理控制台 (opens new window) 打开生物认证

  1. 在自建应用下找到需要开启的客户端应用。
  2. 点击登录控制。
  3. 点击生物认证控制并开启开关。


¶ 第二步:添加 WebAuthn 登录依赖

  1. 在 swift package 搜索栏输入:https://github.com/Authing/authing-binary 。

  2. 选择 Authing-binary (opens new window)。

  3. 依赖规则选择 Up to Next Major Version 1.0.0 。

  4. Add Package 后勾选 WebAuthn 。

WebAuthn 依赖于 Guard-iOS 1.4.0 (opens new window) 之后版本。


¶ 使用 WebAuthn 登录

¶ 使用 WebAuthn 超组件

Authing WebAuthn SDK 为开发者提供了生物认证按钮超组件,开发者可以通过此组件一分钟集成 WebAuthn 无密码认证。

¶ 使用 WebAuthn API

如果开发者想自己实现 WebAuthn 认证流程,可参阅自定义-WebAuthn-认证流程,结合以下 API 进行开发。

¶ 获取 WebAuthn 凭证创建初始化参数

获取 WebAuthn 凭证创建初始化参数,调用此接口前需要用户已登录。

public func getWebauthnRegistrationParam(completion: @escaping(Int, String?, NSDictionary?) -> Void) 

示例

AuthClient().getWebauthnRegistrationParam() { code, message, data in
    // data.registrationOptions
}

¶ 验证 WebAuthn 绑定注册认证器凭证

验证 WebAuthn 绑定注册认证器凭证

func webauthnRegistration(ticket: String, credentialId: String, rawId: String, attestationObject: String, clientDataJSON: String, authenticatorCode: String, completion: @escaping(Int, String?, NSDictionary?) -> Void)

参数

  • ticket 获取凭证创建初始化参数时的 ticket
  • credentialId Base64URL 编码的凭证 ID
  • rawId Base64URL 原始凭证 ID
  • attestationObject 客户端数据,包含 origin(即凭证请求来源)、挑战等信息
  • creclientDataJSONdentialId Base64URL 编码的凭证 ID
  • authenticatorCode 凭证信息类型:"fingerprint" "face" "other"

示例

AuthClient().webauthnRegistration(ticket: ticket, credentialId: cid, rawId: rid, attestationObject: att, clientDataJSON: clidata, authenticatorCode: "face") { code, message, res in
}

¶ 服务端验证 WebAuthn 认证请求凭证

func webauthnAuthentication(ticket: String, credentialId: String, rawId: String, authenticatorData: String, userHandle: String, clientDataJSON: String, signature: String, completion: @escaping(Int, String?, NSDictionary?) -> Void)

参数

  • ticket 从 获取 WebAuthn 认证请求初始化参数接口 获得的 ticket
  • credentialId Base64URL 编码的凭证 ID
  • rawId Base64URL 原始凭证 ID
  • authenticatorData 认证器信息,包含认证状态、签名计数等
  • userHandle 创建凭证时的用户 ID
  • clientDataJSON 客户端数据,包含 origin(即凭证请求来源)、挑战码等信息
  • signature 认证器签名

示例

AuthClient().webauthnAuthentication(ticket: ticket, credentialId: cid, rawId: rawId, authenticatorData: attData, userHandle: userHandle, clientDataJSON: clientData, signature: sig) { code, message, res in
}

¶ 删除服务端 WebAuthn 认证请求凭证

func webauthnRemoveCredential(credentialID: String, completion: @escaping(Int, String?, NSDictionary?) -> Void)

参数

  • credentialID Base64URL 编码的凭证 ID

示例

AuthClient().webauthnRemoveCredential(credentialID: cid) { code, message, res in
}

¶ 获取已绑定的凭证列表

func checkWebauthnVaildCredentitals(credentialIds: [String], authenticatorCode: String, completion: @escaping(Int, String?, NSDictionary?) -> Void)

参数

  • credentialIds Base64URL 编码的凭证 ID 的数组
  • authenticatorCode 凭证信息类型:"fingerprint" "face" "other"

示例

AuthClient().checkWebauthnVaildCredentitals(credentialIds: [cid], authenticatorCode: "face") { code, message, res in
}

上一篇: 私有化部署 下一篇: iOS Guard 更新日志
  • 集成 WebAuthn 登录
  • 使用 WebAuthn 登录

用户身份管理

集成第三方登录
手机号闪验 (opens new window)
通用登录表单组件
自定义认证流程

企业内部管理

单点登录
多因素认证
权限管理

开发者

开发文档
框架集成
博客 (opens new window)
GitHub (opens new window)
社区用户中心 (opens new window)

公司

400 888 2106
sales@authing.cn
北京市朝阳区北辰世纪中心 B 座 16 层(总)
成都市高新区天府五街 200 号 1 号楼 B 区 4 楼 406 室(分)

京ICP备19051205号

beian京公网安备 11010802035968号

© 北京蒸汽记忆科技有限公司