TsgcWSAPIServer_WebAuthn › 方法 › IsWebAuthnTokenValid
检查客户端提供的 WebAuthn Bearer 令牌对于给定连接是否仍然有效。
function IsWebAuthnTokenValid(aConnection: TsgcWSConnection; aHeaders: TStringList): Boolean;
| 名称 | 类型 | 描述 |
|---|---|---|
aConnection | TsgcWSConnection | 需要检查其授权令牌的连接。 |
aHeaders | TStringList | 原始 HTTP 请求标头;Bearer 令牌从 Authorization 标头中提取。 |
当令牌存在、格式正确且未过期时返回 True;否则返回 False。(Boolean)
在 HTTP 管道中使用此重载,请求头在此可用。令牌是在成功的认证流程中之前返回给客户端的 bearer 令牌(参见 WebAuthn 授权)。
if not sgcWSAPIServer_WebAuthn1.IsWebAuthnTokenValid(aConnection, aRequestInfo.RawHeaders) then
aResponseInfo.ResponseNo := 401;
function IsWebAuthnTokenValid(aConnection: TsgcWSConnection; aToken: string) : Boolean;
| 名称 | 类型 | 描述 |
|---|---|---|
aConnection | TsgcWSConnection | 需要检查其授权令牌的连接。 |
aToken | string | 服务器在身份验证成功后签发的 Bearer 令牌字符串。 |
True 表示令牌已知、与连接绑定且未过期;否则为 False。(Boolean)
在 WebSocket 管道中或令牌已从请求中提取时(例如从查询字符串参数或子协议中)使用此重载。
if not sgcWSAPIServer_WebAuthn1.IsWebAuthnTokenValid(aConnection, vToken) then
aConnection.Disconnect;