Skip to content

fix(ema): allow a public resource-AS client in leg 3 - #2736

Merged
cliffhall merged 1 commit into
v2/mainfrom
v2/fix/2725-ema-public-resource-client
Oct 20, 2026
Merged

cliffhall merged 1 commit into
v2/mainfrom
v2/fix/2725-ema-public-resource-client

Conversation

@cliffhall

Copy link
Copy Markdown
Member

Closes #2725

Problem

mintEmaResourceTokens (core/auth/ema/emaFlow.ts) threw before leg 2 unless resourceClientSecret was non-empty. But redeemIdJagForAccessToken, which runs leg 3, already redeems a public client: it sends token_endpoint_auth_method: "none" and no client_secret when no secret is given. So a resource AS that registers clients as public (for example one that forces none at DCR) couldn't be used with EMA. The error also pointed users at xaa.dev.

Change

  • core/auth/ema/emaFlow.ts: removed the secret guard and kept the resourceClientId check. An empty secret now goes down the existing none path.
  • Server Settings: with EMA on, the Resource AS Client Secret field now has its own description saying it can stay empty for a public client (token_endpoint_auth_method "none"). The Client ID field's description is unchanged.

Tests

  • New: with an empty secret, the leg-3 token request has client_id in the body, no client_secret, and no Authorization header.
  • The test for the old secret error now checks the clientId error instead. Two other tests used an empty secret only to make the mint fail; they now use an empty clientId.
  • New: when the context has no resourceUrl, leg 2 sends the PRM resource and leg 3 sends none. This branch was never covered. Deleting the guard took a covered branch out of emaFlow.ts, which dropped the file to 88.88% branch coverage. With this test it is at 94.44%.
  • Form test: the "Leave it empty for a public client" hint appears exactly once, on the secret field.

npm run local:gate passes.

Screenshots

Server Settings → OAuth Settings, with Enterprise-managed authorization turned on (1280×900).

Before After
before after

🤖 Generated with Claude Code

mintEmaResourceTokens refused to run without a resource-AS client
secret, although redeemIdJagForAccessToken already redeems a public
client with token_endpoint_auth_method "none". Drop the secret guard
and keep the clientId check, so a resource AS that registers public
clients works with EMA.

The Resource AS Client Secret field now says it may stay empty for a
public client. Tests cover the secretless leg-3 request (client_id in
the body, no client_secret, no Authorization header), and the tests
that used an empty secret to force a mint failure now use an empty
clientId.

Closes #2725

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Signed-off-by: cliffhall <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused fix reuses existing public-client support, preserves client-ID validation, and includes relevant regression coverage with no identified blockers.

No open issues 🎉

What changed in this PR

Enables public resource-AS clients in EMA by allowing leg 3 to proceed without a client secret, addressing #2725.

Changes:

  • Removes the secret requirement while retaining client-ID validation.
  • Clarifies that public clients can leave the secret field empty.
  • Adds regression coverage for public-client requests and resource fallback behavior.
File Description
core/​auth/​ema/​emaFlow.ts Removes the client-secret guard.
clients/​web/​src/​test/​core/​auth/​ema/​emaFlow.test.ts Covers public-client redemption and resource fallback.
clients/​web/​src/​components/​groups/​ServerSettingsForm/​ServerSettingsForm.tsx Adds public-client guidance to the secret field.
clients/​web/​src/​components/​groups/​ServerSettingsForm/​ServerSettingsForm.test.tsx Checks that the new hint appears once.

Review effort: Balanced

@cliffhall

Copy link
Copy Markdown
Member Author

Copilot review loop closed: round 1 came back clean (no inline comments, "No open issues", nothing in a Suppressed comments block), so no further rounds were requested.

@cliffhall
cliffhall merged commit 5642739 into v2/main Oct 20, 2026
8 checks passed
@cliffhall
cliffhall deleted the v2/fix/2725-ema-public-resource-client branch October 20, 2026 03:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v2 Issues and PRs for v2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EMA leg 3 requires a resource-AS client secret, which blocks public clients the redeem already supports

2 participants