Repository navigation
Description
Part of #14
What is wrong: cmapi decides that a token is an access token from Keycloak's typ claim in the payload (Bearer). It does not read the typ of the JOSE header. RFC 9068 (JWT Profile for OAuth 2.0 Access Tokens), section 4: the resource server "MUST verify that the "typ" header value is "at+jwt" or "application/at+jwt"" and must "reject tokens carrying any other value". A token with no typ claim passes today's check.
Where: cmapi/src/cmapi/core/auth.py:168-170 on b83391c: if claims.get("typ") not in (None, "Bearer").
How to prove it: A test signs a token that has the right issuer, audience and key, and no typ claim, as an ID token of another issuer profile can have. Today Authenticator.authenticate accepts it. After the fix the token is refused with 401, or the pull request shows why cmapi cannot ask for more from Keycloak and what else stops an ID token (the audience check).
Measured or inferred: Read from the code on 2026-11-13. Not tested against a real Keycloak token: realm cmapi is not on CRC yet. The contracts review of diagram-kit PR 64 found it.
Severity: Medium, until the research says what Keycloak 26 puts in the header.
What must hold after the fix: cmapi refuses a token that is not an access token, by a rule that is written down with its source. Where cmapi differs from RFC 9068, docs/14 says so and why.
Research: Mandate, before the code: (1) what typ RHBK 26.6 puts in the JOSE header of an access token (historically JWT, with typ: Bearer in the payload), and whether a realm or client setting makes it at+jwt. Read the Keycloak source or its documents for 26.x, and measure a token from the realm test of deploy/tests/realm-test.py when containers are permitted again (#157). (2) RFC 9068 section 4 and RFC 8725 section 3.11 (explicit typing). (3) What stops an ID token today: its audience is the client, not cmapi-<instance>. Options: require the claim typ to be Bearer (no None), accept the header at+jwt also, or make the accepted values configuration of the Authenticator in instance.yaml.
Solution (inline, not applied): Not written here.
Class: INV. The fix adds a check to the token verification.
Activity
Records at 22:15Z: #143, #179, #183, #178 merged; #181, #185, #186 in…
ephico2real2 commentedon Nov 13, 2026
In-Progress: draft pull request for branch
access-token-type. Built: the header check, the legacy setting, the client attribute in the realm files and in the sync, the tests and the documents. The service suite passes natively (637 passed). Codex reviewed seven claims: four confirmed, and five findings (C4, C5, C7, E1, E2) wait for a ruling and their fixes. The realm test on a real Keycloak runs in GitHub'smanifestsjob.The review of #184: the sync types a client with an optional scope, t…
The record of #184's review: each of Codex's findings ruled, with its…
ephico2real2 commentedon Nov 13, 2026
Done: pull request #195 merged to
main(9a5a9d6). GitHub Actions run 43521078691 was green on the exact head079ecf4(six jobs). The realm test on a real Keycloak passed in themanifestsjob (realm cases failed: 0): the access token ofcmapi-docs,cmapi-automationandsvc-payments-cihas the headertyp: at+jwt, the token ofcmapi-directoryhasJWT, and the sync puts the attribute back on a realm that has it off. Native on macOS: the service suite 690 passed, and Codex's 36 review cases pass (6 failed before the fixes). Review by Codexgpt-6.1-sol, each finding ruled indocs/reviews/2026-11-13-issue-184/README.md. Not measured: a token exchange (C4 is from Keycloak's source), and anything on CRC: realmcmapiis not there.