Skip to content

feat(security): standardize security headers and CORS policy#860

Open
Exodus2004 wants to merge 31 commits into
ritesh-1918:gssocfrom
Exodus2004:fix/issue-637-security-headers-cors
Open

feat(security): standardize security headers and CORS policy#860
Exodus2004 wants to merge 31 commits into
ritesh-1918:gssocfrom
Exodus2004:fix/issue-637-security-headers-cors

Conversation

@Exodus2004
Copy link
Copy Markdown

Closes #637

Proposed Solution Approach

Instead of disparate and conflicting middleware blocks, I've implemented a centralized security configuration in \�ackend/security_config.py.

Why this approach is better:

  1. Consolidation: Removed 3 redundant security header blocks and 2 CORS middleware registrations that were causing configuration drift and potential bypasses.
  2. Standardization: Enforced strict, production-ready security headers (CSP, HSTS, X-Frame-Options, etc.) that match modern Helmet.js standards.
  3. Environment Flexibility: CORS origins are now manageable via an environment variable (\CORS_ORIGINS) with safe production defaults, preventing hardcoded local dev leaks in prod.
  4. Maintainability: Decoupled security logic from the main application entry point (\main.py), making it easier to audit and update without cluttering the core API logic.

Implemented consolidated security configuration in security_config.py and cleaned up redundant middleware in main.py. Standardized CSP, HSTS, and strict CORS origins for production readiness. Closes ritesh-1918#637.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 31, 2026

Someone is attempting to deploy a commit to the ritesh Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 31, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f3beae0c-8c1a-4a93-9a4f-7f0dca4759df

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

GSSoC Contributor added 2 commits May 31, 2026 18:44
Added KnowledgeGapService to identify recurring ticket themes with poor Knowledge Base coverage. This allows support teams to proactively documentation missing troubleshooting steps. Closes ritesh-1918#611.
Added SLABreachPredictionService to identify tickets at risk of exceeding SLA deadlines. This allows support managers to prioritize tickets before they breach. Closes ritesh-1918#609.
GSSoC Contributor added 24 commits May 31, 2026 19:12
1. Fixed corrupted App.jsx and normalized route splitting.
2. Fixed duplicated declarations in Login.jsx and missing imports in AdminSidebar.jsx.
3. Fixed missing variables and state management loops in AdminTickets.jsx and AdminHeader.jsx.
4. Corrected backend SyntaxError in classifier_service.py and standardized metrics imports.
5. Resolved serialized variable error in persistenceMiddleware.js.
…ax issues

1. Fixed SyntaxError in classifier_service.py by properly closing try-except blocks.
2. Added missing imports (time, metrics) to classifier_service.py.
3. Resolved ESLint globals and unused variable errors in Cypress tests.
4. Fixed 'Cannot access refs during render' in BackToTop.jsx and useKeyboardShortcuts.js.
5. Fixed undefined 'axios' and unused 'apiClient' in TicketTracking.jsx.
6. Synchronized package-lock.json.
1. Fixed SyntaxError in classifier_service.py by properly nesting try-except-finally blocks.
2. Exported missing SHORTCUTS_LEGEND from useKeyboardShortcuts.js.
3. Synchronized package-lock.json.
1. Wrapped torch import in DuplicateService with try-except for CI compatibility.
2. Added missing numpy and threading imports to DuplicateService.
3. Fixed SyntaxError in ClassifierService.
Wrapped google.generativeai import in tag_service.py with try-except to prevent ModuleNotFoundError in CI smoke tests.
Removed invalid 'buckets' argument from request_size and response_size metric calls in main.py to fix TypeError in production environment.
Added missing 'Header' import in main.py to fix NameError in metrics verification function.
The slowapi limiter requires a 'request' argument to be present in the decorated function. Added 'request: Request' to analyze_stream.
GSSoC Contributor added 4 commits May 31, 2026 20:15
1. Added missing 'request: Request' argument to analyze_stream to satisfy slowapi requirement.
2. Removed duplicate /metrics route registration.
3. Cleaned up redundant imports and code blocks.
…instrumentator

1. Consolidated Instrumentator initialization into a single block.
2. Removed duplicate /metrics route registration.
3. Removed redundant expose() call from instrumentator.
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