Skip to content

feat(auth): hide/show GitHub & Google login (#384) - #492

Closed
grootbro wants to merge 2 commits into
Openpanel-dev:mainfrom
grootbro:feat/hide-show-auth-providers-384
Closed

grootbro wants to merge 2 commits into
Openpanel-dev:mainfrom
grootbro:feat/hide-show-auth-providers-384

Conversation

@grootbro

@grootbro grootbro commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Social login buttons render only when the matching OAuth credentials are set (CLIENT_ID + SECRET + REDIRECT_URI)
  • Optional DISABLE_GITHUB_AUTH / DISABLE_GOOGLE_AUTH to hide login while keeping Google creds for Search Console
  • auth.getOAuthProviders + server-side gate on signInOAuth
  • Docs: self-hosting guide + environment variables for GitHub/Google setup

Fixes #384

Test plan

  • Self-host without OAuth env → login/onboarding show email only (no Or divider)
  • Set GitHub credentials only → GitHub button appears; Google hidden
  • Set DISABLE_GOOGLE_AUTH=true with Google creds → Google button hidden
  • Cloud (both providers configured) → both buttons still show
  • signInOAuth for a disabled provider returns a bad-request error
  • CI: oauth-providers unit tests pass

Made with Cursor

Summary by CodeRabbit

  • New Features

    • GitHub and Google social login are available when each provider’s client ID, client secret, and redirect URI are configured.
    • Login buttons can be hidden per provider with DISABLE_GITHUB_AUTH or DISABLE_GOOGLE_AUTH. Disabled providers also reject sign-in attempts.
    • Google Search Console integration remains available with its required credentials, even when Google login is disabled.
  • Documentation

    • Added self-hosting guidance for social login setup and the related environment variables.

Self-hosters can enable GitHub/Google via env vars (or hide with
DISABLE_*_AUTH). Document setup; login/onboarding follow server flags.
@coderabbitai

coderabbitai Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 65323f48-3999-4b3b-a775-648b19e71643

📥 Commits

Reviewing files that changed from the base of the PR and between 26a1e6b and ab43467.

📒 Files selected for processing (4)
  • apps/public/content/docs/self-hosting/environment-variables.mdx
  • apps/public/content/docs/self-hosting/self-hosting.mdx
  • packages/auth/src/oauth-providers.test.ts
  • packages/trpc/src/routers/auth.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/public/content/docs/self-hosting/self-hosting.mdx

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The auth package now determines whether GitHub and Google login are enabled from their credentials and disable flags. The auth router returns provider availability and rejects sign-in attempts for disabled providers. The self-hosting documentation describes the settings and their effect on Google Search Console.

Changes

OAuth provider availability

Layer / File(s) Summary
Provider configuration and validation
packages/auth/src/oauth-providers.ts, packages/auth/src/index.ts, packages/auth/src/oauth-providers.test.ts
The auth package checks provider credentials and disable flags, exports provider availability helpers, and tests the configuration rules.
Auth provider API and sign-in guard
packages/trpc/src/routers/auth.ts
The router returns enabled-provider status, accepts only Google and GitHub for OAuth sign-in, and rejects sign-in attempts for disabled providers before generating authorization URLs.
Self-hosting OAuth documentation
apps/public/content/docs/self-hosting/environment-variables.mdx, apps/public/content/docs/self-hosting/self-hosting.mdx
The documentation describes the credentials and disable flags for social login, and clarifies that disabling Google login does not disable Google Search Console requirements.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant AuthRouter
  participant ProviderHelpers
  participant Environment
  Client->>AuthRouter: request provider availability
  AuthRouter->>ProviderHelpers: get enabled provider status
  ProviderHelpers->>Environment: read credentials and disable flags
  Environment-->>ProviderHelpers: return environment values
  ProviderHelpers-->>AuthRouter: return provider status
  AuthRouter-->>Client: return enabled providers
  Client->>AuthRouter: request OAuth sign-in
  AuthRouter->>ProviderHelpers: check selected provider
  alt Provider enabled
    ProviderHelpers-->>AuthRouter: return enabled
    AuthRouter-->>Client: return authorization URL
  else Provider disabled
    ProviderHelpers-->>AuthRouter: return disabled
    AuthRouter-->>Client: return provider-specific bad request
  end
Loading

Suggested reviewers: lindesvard

Merge Risk: ⚪ Minimal · up to ab434

The OAuth configuration and sign-in checks present no identified merge-blocking risk. Search Console availability remains independent of login-disable flags.

Security Architecture Review

Security architecture risk: 🟡 Moderate · up to ab434

Provider visibility and sign-in initiation now share one policy, but disabling a provider does not prevent its callbacks from creating sessions while valid login credentials remain configured. Existing identity and registration checks limit the impact; the flags should not be treated as a complete authentication shutdown.

Retained concerns

  • Medium · security · inferred: The new provider-disable policy stops at discovery and signInOAuth initiation. The session-issuing callbacks do not evaluate it. With valid login credentials retained, an already-started transaction can complete after disablement. A client can also obtain its own valid provider authorization code independently and supply matching state and, for Google, PKCE verifier cookies directly to the callback. The documented API rejection therefore does not provide a complete provider-authentication boundary. The callback mechanism predates the PR; the concern is the new disable configuration leaving that authority active.
Security review details

Security Blast Radius

  • inferred — The disable-policy gap affects an instance retaining valid login credentials for a disabled provider. It permits authentication as a legitimately proven provider identity and inheritance of that account's existing authority, or registration subject to the existing registration policy. It does not establish arbitrary-user impersonation, cross-instance access, or infrastructure privilege escalation.

Security Findings and Attack Paths

  • inferred — A client with its own valid provider authorization code can submit it to the public callback with matching state and, for Google, the verifier used to generate its PKCE challenge. The application performs the credentialed exchange and can issue a session without calling signInOAuth. This bypasses the new initiation deny decision, not the provider's identity proof. The path is inferred from source rather than demonstrated against a deployed instance.

Trust Boundaries and Controls

  • observed — Login callbacks retain provider-code exchange, state comparison, Google PKCE, verified-email checks, account resolution, and callback-time registration policy. These controls constrain the authentication outcome but do not enforce provider disablement.
  • observed — Search Console is a separate project-authorized flow, not an alternate application login path. Initiation requires project write access and signs state, verifier, and project cookies. Its callback validates those signatures and PKCE, then persists encrypted project-connection tokens rather than issuing a login session.

Hardening Proposals

  • proposed — Define whether the flags disable authentication or only hide and gate initiation. For authentication disablement, apply the shared eligibility policy at callback entry before account or session mutations, independently of Search Console authorization. Define in-flight and existing-session behavior explicitly; signed transaction cookies alone would not stop an already-issued flow after disablement.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 7 files. (2 skipped: 2… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: configurable visibility for GitHub and Google authentication providers.
Linked Issues check ✅ Passed The PR meets the coding requirements in issue #384. It adds independent GitHub and Google visibility controls through DISABLE_GITHUB_AUTH and DISABLE_GOOGLE_AUTH. It enables each provider only whe…
Out of Scope Changes check ✅ Passed The reviewed changes stay within issue #384. The new auth helpers, router validation, tests, and self-hosting documentation directly support provider visibility and GitHub integration. No unrelated ch…
Full details: Docstring Coverage

Explanation

Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 7 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

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.

Keep the upstream auth.providers contract and login UI, including independent
Search Console availability. Retain credential checks, login disable flags,
and the server-side OAuth gate; remove the duplicate provider hook.

Verify 15 OAuth tests, auth/trpc/dashboard typechecks, and focused lint.
@lindesvard

Copy link
Copy Markdown
Contributor

Hey, thanks a lot for this contribution! We just merged a full rewrite of the OpenPanel codebase into main, so this PR no longer applies and we're closing it. If you still want this change in, please open a new PR against the new main. Sorry for the extra work, and thanks again!

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.

Hide/Show Auth Providers

2 participants