OidcClient#
- class ansys.iam.oidc.OidcClient(issuer: str | None = None, audience: str | None = None)#
Bases:
OidcClientBaseOIDC client.
Overview#
Validate the JSON Web Token string. |
|
Not implemented yet… |
|
Retrieve user information, preferring local token claims and falling back to the |
Import detail#
from ansys.iam.oidc import OidcClient
Method detail#
- OidcClient.validate_access_token(value: str) joserfc.jwt.Token#
Validate the JSON Web Token string.
The following validations are performed: exp, nbf, iss and aud.
- Parameters:
- value: str
text of the JWT
- Returns:
TokenThe validated JWT token.
- Raises:
NoIssuerOrAudienceErrorIf the issuer URL or audience is not set.
ValueErrorIf the token is invalid (expired, wrong issuer, wrong audience, not yet valid, etc.).
- OidcClient.get_user_info(access_token: str, fields: list[str] | None = None, *, from_issuer: bool = False) ansys.iam.oidc._userinfo.UserInfo#
Retrieve user information, preferring local token claims and falling back to the OpenID Provider
userinfoendpoint only when required.Workflow:
Decode the access token using the provider JWKS.
If
fieldsisNoneor empty, immediately return aUserInfobuilt from all claims.If
fieldsis provided and every requested field exists and is non-null in the decoded claims, return the locally builtUserInfo.Otherwise perform a network request to the
userinfoendpoint and buildUserInfofrom that response.If
from_issueris True, skip local token claims and perform a network request to theuserinfoendpoint and buildUserInfofrom that response.
Field validation: any element of
fieldsnot matching aUserInfoattribute triggers aValueError.see also: https://openid.net/specs/openid-connect-core-1_0.html#UserInfoResponse
- Parameters:
- Returns:
UserInfoThe user information object derived from local claims or the remote endpoint.
- Raises:
ValueErrorIf any provided field name is invalid.
NoIssuerErrorIf the requested fields are not present in the token and the issuer URL is not set, preventing retrieval from the identity provider.