Skip to content

Bypass non-OIDC requests in the service worker#1663

Merged
guillaume-chervet merged 4 commits into
mainfrom
copilot/bypass-non-oidc-requests
May 14, 2026
Merged

Bypass non-OIDC requests in the service worker#1663
guillaume-chervet merged 4 commits into
mainfrom
copilot/bypass-non-oidc-requests

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 13, 2026

ServiceWorker-handled fetches can retain stale CSP behavior for the worker lifetime and add noise by proxying unrelated requests. This adds an opt-in bypass so OIDC server and access-token target traffic continue through the worker while unrelated requests are handled by the browser.

  • Configuration

    • Adds bypassAllNonOidcRequests to trusted domain object configuration.
    • Defaults to false to preserve existing behavior.
  • Service worker fetch handling

    • When enabled, requests outside OIDC server URLs and configured access-token target domains return without event.respondWith(), letting the browser handle them directly.
    • OIDC server requests are never bypassed, including issuer, authorization, token, revocation, and userinfo URLs.
    • Configured accessTokenDomains requests are not bypassed so access token injection continues to work.
    • domains remains the fallback for access-token target matching when accessTokenDomains is not configured.
    • Bypass only activates after OIDC server configuration is initialized.
  • Tests and docs

    • Adds focused coverage for bypass decisions, OIDC server request preservation, and access-token target domain preservation.
    • Documents the new option in package READMEs and migration guidance.
trustedDomains.default = {
  oidcDomains: ['https://demo.duendesoftware.com'],
  accessTokenDomains: ['https://www.myapi.com/users'],
  bypassAllNonOidcRequests: true,
};

Copilot AI and others added 2 commits May 13, 2026 19:33
Agent-Logs-Url: https://github.com/AxaFrance/oidc-client/sessions/c3807b47-b316-4658-928d-53c56b639eba

Co-authored-by: guillaume-chervet <52236059+guillaume-chervet@users.noreply.github.com>
Agent-Logs-Url: https://github.com/AxaFrance/oidc-client/sessions/c3807b47-b316-4658-928d-53c56b639eba

Co-authored-by: guillaume-chervet <52236059+guillaume-chervet@users.noreply.github.com>
Copilot AI changed the title [WIP] Bypass all non OIDC requests in ServiceWorker Bypass non-OIDC requests in the service worker May 13, 2026
Copilot AI requested a review from guillaume-chervet May 13, 2026 19:37
@guillaume-chervet
Copy link
Copy Markdown
Contributor

@copilot is it possible to intercept also accessTokenDomains request ?

Agent-Logs-Url: https://github.com/AxaFrance/oidc-client/sessions/c87015bc-b866-4c0f-9042-c87efba325fc

Co-authored-by: guillaume-chervet <52236059+guillaume-chervet@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 13, 2026

@copilot is it possible to intercept also accessTokenDomains request ?

Implemented in 2b15bce. With bypassAllNonOidcRequests enabled, configured accessTokenDomains (and domains fallback) are still intercepted so token injection continues to work; only requests outside OIDC and access-token domains are bypassed.

@guillaume-chervet guillaume-chervet marked this pull request as ready for review May 14, 2026 13:59
@guillaume-chervet guillaume-chervet merged commit debafc8 into main May 14, 2026
14 of 16 checks passed
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.

Bypass all non OIDC requests in ServiceWorker

2 participants