TsgcWebSocketHTTPServer › Events › OnUnknownAuthentication
Fires when authentication is enabled and the authentication method is not recognized by the server.
public event TsgcWSUnknownAuthenticationEventHandler OnUnknownAuthentication;
// delegate void TsgcWSUnknownAuthenticationEventHandler(TsgcWSConnection Connection, string AuthType, string AuthData, out string aUser, out string aPassword, out bool Authenticated)
—
OnUnknownAuthentication is raised when the client presents an Authorization header that does not match one of the built-in schemes (Basic, Session, URL), for example a JWT Bearer token or a custom scheme. The AuthType parameter contains the scheme name and AuthData contains the raw credentials sent by the client; the application can parse them, populate the aUser and aPassword output parameters (so the session is tagged with a username), and finally set Authenticated to True to accept the connection or to False to reject it. Applies to both WebSocket upgrades and HTTP requests when Authentication.Enabled is True.
void OnUnknownAuthenticationEvent(TsgcWSConnection Connection, string AuthType, string AuthData,
ref string User, ref string Password, ref bool Authenticated)
{
if (AuthType == "Bearer")
{
if (AuthData == "jwt_token")
Authenticated = true;
else
Authenticated = false;
}
else
Authenticated = false;
}