Allow OAuth provider hosts in CSP form-action#28
Merged
Conversation
The CSP's form-action directive is `'self'` only, which blocks the
302 redirect from /connections/{id}/reauth (and similar OAuth-install
flows) to accounts.google.com / slack.com / github.com. The browser
reports:
Sending form data to '...' violates the following Content Security
Policy directive: "form-action 'self'". The request has been blocked.
…and the operator sees nothing happen on click. form-action covers
both the initial POST target AND any redirects from that submission,
so same-origin POST → cross-origin 302 hits the directive even though
the POST itself is same-origin.
Add the three OAuth-provider hosts to form-action and pin them with
TestCSPAllowsTemplateCDNs. The list is intentionally minimal — a
future connector that posts to a new OAuth host will need this
directive updated.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the admin UI Content Security Policy (CSP) to allow OAuth provider origins in the form-action directive so form submissions that receive cross-origin 302 redirects (e.g., /connections/{id}/reauth → accounts.google.com) are not blocked by the browser.
Changes:
- Extend CSP
form-actionto include Google, Slack, and GitHub OAuth/provider hosts. - Add test assertions to ensure these hosts remain allowlisted under
form-actiongoing forward.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
internal/web/headers.go |
Adds an oauthHosts allowlist and appends it to the CSP form-action directive. |
internal/web/csp_test.go |
Extends the CSP regression test to require the OAuth provider hosts under form-action. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Operator clicks Re-authenticate on a Gmail connection and nothing happens. The browser console reports:
Root cause: CSP's
form-action 'self'covers both the initial form target AND any redirects from that submission. The POST to/connections/{id}/reauthis same-origin (allowed), but the 302 →accounts.google.comis cross-origin (blocked). Same issue applies to Slack OAuth (slack.com) and the GitHub App manifest/install flows (github.com).Fix
Extend
form-actionto include the three OAuth-provider hosts. Pin them withTestCSPAllowsTemplateCDNsso a future tightening that drops one will fail loudly.Risk
Minimal.
form-actiononly constrains where forms can submit; the addition is exactly the set the existing OAuth flows already need. A future connector that posts to a new OAuth host will need this directive extended — explicitly noted in the directive's comment.Test plan
reauth_required→ browser navigates toaccounts.google.com/o/oauth2/...instead of being blocked.🤖 Generated with Claude Code