mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 01:31:35 +08:00
FEATURE: Allow admins to opt-in to seamless redirects on /auth/*
(#31235)
By default, when multiple login providers are enabled, Discourse requires user interaction before triggering an external auth flow. This is defense-in-depth against "Login CSRF" attacks. This commit introduces a setting to control this behavior, so that it can be disabled when admins fully trust the downstream systems, and need an interaction-free login flow on a site with multiple login providers. Default behavior remains unchanged.
This commit is contained in:
@ -31,7 +31,10 @@ class Middleware::OmniauthBypassMiddleware
|
||||
# When only one provider is enabled, assume it can be completely trusted, and allow GET requests
|
||||
only_one_provider =
|
||||
!SiteSetting.enable_local_logins && Discourse.enabled_authenticators.length == 1
|
||||
OmniAuth.config.allowed_request_methods = only_one_provider ? %i[get post] : [:post]
|
||||
|
||||
allow_get = only_one_provider || !SiteSetting.auth_require_interaction
|
||||
|
||||
OmniAuth.config.allowed_request_methods = allow_get ? %i[get post] : [:post]
|
||||
|
||||
omniauth =
|
||||
OmniAuth::Builder.new(@app) do
|
||||
|
Reference in New Issue
Block a user