WebAuthn 身份验证允许用户使用之前注册的公钥凭据登录。它涉及使用用户注册时存储的公钥对已签名的质询进行验证。
身份验证选项
身份验证需要客户端通过向 TsgcWSAPIServer_WebAuthn 服务器中配置的身份验证选项端点发送新的 HTTP 请求来启动身份验证流程。默认情况下,该端点为 /sgcWebAuthn/Authentication/Options,因此,如果您的服务器监听的域名为 https://www.test.com,则客户端应向 https://www.test.com/sgcWebAuthn/Authentication/Options 发送新请求。
客户端通过 POST 将断言(认证响应)发送到服务器
{"username":"test","user_verification":"preferred"}
服务器生成 PublicKeyCredentialRequestOptions
{
"challenge": "9d0d61edf30b45f8b88aef7087f9117716e2b7d8b0ee4460b06142f39dd0ec9f",
"timeout": 60000,
"rpId": "localhost",
"allowCredentials": [
{
"id": "yeA4BVRlrAfLG-KzqsL_rlI4ffhuKHK8uoEkVoab065UkS82Zqlh9VFQHIYwOuOo",
"type": "public-key",
"transports": [
"nfc",
"usb"
]
}
],
"userVerification": "preferred",
"hints": [],
"attestation": "none",
"attestationFormats": [],
"extensions": {}
}
身份验证验证
身份验证要求客户端通过向 TsgcWSAPIServer_WebAuthn 服务器中配置的 身份验证验证端点发起新的 HTTP 请求来启动身份验证流程。默认端点为 /sgcWebAuthn/Authentication/Verify,因此如果您的服务器监听域名 https://www.test.com,则客户端应向 URL https://www.test.com/sgcWebAuthn/Authentication/Verify 发起新请求。
浏览器提示用户使用其身份验证器(例如指纹识别、YubiKey)。身份验证器使用与凭据 ID 关联的私钥对挑战进行签名。返回的凭据包括:
请参阅以下客户端请求的 JSON 示例:
{
"id": "yeA4BVRlrAfLG-KzqsL_rlI4ffhuKHK8uoEkVoab065UkS82Zqlh9VFQHIYwOuOo",
"rawId": "yeA4BVRlrAfLG-KzqsL_rlI4ffhuKHK8uoEkVoab065UkS82Zqlh9VFQHIYwOuOo",
"response": {
"authenticatorData": "SZYN5YgOjGh0NBcPZHZgW4_krrmihjLHmVzzuoMdl2MFAAAABw",
"clientDataJSON": "eyJ0eXBlIjoid2ViYXV0aG4uZ.....",
"signature": "MEQCIAJRqvvys8....",
"userHandle": "36b9d6a84204487382fee62e7e67a80d"
},
"type": "public-key",
"clientExtensionResults": {},
"authenticatorAttachment": "cross-platform"
}
服务器读取来自客户端的请求,验证凭据已存储,并验证签名。如果签名有效,则调用事件 OnWebAuthnAuthenticationSuccessful。
通过以下链接获取有关身份验证流程的更多信息: