From 78e3b7776559fd0ace461a065eb43d5164c4a556 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Tue, 11 Jun 2024 10:35:18 -0400 Subject: [PATCH] Move to `x` namespace --- app/controllers/application_controller.rb | 2 +- .../concerns/web_app_controller_concern.rb | 2 +- app/helpers/application_helper.rb | 2 +- app/helpers/registration_helper.rb | 2 +- app/serializers/initial_state_serializer.rb | 2 +- config/application.rb | 2 +- config/initializers/3_omniauth.rb | 12 ++++++------ spec/helpers/application_helper_spec.rb | 18 +++++++++--------- spec/requests/omniauth_callbacks_spec.rb | 6 +++--- 9 files changed, 24 insertions(+), 24 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 43bf4289d09..d87cab84792 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -79,7 +79,7 @@ class ApplicationController < ActionController::Base end def after_sign_out_path_for(_resource_or_scope) - if Rails.configuration.omniauth.only && Rails.configuration.omniauth.oidc_enabled + if Rails.configuration.x.omniauth.only && Rails.configuration.x.omniauth.oidc_enabled '/auth/auth/openid_connect/logout' else new_user_session_path diff --git a/app/controllers/concerns/web_app_controller_concern.rb b/app/controllers/concerns/web_app_controller_concern.rb index fddb8f156be..3ef9521de0c 100644 --- a/app/controllers/concerns/web_app_controller_concern.rb +++ b/app/controllers/concerns/web_app_controller_concern.rb @@ -11,7 +11,7 @@ module WebAppControllerConcern end def skip_csrf_meta_tags? - !(ENV['ONE_CLICK_SSO_LOGIN'] == 'true' && Rails.configuration.omniauth.only && Devise.omniauth_providers.length == 1) && current_user.nil? + !(ENV['ONE_CLICK_SSO_LOGIN'] == 'true' && Rails.configuration.x.omniauth.only && Devise.omniauth_providers.length == 1) && current_user.nil? end def set_app_body_class diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6f85148b71a..ff452854fc3 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -49,7 +49,7 @@ module ApplicationHelper end def omniauth_only? - Rails.configuration.omniauth.only + Rails.configuration.x.omniauth.only end def link_to_login(name = nil, html_options = nil, &block) diff --git a/app/helpers/registration_helper.rb b/app/helpers/registration_helper.rb index 596261de951..685c8b62e4c 100644 --- a/app/helpers/registration_helper.rb +++ b/app/helpers/registration_helper.rb @@ -12,7 +12,7 @@ module RegistrationHelper end def omniauth_only? - Rails.configuration.omniauth.only + Rails.configuration.x.omniauth.only end def ip_blocked?(remote_ip) diff --git a/app/serializers/initial_state_serializer.rb b/app/serializers/initial_state_serializer.rb index d8addbd1e02..68d2fa90871 100644 --- a/app/serializers/initial_state_serializer.rb +++ b/app/serializers/initial_state_serializer.rb @@ -125,6 +125,6 @@ class InitialStateSerializer < ActiveModel::Serializer end def sso_redirect - "/auth/auth/#{Devise.omniauth_providers[0]}" if ENV['ONE_CLICK_SSO_LOGIN'] == 'true' && Rails.configuration.omniauth.only && Devise.omniauth_providers.length == 1 + "/auth/auth/#{Devise.omniauth_providers[0]}" if ENV['ONE_CLICK_SSO_LOGIN'] == 'true' && Rails.configuration.x.omniauth.only && Devise.omniauth_providers.length == 1 end end diff --git a/config/application.rb b/config/application.rb index 6037ffdd7b9..aff6908f6b7 100644 --- a/config/application.rb +++ b/config/application.rb @@ -113,7 +113,7 @@ module Mastodon end # Load config/omniauth.yml settings - config.omniauth = config_for(:omniauth) + config.x.omniauth = config_for(:omniauth) config.to_prepare do Doorkeeper::AuthorizationsController.layout 'modal' diff --git a/config/initializers/3_omniauth.rb b/config/initializers/3_omniauth.rb index d731c0fd5c4..d3f79c91e4a 100644 --- a/config/initializers/3_omniauth.rb +++ b/config/initializers/3_omniauth.rb @@ -10,26 +10,26 @@ end Devise.setup do |config| # CAS strategy - if Rails.configuration.omniauth.cas_enabled + if Rails.configuration.x.omniauth.cas_enabled config.omniauth( :cas, - Rails.configuration.omniauth.cas + Rails.configuration.x.omniauth.cas ) end # SAML strategy - if Rails.configuration.omniauth.saml_enabled + if Rails.configuration.x.omniauth.saml_enabled config.omniauth( :saml, - Rails.configuration.omniauth.saml + Rails.configuration.x.omniauth.saml ) end # OpenID Connect Strategy - if Rails.configuration.omniauth.oidc_enabled + if Rails.configuration.x.omniauth.oidc_enabled config.omniauth( :openid_connect, - Rails.configuration.omniauth.oidc + Rails.configuration.x.omniauth.oidc ) end end diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 4859816d09c..0b897c012dd 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -88,10 +88,10 @@ describe ApplicationHelper do context 'when in omniauth only mode' do around do |example| - original = Rails.configuration.omniauth.only - Rails.configuration.omniauth.only = true + original = Rails.configuration.x.omniauth.only + Rails.configuration.x.omniauth.only = true example.run - Rails.configuration.omniauth.only = original + Rails.configuration.x.omniauth.only = original end it 'redirects to joinmastodon site' do @@ -109,10 +109,10 @@ describe ApplicationHelper do describe 'omniauth_only?' do context 'when configuration is set to true' do around do |example| - original = Rails.configuration.omniauth.only - Rails.configuration.omniauth.only = true + original = Rails.configuration.x.omniauth.only + Rails.configuration.x.omniauth.only = true example.run - Rails.configuration.omniauth.only = original + Rails.configuration.x.omniauth.only = original end it 'returns true' do @@ -122,10 +122,10 @@ describe ApplicationHelper do context 'when configuration is false' do around do |example| - original = Rails.configuration.omniauth.only - Rails.configuration.omniauth.only = false + original = Rails.configuration.x.omniauth.only + Rails.configuration.x.omniauth.only = false example.run - Rails.configuration.omniauth.only = original + Rails.configuration.x.omniauth.only = original end it 'returns false' do diff --git a/spec/requests/omniauth_callbacks_spec.rb b/spec/requests/omniauth_callbacks_spec.rb index 403dda4640d..2d4724af6a3 100644 --- a/spec/requests/omniauth_callbacks_spec.rb +++ b/spec/requests/omniauth_callbacks_spec.rb @@ -129,15 +129,15 @@ describe 'OmniAuth callbacks' do end end - describe '#openid_connect', if: Rails.configuration.omniauth.oidc_enabled && Rails.configuration.omniauth.oidc[:scope].present? do + describe '#openid_connect', if: Rails.configuration.x.omniauth.oidc_enabled && Rails.configuration.x.omniauth.oidc[:scope].present? do include_examples 'omniauth provider callbacks', :openid_connect end - describe '#cas', if: Rails.configuration.omniauth.cas_enabled do + describe '#cas', if: Rails.configuration.x.omniauth.cas_enabled do include_examples 'omniauth provider callbacks', :cas end - describe '#saml', if: Rails.configuration.omniauth.saml_enabled do + describe '#saml', if: Rails.configuration.x.omniauth.saml_enabled do include_examples 'omniauth provider callbacks', :saml end end