Skip to content

fix(oauth): upstream PKCE check off only when exemptions are configured (#884 follow-up) - #888

Open
keysersoft wants to merge 1 commit into
mainfrom
keysersoft/copilot-studio-pkce-lib
Open

keysersoft wants to merge 1 commit into
mainfrom
keysersoft/copilot-studio-pkce-lib

Conversation

@keysersoft

Copy link
Copy Markdown
Contributor

#884 is live but did not take effect: @rekog/mcp-nest-auth enforces PKCE on its own (requirePkce defaults to true, no per-client exception). Live check after the 755e30c deploy: the listed Copilot Studio client passed our middleware and was then redirected with invalid_request: code_challenge is required by upstream.

  • requirePkce: !pkceExemptionsConfigured() in McpAuthModule.forRoot. With an empty OAUTH_PKCE_EXEMPT_CLIENT_IDS (self-host default) nothing changes, and upstream still enforces PKCE.
  • With a list, AuthorizePkceMiddleware is the single gate on /authorize. It already requires S256 with a valid challenge shape from every client, and exempts only listed clients registered as confidential with a stored secret. Codes without a challenge can therefore only be issued to those clients. At /token, upstream still validates any challenge that was sent and still requires the client secret.
  • pkceExemptClientIds() / pkceExemptionsConfigured() are shared by the module and the middleware, so both read the list the same way.
  • Upstream logs a startup warning when requirePkce is false. That is expected on the cloud while the Copilot Studio client is listed.

Tests: authorize-pkce spec 20/20; auth + mcp-server + connectors 1466 passed.

…nfigured

@rekog/mcp-nest-auth enforces PKCE itself (requirePkce defaults to true)
and has no per-client exception, so the OAUTH_PKCE_EXEMPT_CLIENT_IDS
exemption from #884 passed AuthorizePkceMiddleware and was then refused
upstream. When at least one exempt client is listed, upstream's check is
switched off and AuthorizePkceMiddleware is the single enforcement point:
S256 for every other client, exemption only for listed confidential
clients. With no list, upstream keeps enforcing PKCE as before.
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.

1 participant