Skip to content

Resource indicators audience policy - #123

Open
lionick wants to merge 18 commits into
IdentityPython:mainfrom
lionick:resource-indicators-audience-policy
Open

lionick wants to merge 18 commits into
IdentityPython:mainfrom
lionick:resource-indicators-audience-policy

Conversation

@lionick

@lionick lionick commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@c00kiemon5ter

Copy link
Copy Markdown
Member

The CI is failing due to missing or moved vars from the cryptography package.
We should check the changes introduced by version 47 and align with cryptojwt.

@c00kiemon5ter

c00kiemon5ter commented Sep 17, 2026 •

Copy link
Copy Markdown
Member

The issue comes from the combination of the cryptojwt and cryptography versions installed.
cryptography has removed support for certain curves. See the changelog for v47.0.0

https://cryptography.io/en/latest/changelog/#v47-0-0

BACKWARDS INCOMPATIBLE: Support for binary elliptic curves (SECT* classes) has been removed. These curves are rarely used and have additional security considerations that make them undesirable.

and the fix that is included in the latest (v1.11.0) cryptojwt version:

https://github.com/IdentityPython/JWTConnect-Python-CryptoJWT/pull/194/changes

@lionick

lionick commented Sep 18, 2026

Copy link
Copy Markdown
Contributor Author

However, v1.11.0 declares requires-python: >=3.10 — there's no released cryptojwt version that has this fix and still supports 3.8/3.9 (v1.10.0, the last one that does, predates the fix).

So picking up the fix means bumping to cryptojwt>=1.11.0 and dropping Python 3.8/3.9 from this repo's CI matrix — which lines up with both already being past their own upstream EOL.

@c00kiemon5ter

Copy link
Copy Markdown
Member

I think we can drop both Python versions (3.8 and 3.9).
3.9 reached end-of-life on 2025-10-31.

@lionick
lionick force-pushed the resource-indicators-audience-policy branch from 2bd72f9 to 9de42d2 Compare October 2, 2026 08:58
@lionick
lionick marked this pull request as ready for review October 2, 2026 09:11
PeterBolha and others added 12 commits November 16, 2026 11:25
Signed-off-by: Ivan Kanakarakis <ivan.kanak@gmail.com>
Signed-off-by: Ivan Kanakarakis <ivan.kanak@gmail.com>
Add RFC 8707 resource indicator support across the authorization,
access_token and client_credentials endpoints: an opt-in
enable_resource_indicators flag, per-endpoint and per-client
resource_indicators policy configuration, and the
validate_resource_indicators_policy default policy function.
…ce policies

Add the enable_audience_policies/audience_policies hook used across
authorization, token and introspection endpoints to compute or
restrict the final aud beyond what resource indicators alone
determine. Also repairs the test suite broken by this and the
preceding resource-indicators commit (bumps requirements-dev.txt,
adjusts client_credentials.py and introspection.py).
A client's add_claims.always/by_scope entries could be explicit None
rather than absent, which .get(key, {}) doesn't treat as missing.
…ement

id_token minting was deleting client_id from kwargs before building
the token payload. Keep it, and align introspection's audience
enforcement check accordingly.
…tion

Previously the client_id-presence check only ran in the elif branch,
so it was skipped entirely whenever authn_info was empty and no
client_authn_method was configured for the endpoint - silently
accepting an authentication result with no client_id. Run it
unconditionally instead.
@lionick
lionick force-pushed the resource-indicators-audience-policy branch 3 times, most recently from ea4676c to 093e6ec Compare November 17, 2026 07:16
…dicator applies

RFC 9068 Section 3 requires a default resource indicator in aud when
no "resource" parameter is sent - client_credentials was omitting
aud entirely in that case, and separately leaking an unvalidated
"resource" value into aud whenever resource indicators were disabled.

Both fixed: fall back to [client_id] when nothing trusted a resource
into the token, and only trust "resource" into aud when something
actually had the chance to validate or reject it - either
resource_indicators, or an audience policy. Trusting it is not the
same as deleting it from the request: an audience-policy function may
read request.get("resource") directly (rather than the "audience"
argument it's also given), so the field has to stay visible to it even
when resource_indicators itself is off.

Also repairs test coverage: one test was parametrized over resource
values it never actually sent, and two scenarios (no configuration at
all, requesting self or self+unknown) had no test at all.
No functional change - every other client id in this file uses the
"client_N" form; these bare "clientN" spellings were inconsistent.
Each docstring states the resource-indicators config in play and what
the client requests, so the expected aud/error is readable without
cross-referencing anything outside this file.
Two bugs combined to drop aud on cross-client token exchange: the
helper never fell back to a default resource indicator (same gap as
client_credentials, fixed the same way), and
ExchangeGrant.payload_arguments computed the right aud from the
minted token's own resources, then two lines later unconditionally
replaced it with the grant's own (always-empty) resources, discarding
it regardless of what the first fix set. Removing just the overwrite
keeps the aud the existing code already computes correctly.
@lionick
lionick force-pushed the resource-indicators-audience-policy branch from 093e6ec to dcd390b Compare November 17, 2026 07:24
The existing docs were stale and incomplete in several ways:
- used "callable" as the policy key; the code has always read "function"
- never mentioned enable_resource_indicators, without which the feature
  is a silent no-op regardless of "resource_indicators" config
- never mentioned client_credentials/token_exchange support
- the per-client example nested the policy under "authorization_code"/
  "access_token" keys, which no current code path reads - every helper
  reads cdb[client]["resource_indicators"] flat
- audience_policies/enable_audience_policies didn't exist in the docs at all,
  including no explanation of its policy function's arguments, its
  return-value contract (ignored, unlike a resource-indicators policy
  function), or a worked example of either restricting or computing the
  audience
- the audience argument's per-endpoint source (and that it's read-only,
  not a write target) wasn't documented either
- said nothing about the default aud (RFC 9068 Section 3 MUST)
- the resource-indicators policy function example had no prose explaining
  its arguments, what it may mutate, or what its two possible return
  shapes mean
- clients.rst didn't say who sets enable_resource_indicators or where,
  reading like a per-client setting when it's a one-time, server-wide
  endpoint setting, and described the per-client resource_indicators
  shape by contrast with a since-removed wrong version instead of plainly

Rewritten in doc/server/contents/conf.rst and clients.rst to match the
files' actual heading hierarchy and document what the code currently
does.
@lionick
lionick force-pushed the resource-indicators-audience-policy branch from 3038665 to ab37e5e Compare November 17, 2026 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants