mirror of
https://github.com/AJaySi/ALwrity.git
synced 2026-04-25 17:05:56 +03:00
[PR #345] [CLOSED] Harden OAuth postMessage origins for GSC and Bing #312
Labels
No labels
AI Content Agents
AI Content Strategy
AI Content planning
AI Marketing Tools
AI SEO
AI personalization
AI writer
ALwrity Copi-lot
Alwrity web search
Anthropic
DeepSeek
Gemini AI
Integration
LLM
OnBoarding
OnBoarding
RAG knowledgebase Memory
bug
documentation
enhancement
good first issue
help wanted
invalid
openai
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/ALwrity#312
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/AJaySi/ALwrity/pull/345
Author: @AJaySi
Created: 2/11/2026
Status: ❌ Closed
Base:
main← Head:codex/replace-wildcard-postmessage-targets📝 Commits (1)
41fc0d9Harden OAuth postMessage origins for GSC and Bing📊 Changes
11 files changed (+236 additions, -34 deletions)
View changed files
📝
backend/routers/bing_oauth.py(+20 -9)📝
backend/routers/gsc_auth.py(+17 -6)📝
backend/services/oauth_redirects.py(+7 -1)📝
frontend/src/api/bingOAuth.ts(+1 -0)📝
frontend/src/api/gsc.ts(+2 -2)📝
frontend/src/components/BingCallbackPage/BingCallbackPage.tsx(+5 -2)📝
frontend/src/components/OnboardingWizard/common/useGSCConnection.ts(+9 -2)📝
frontend/src/components/SEODashboard/components/GSCAuthCallback.tsx(+3 -2)➕
frontend/src/hooks/__tests__/useBingOAuth.postMessage.test.tsx(+97 -0)📝
frontend/src/hooks/useBingOAuth.ts(+13 -10)➕
frontend/src/utils/oauthOrigins.ts(+62 -0)📄 Description
Motivation
postMessagetargets with explicit validated origins derived from provider redirect configuration to prevent spoofed OAuth popup messages.sourcechecks in message listeners and add integration-level checks to reject untrusted messages.Description
get_trusted_origins_for_redirectinbackend/services/oauth_redirects.pyand updated GSC/Bing auth endpoints to returntrusted_originsinstead of relying on'*'for callbacks.postMessagetargets inbackend/routers/gsc_auth.pyandbackend/routers/bing_oauth.pywith validated redirect-origin values and used those origins when emitting success/error messages from callback HTML.frontend/src/utils/oauthOrigins.tsto centralize storing/resolving OAuth postMessage targets and to provideisTrustedOAuthMessageEventfor strict origin+source validation.frontend/src/hooks/useBingOAuth.ts,frontend/src/components/OnboardingWizard/common/useGSCConnection.ts,frontend/src/components/SEODashboard/components/GSCAuthCallback.tsx, andfrontend/src/components/BingCallbackPage/BingCallbackPage.tsxnow send messages to explicit origins and require trusted origin+popup source before acting.trusted_origins(frontend/src/api/bingOAuth.tsandfrontend/src/api/gsc.ts) and added an integration-style testfrontend/src/hooks/__tests__/useBingOAuth.postMessage.test.tsxthat verifies rejection of untrusted-origin messages and acceptance of trusted-origin + popup-source messages.Testing
python -m py_compile backend/routers/gsc_auth.py backend/routers/bing_oauth.py backend/services/oauth_redirects.pyand it succeeded.src/hooks/__tests__/useBingOAuth.postMessage.test.tsx) that simulates popup messaging and verifies the trust checks, but runningnpm test -- --watch=false --runInBand src/hooks/__tests__/useBingOAuth.postMessage.test.tsxfailed in this environment becausereact-scriptsis not installed.Codex Task
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.