TsgcWSAPIServer_WebAuthnMethods › IsWebAuthnTokenValid

IsWebAuthnTokenValid Method

Checks whether the WebAuthn bearer token supplied by the client is still valid for the given connection.

Overloads

Overload 1

Syntax

function IsWebAuthnTokenValid(aConnection: TsgcWSConnection; aHeaders: TStringList): Boolean;

Parameters

NameTypeDescription
aConnectionTsgcWSConnectionConnection whose authorization token must be checked.
aHeadersTStringListRaw HTTP request headers; the bearer token is extracted from the Authorization header.

Return Value

True when the token is present, well-formed and has not expired; False otherwise. (Boolean)

Remarks

Use this overload from HTTP pipelines where the headers are available. The token is the bearer previously returned to the client by a successful authentication flow (see WebAuthn Authorization).

Example

if not sgcWSAPIServer_WebAuthn1.IsWebAuthnTokenValid(aConnection, aRequestInfo.RawHeaders) then
  aResponseInfo.ResponseNo := 401;

Overload 2

Syntax

function IsWebAuthnTokenValid(aConnection: TsgcWSConnection; aToken: string) : Boolean;

Parameters

NameTypeDescription
aConnectionTsgcWSConnectionConnection whose authorization token must be checked.
aTokenstringBearer token string previously issued by the server during a successful authentication.

Return Value

True when the token is known, bound to the connection and not expired; False otherwise. (Boolean)

Remarks

Use this overload in WebSocket pipelines or whenever the token has already been extracted from the request (for example from a query string parameter or a subprotocol).

Example

if not sgcWSAPIServer_WebAuthn1.IsWebAuthnTokenValid(aConnection, vToken) then
  aConnection.Disconnect;

Back to Methods