Skip to content

Conversation

@MODSetter
Copy link
Owner

@MODSetter MODSetter commented Oct 31, 2025

Description

feat: add BACKEND_URL configuration for OAuth redirect

Motivation and Context

To override google oauth redirect.

Screenshots

API Changes

  • This PR includes API changes

Change Type

  • Bug fix
  • New feature
  • Performance improvement
  • Refactoring
  • Documentation
  • Dependency/Build system
  • Breaking change
  • Other (specify):

Testing Performed

  • Tested locally
  • Manual/QA verification

Checklist

  • Follows project coding standards and conventions
  • Documentation updated as needed
  • Dependencies updated as needed
  • No lint/build errors or new warnings
  • All relevant tests are passing

High-level PR Summary

This PR adds a new optional BACKEND_URL environment variable to allow overriding the OAuth redirect URL for Google authentication. When BACKEND_URL is configured, the Google OAuth router uses a custom redirect URL pointing to {BACKEND_URL}/auth/google/callback instead of the default, which is useful for scenarios where the backend needs to force HTTPS redirects or handle proxy/load balancer configurations.

⏱️ Estimated Review Time: 5-15 minutes

💡 Review Order Suggestion
Order File Path
1 surfsense_backend/app/config/__init__.py
2 surfsense_backend/app/app.py

Need help? Join our Discord

Analyze latest changes

- Introduced BACKEND_URL in the configuration to allow overriding the HTTP to HTTPS in the OAuth redirect URI.
- Updated the Google OAuth router to conditionally use the BACKEND_URL for the redirect URI when specified.
@vercel
Copy link

vercel bot commented Oct 31, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
surf-sense-frontend Ready Ready Preview Comment Oct 31, 2025 6:54am

@coderabbitai
Copy link

coderabbitai bot commented Oct 31, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The pull request introduces environment-based configuration for Google OAuth redirect URL handling. A new BACKEND_URL configuration option is added and used to conditionally modify the OAuth router construction, enabling the redirect URI to be dynamically set when the environment variable is present.

Changes

Cohort / File(s) Summary
Configuration
surfsense_backend/app/config/__init__.py
Added BACKEND_URL configuration attribute sourced from environment variable
OAuth Router Setup
surfsense_backend/app/app.py
Google OAuth router construction now branches conditionally: includes redirect_url parameter when BACKEND_URL is set; uses original construction otherwise

Sequence Diagram(s)

sequenceDiagram
    participant Env as Environment
    participant Config as Config Class
    participant App as app.py
    participant Router as OAuth Router
    
    Env->>Config: BACKEND_URL (if present)
    Config->>App: config.BACKEND_URL
    alt BACKEND_URL is set
        App->>Router: Create with redirect_url={BACKEND_URL}/auth/google/callback
    else BACKEND_URL not set
        App->>Router: Create with default is_verified_by_default=True
    end
Loading

Estimated Code Review Effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • The BACKEND_URL addition follows existing configuration patterns
  • Conditional router construction is straightforward and localized to one location
  • No complex logic or multi-file dependencies introduced

Poem

🐰 A backend URL hops into place,
OAuth redirects find their grace,
Configuration branches left and right,
Environment variables set it tight,
Bounce—authentication takes flight!

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5174f21 and 4a3f681.

📒 Files selected for processing (2)
  • surfsense_backend/app/app.py (1 hunks)
  • surfsense_backend/app/config/__init__.py (1 hunks)

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.

@MODSetter MODSetter merged commit 7a0dc0e into main Oct 31, 2025
4 of 8 checks passed
Copy link

@recurseml recurseml bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on 5174f21..4a3f681

✨ No bugs found, your code is sparkling clean

✅ Files analyzed, no issues (2)

surfsense_backend/app/app.py
surfsense_backend/app/config/__init__.py

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.

2 participants