TsgcWSAPIServer_WebAuthnMethods › AddCredential

AddCredential Method

Registers an existing credential in the server credential store so the user can authenticate later.

Overloads

Overload 1

Syntax

procedure AddCredential(const aCredential : TsgcWebAuthn_CredentialRecord);

Parameters

NameTypeDescription
aCredentialconst TsgcWebAuthn_CredentialRecordRecord that holds the user identifier, credential id, public key, sign counter and attestation data returned by the authenticator.

Remarks

Use this overload to restore credentials previously persisted by the application (for example from a database) into the in-memory store used by the Relying Party, typically during server startup.

Example

var
  oCred: TsgcWebAuthn_CredentialRecord;
begin
  oCred.UserId     := 'user@test.com';
  oCred.CredId     := vCredentialIdFromDB;
  oCred.PublicKey  := vPublicKeyFromDB;
  oCred.SignCount  := 0;
  sgcWSAPIServer_WebAuthn1.AddCredential(oCred);
end;

Overload 2

Syntax

procedure AddCredential(const aJSON: string);

Parameters

NameTypeDescription
aJSONconst stringJSON string that describes the credential (user id, credential id, public key, sign counter) as serialized by a previous registration.

Remarks

This overload is a convenience when credentials are stored as JSON blobs. The JSON is parsed internally and converted to a TsgcWebAuthn_CredentialRecord before being added to the store.

Example

sgcWSAPIServer_WebAuthn1.AddCredential(vJSONFromDB);

Back to Methods