OidcWebSocketDependency#
- class ansys.iam.oidc.OidcWebSocketDependency(oidc_issuer: str | None = None, audience: str | None = None, subprotocol_prefix: str = DEFAULT_SUBPROTOCOL_PREFIX, *, auto_error: bool = True)#
Bases:
OidcDependencyFastAPI dependency class for OpenID Connect (OIDC) access token validation for WebSocket connections.
It’s expected that the token is found, base64-encoded, as a subprotocol of the WebSocket, followed by a given prefix. For example, if the prefix is saf.auth.bearer., the subprotocol should be saf.auth.bearer.
. Use ansys.iam.oidc.encode_base64_tokento encode the token.
Overview#
Extract and validate the access token from the WebSocket subprotocol. |
Import detail#
from ansys.iam.oidc import OidcWebSocketDependency
Method detail#
- async OidcWebSocketDependency.__call__(websocket: fastapi.WebSocket) str | None#
Extract and validate the access token from the WebSocket subprotocol.
- Parameters:
- websocket
WebSocket The WebSocket connection object.
- websocket
- Returns:
- Raises:
WebSocketExceptionIf auto_error is True and authentication fails (missing token, invalid encoding, or token validation fails).