FEATURE: Add a site setting to control automatic auth redirect (#10732)

This allows administrators to stop automatic redirect to an external authenticator. It only takes effect when there is a single authentication method, and the site is login_required
This commit is contained in:
David Taylor
2020-09-24 17:06:07 +01:00
committed by GitHub
parent 6a5aeceee8
commit f1d64bbbe5
4 changed files with 23 additions and 2 deletions

View File

@ -707,11 +707,11 @@ class ApplicationController < ActionController::Base
def redirect_to_login
dont_cache_page
if SiteSetting.enable_sso?
if SiteSetting.external_auth_immediately && SiteSetting.enable_sso?
# save original URL in a session so we can redirect after login
session[:destination_url] = destination_url
redirect_to path('/session/sso')
elsif !SiteSetting.enable_local_logins && Discourse.enabled_authenticators.length == 1 && !cookies[:authentication_data]
elsif SiteSetting.external_auth_immediately && !SiteSetting.enable_local_logins && Discourse.enabled_authenticators.length == 1 && !cookies[:authentication_data]
# Only one authentication provider, direct straight to it.
# If authentication_data is present, then we are halfway though registration. Don't redirect offsite
cookies[:destination_url] = destination_url