OidcDependency#

class ansys.iam.oidc.OidcDependency(oidc_issuer: str | None = None, audience: str | None = None, *, auto_error: bool = True)#

Bases: fastapi.security.OpenIdConnect

FastAPI dependency class for OpenID Connect (OIDC) access token validation.

Overview#

async_client

Get the asynchronous OIDC client.

client

Get a synchronous OIDC client.

__call__

Extract and validate the access token from the HTTP request.

Import detail#

from ansys.iam.oidc import OidcDependency

Property detail#

property OidcDependency.async_client: ansys.iam.oidc._client.AsyncOidcClient#

Get the asynchronous OIDC client.

Returns:
AsyncOidcClient

The asynchronous OIDC client instance.

property OidcDependency.client: ansys.iam.oidc._client.OidcClient#

Get a synchronous OIDC client.

Returns:
OidcClient

A new synchronous OIDC client instance.

Method detail#

async OidcDependency.__call__(request: starlette.requests.Request) → str | None#

Extract and validate the access token from the HTTP request.

Parameters:
requestRequest

The incoming HTTP request.

Returns:
str | None

If authentication is mandatory, the access token if present and valid. If authentication is optional, the access token if present, otherwise None.

Raises:
HTTPException

If auto_error is True and authentication fails (missing token, invalid scheme, or token validation fails).