Skip to content

Force SSO for new sign-ups (closes #64)#69

Open
li-xinwei wants to merge 2 commits intomainfrom
sso-signup-only
Open

Force SSO for new sign-ups (closes #64)#69
li-xinwei wants to merge 2 commits intomainfrom
sso-signup-only

Conversation

@li-xinwei
Copy link
Copy Markdown

@li-xinwei li-xinwei commented Mar 29, 2026

Summary

  • Add PREVENT_NEW_LOCAL_PASSWORDS environment variable that controls whether local sign-ups are allowed
  • When enabled, the sign-up page shows only Google and Snap! SSO buttons (no username/password form)
  • When enabled, the sign-in page places SSO buttons at the top with the traditional password form below, so existing users can still log in
  • Server-side guard in RegistrationsController prevents bypassing the UI restriction via direct POST
  • No existing auth code is deleted — the local form is conditionally hidden to avoid upstream merge conflicts
  • Uses the existing Feature toggle system (same pattern as reCAPTCHA)

Changes

  • config/initializers/feature.rb — register :prevent_local_signups feature flag
  • app/views/devise/registrations/new.html.haml — conditionally show SSO-only sign-up
  • app/views/devise/sessions/new.html.haml — reorder SSO above password when flag active
  • app/views/devise/shared/_sso_buttons.html.haml — new partial for Google + Snap! buttons
  • app/controllers/registrations_controller.rb — block local sign-up POST when flag active
  • dotenv.example — document the new environment variable

Test plan

  • Set PREVENT_NEW_LOCAL_PASSWORDS=true and verify sign-up page shows only SSO buttons
  • Verify sign-in page shows SSO buttons above the password form
  • Verify direct POST to /accounts is rejected with redirect
  • Without the env var, verify both pages behave exactly as before

Closes #64

Add PREVENT_NEW_LOCAL_PASSWORDS env var that hides the local
registration form and shows only Google and Snap! SSO buttons.
Existing users can still sign in with username/password below
the SSO buttons. Local auth code is preserved to avoid upstream
merge conflicts.
@li-xinwei li-xinwei self-assigned this Mar 29, 2026
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.

SSO for New Sign ups

1 participant