TsgcWSAPIServer_WebAuthn › 方法 › AddCredential
在服务器凭据存储中注册现有凭据,以便用户后续进行身份验证。
procedure AddCredential(const aCredential : TsgcWebAuthn_CredentialRecord);
| 名称 | 类型 | 描述 |
|---|---|---|
aCredential | const TsgcWebAuthn_CredentialRecord | 该记录保存由验证器返回的用户标识符、凭据 ID、公钥、签名计数器和证明数据。 |
使用此重载将应用程序之前持久化的凭据(例如从数据库)恢复到依赖方使用的内存存储中,通常在服务器启动时进行。
var
oCred: TsgcWebAuthn_CredentialRecord;
begin
oCred.UserId := 'user@test.com';
oCred.CredId := vCredentialIdFromDB;
oCred.PublicKey := vPublicKeyFromDB;
oCred.SignCount := 0;
sgcWSAPIServer_WebAuthn1.AddCredential(oCred);
end;
procedure AddCredential(const aJSON: string);
| 名称 | 类型 | 描述 |
|---|---|---|
aJSON | const string | 描述凭证(用户 ID、凭证 ID、公钥、签名计数器)的 JSON 字符串,由上次注册时序列化。 |
当凭据以 JSON blob 形式存储时,此重载非常方便。JSON 在内部解析并转换为 TsgcWebAuthn_CredentialRecord,然后添加到存储中。
sgcWSAPIServer_WebAuthn1.AddCredential(vJSONFromDB);