Skip to content

xtr_security_openid_connect_server.exception

The errors this package raises, one family under one base.

Every error derives from :class:OpenIdConnectServerError, itself an :class:~xtr_security_oauth2_server_core.exception.OAuth2Error, so one except OAuth2Error still catches anything the authorization server or its identity layer raises.

  • :class:OpenIdConnectServerError — the base of them all.
  • :class:InvalidArgumentError — one of this package's own objects used wrongly, which is a caller's mistake and nobody's answer.
  • :class:InvalidConfigurationError — a deployment's configuration the identity layer cannot be built out of, named setting by setting.
  • :class:UnsupportedAlgorithmError — a signature algorithm that names no digest, so an ID token signed with it can carry no token hash.

InvalidArgumentError

Bases: OpenIdConnectServerError, ValueError

A call into this package was malformed, and no client caused it.

A claim set that names no scope, for one: no grant could ever reveal its claims. The mistake is caught where it is made, when the object is built, rather than surfacing later as claims that silently never appear.

Deliberately not an OAuthServerError: that one is the answer a client gets, and there is no answer to give here, because nothing a client sent caused it. Whoever catches one has a wiring mistake to fix.

Also a :class:ValueError, so code guarding a call with except ValueError keeps working — the same reason the authorization server's error of this name is one.

InvalidConfigurationError

Bases: OpenIdConnectServerError, ValueError

An identity layer cannot be built out of what a deployment configured.

Some of what signing a user in needs only the application can supply: where a signed-in user's claims come from, a login firewall that keeps a session to come back to after a re-login. The bundle builds and boots all the same, so a fresh application still runs its console; this is what the first service needing one of those settings raises, naming the setting and the file it belongs in.

Also raised for a setting that is present but cannot be used, such as an authorization server setting the identity layer relies on that the application changed back after the bundle made it.

Deliberately not an OAuthServerError: no client caused this and no client is waiting for it. Also a :class:ValueError, because a configuration this package cannot read is a bad argument — the same reason the authorization server's error of this name is one.

OpenIdConnectServerError

Bases: OAuth2Error

Base class for every error raised by this package.

Catch this to handle anything the identity layer can go wrong with; catch a subclass to handle one cause.

It derives from the authorization server's own root, :class:~xtr_security_oauth2_server_core.exception.OAuth2Error, because this package is a layer on that server, not a server of its own: one except OAuth2Error keeps catching everything a deployment's authorization server raises, the identity layer included.

UnsupportedAlgorithmError

UnsupportedAlgorithmError(algorithm: str, curve: str | None = None)

Bases: OpenIdConnectServerError

No token hash can be taken for a signature algorithm.

A token hash is the left half of the digest the ID token's algorithm signs with, so a client recomputes it from the alg header — and, for EdDSA, the curve of the key it verified the token with. An algorithm or a curve whose digest cannot be told leaves nothing to recompute it with; guessing one would hand out ID tokens every client rejects, so it is refused here instead, by name, where the deployment that chose it sees it.

Attributes:

  • algorithm –

    The signature algorithm no token hash could be taken for.

  • curve –

    The curve it was asked for over, or None when the algorithm names no digest whatever the curve.

Report that algorithm, over curve when one is named, names no digest.