mirror of
https://github.com/AJaySi/ALwrity.git
synced 2026-04-25 17:05:56 +03:00
[PR #346] [MERGED] Harden GSC OAuth callback state validation #311
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#311
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/346
Author: @AJaySi
Created: 2/11/2026
Status: ✅ Merged
Merged: 2/11/2026
Merged by: @AJaySi
Base:
main← Head:codex/harden-gscservice-handle_oauth_callback📝 Commits (1)
6929ea1Harden GSC OAuth callback state validation📊 Changes
2 files changed (+183 additions, -37 deletions)
View changed files
➕
backend/services/gsc_oauth_state_validation_tests.py(+149 -0)📝
backend/services/gsc_service.py(+34 -37)📄 Description
Motivation
Description
expires_atcolumn to thegsc_oauth_statestable and ensured the column is created/altered during table initialization, with a default 20-minute TTL. (backend/services/gsc_service.py)expires_atwhen issuing a new state and update it on conflict so each state has a time-to-live. (backend/services/gsc_service.py)handle_oauth_callbackto: immediately reject a missingstate; atomically consume only an exact, non-expired state usingDELETE ... RETURNING user_id; detect and return explicit errors for expired or not-found/reused states; and removed prior fallback branches that returned recent credentials or used the most recent state. (backend/services/gsc_service.py)backend/services/gsc_oauth_state_validation_tests.py)Testing
backend/services/gsc_oauth_state_validation_tests.pycovering the invalid-state, reused-state, expired-state, and cross-user mismatch cases and ran the tests successfully. The test command used wasPYTHONPATH=backend pytest -q backend/services/gsc_oauth_state_validation_tests.py. All tests passed.Codex Task
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.