summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmelia Smith <ThisIsMissEm@users.noreply.github.com>2023-08-02 19:32:48 +0200
committerGitHub <noreply@github.com>2023-08-02 19:32:48 +0200
commite258b4cb64479fffbede4763dffe0379d0798f8e (patch)
treece6005c9560097f7c326f75d1a3f97cb44e30a40
parent8891d8945d837f0da16a3a5aa2dc9783e39b0acd (diff)
Refactor: replace whitelist_mode mentions with limited_federation_mode (#26252)
-rw-r--r--.rubocop_todo.yml2
-rw-r--r--app/controllers/accounts_controller.rb2
-rw-r--r--app/controllers/admin/instances_controller.rb2
-rw-r--r--app/controllers/api/base_controller.rb4
-rw-r--r--app/controllers/api/v1/instances/activity_controller.rb4
-rw-r--r--app/controllers/api/v1/instances/domain_blocks_controller.rb2
-rw-r--r--app/controllers/api/v1/instances/extended_descriptions_controller.rb4
-rw-r--r--app/controllers/api/v1/instances/peers_controller.rb6
-rw-r--r--app/controllers/api/v1/instances/privacy_policies_controller.rb2
-rw-r--r--app/controllers/api/v1/instances/rules_controller.rb4
-rw-r--r--app/controllers/api/v1/instances/translation_languages_controller.rb2
-rw-r--r--app/controllers/api/v1/instances_controller.rb4
-rw-r--r--app/controllers/api/v1/peers/search_controller.rb4
-rw-r--r--app/controllers/application_controller.rb4
-rw-r--r--app/controllers/concerns/account_owned_concern.rb2
-rw-r--r--app/controllers/concerns/api_caching_concern.rb2
-rw-r--r--app/controllers/follower_accounts_controller.rb2
-rw-r--r--app/controllers/following_accounts_controller.rb2
-rw-r--r--app/controllers/media_controller.rb4
-rw-r--r--app/controllers/media_proxy_controller.rb2
-rw-r--r--app/controllers/statuses_controller.rb2
-rw-r--r--app/controllers/tags_controller.rb4
-rw-r--r--app/helpers/domain_control_helper.rb6
-rw-r--r--app/serializers/initial_state_serializer.rb2
-rw-r--r--app/services/concerns/payloadable.rb2
-rw-r--r--app/services/unallow_domain_service.rb2
-rw-r--r--app/views/admin/instances/index.html.haml6
-rw-r--r--app/views/admin/instances/show.html.haml2
-rw-r--r--config/initializers/2_limited_federation_mode.rb7
-rw-r--r--config/initializers/2_whitelist_mode.rb5
-rw-r--r--config/navigation.rb4
-rw-r--r--spec/requests/cache_spec.rb6
-rw-r--r--spec/services/unallow_domain_service_spec.rb4
33 files changed, 57 insertions, 55 deletions
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 972b496d5c2..b942165129e 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -589,7 +589,7 @@ Style/FetchEnvVar:
- 'app/lib/translation_service.rb'
- 'config/environments/development.rb'
- 'config/environments/production.rb'
- - 'config/initializers/2_whitelist_mode.rb'
+ - 'config/initializers/2_limited_federation_mode.rb'
- 'config/initializers/blacklists.rb'
- 'config/initializers/cache_buster.rb'
- 'config/initializers/content_security_policy.rb'
diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb
index 0090ef7ec55..936973fb2a4 100644
--- a/app/controllers/accounts_controller.rb
+++ b/app/controllers/accounts_controller.rb
@@ -12,7 +12,7 @@ class AccountsController < ApplicationController
before_action :require_account_signature!, if: -> { request.format == :json && authorized_fetch_mode? }
skip_around_action :set_locale, if: -> { [:json, :rss].include?(request.format&.to_sym) }
- skip_before_action :require_functional!, unless: :whitelist_mode?
+ skip_before_action :require_functional!, unless: :limited_federation_mode?
def show
respond_to do |format|
diff --git a/app/controllers/admin/instances_controller.rb b/app/controllers/admin/instances_controller.rb
index 5194057263f..e5a55de06dc 100644
--- a/app/controllers/admin/instances_controller.rb
+++ b/app/controllers/admin/instances_controller.rb
@@ -65,7 +65,7 @@ module Admin
end
def filtered_instances
- InstanceFilter.new(whitelist_mode? ? { allowed: true } : filter_params).results
+ InstanceFilter.new(limited_federation_mode? ? { allowed: true } : filter_params).results
end
def filter_params
diff --git a/app/controllers/api/base_controller.rb b/app/controllers/api/base_controller.rb
index 2629ab782fc..c764b451014 100644
--- a/app/controllers/api/base_controller.rb
+++ b/app/controllers/api/base_controller.rb
@@ -8,7 +8,7 @@ class Api::BaseController < ApplicationController
include AccessTokenTrackingConcern
include ApiCachingConcern
- skip_before_action :require_functional!, unless: :whitelist_mode?
+ skip_before_action :require_functional!, unless: :limited_federation_mode?
before_action :require_authenticated_user!, if: :disallow_unauthenticated_api_access?
before_action :require_not_suspended!
@@ -150,7 +150,7 @@ class Api::BaseController < ApplicationController
end
def disallow_unauthenticated_api_access?
- ENV['DISALLOW_UNAUTHENTICATED_API_ACCESS'] == 'true' || Rails.configuration.x.whitelist_mode
+ ENV['DISALLOW_UNAUTHENTICATED_API_ACCESS'] == 'true' || Rails.configuration.x.limited_federation_mode
end
private
diff --git a/app/controllers/api/v1/instances/activity_controller.rb b/app/controllers/api/v1/instances/activity_controller.rb
index 3d55d990af2..9da77f8dabb 100644
--- a/app/controllers/api/v1/instances/activity_controller.rb
+++ b/app/controllers/api/v1/instances/activity_controller.rb
@@ -3,7 +3,7 @@
class Api::V1::Instances::ActivityController < Api::BaseController
before_action :require_enabled_api!
- skip_before_action :require_authenticated_user!, unless: :whitelist_mode?
+ skip_before_action :require_authenticated_user!, unless: :limited_federation_mode?
vary_by ''
@@ -33,6 +33,6 @@ class Api::V1::Instances::ActivityController < Api::BaseController
end
def require_enabled_api!
- head 404 unless Setting.activity_api_enabled && !whitelist_mode?
+ head 404 unless Setting.activity_api_enabled && !limited_federation_mode?
end
end
diff --git a/app/controllers/api/v1/instances/domain_blocks_controller.rb b/app/controllers/api/v1/instances/domain_blocks_controller.rb
index e954c458977..c91234e088c 100644
--- a/app/controllers/api/v1/instances/domain_blocks_controller.rb
+++ b/app/controllers/api/v1/instances/domain_blocks_controller.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class Api::V1::Instances::DomainBlocksController < Api::BaseController
- skip_before_action :require_authenticated_user!, unless: :whitelist_mode?
+ skip_before_action :require_authenticated_user!, unless: :limited_federation_mode?
before_action :require_enabled_api!
before_action :set_domain_blocks
diff --git a/app/controllers/api/v1/instances/extended_descriptions_controller.rb b/app/controllers/api/v1/instances/extended_descriptions_controller.rb
index a0665725bd3..376fec90660 100644
--- a/app/controllers/api/v1/instances/extended_descriptions_controller.rb
+++ b/app/controllers/api/v1/instances/extended_descriptions_controller.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class Api::V1::Instances::ExtendedDescriptionsController < Api::BaseController
- skip_before_action :require_authenticated_user!, unless: :whitelist_mode?
+ skip_before_action :require_authenticated_user!, unless: :limited_federation_mode?
skip_around_action :set_locale
before_action :set_extended_description
@@ -10,7 +10,7 @@ class Api::V1::Instances::ExtendedDescriptionsController < Api::BaseController
# Override `current_user` to avoid reading session cookies unless in whitelist mode
def current_user
- super if whitelist_mode?
+ super if limited_federation_mode?
end
def show
diff --git a/app/controllers/api/v1/instances/peers_controller.rb b/app/controllers/api/v1/instances/peers_controller.rb
index 23096650e61..08a982f2274 100644
--- a/app/controllers/api/v1/instances/peers_controller.rb
+++ b/app/controllers/api/v1/instances/peers_controller.rb
@@ -3,14 +3,14 @@
class Api::V1::Instances::PeersController < Api::BaseController
before_action :require_enabled_api!
- skip_before_action :require_authenticated_user!, unless: :whitelist_mode?
+ skip_before_action :require_authenticated_user!, unless: :limited_federation_mode?
skip_around_action :set_locale
vary_by ''
# Override `current_user` to avoid reading session cookies unless in whitelist mode
def current_user
- super if whitelist_mode?
+ super if limited_federation_mode?
end
def index
@@ -21,6 +21,6 @@ class Api::V1::Instances::PeersController < Api::BaseController
private
def require_enabled_api!
- head 404 unless Setting.peers_api_enabled && !whitelist_mode?
+ head 404 unless Setting.peers_api_enabled && !limited_federation_mode?
end
end
diff --git a/app/controllers/api/v1/instances/privacy_policies_controller.rb b/app/controllers/api/v1/instances/privacy_policies_controller.rb
index 36889f73354..f5b1b4ec5f5 100644
--- a/app/controllers/api/v1/instances/privacy_policies_controller.rb
+++ b/app/controllers/api/v1/instances/privacy_policies_controller.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class Api::V1::Instances::PrivacyPoliciesController < Api::BaseController
- skip_before_action :require_authenticated_user!, unless: :whitelist_mode?
+ skip_before_action :require_authenticated_user!, unless: :limited_federation_mode?
before_action :set_privacy_policy
diff --git a/app/controllers/api/v1/instances/rules_controller.rb b/app/controllers/api/v1/instances/rules_controller.rb
index d3eeca32624..2f71984b05e 100644
--- a/app/controllers/api/v1/instances/rules_controller.rb
+++ b/app/controllers/api/v1/instances/rules_controller.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class Api::V1::Instances::RulesController < Api::BaseController
- skip_before_action :require_authenticated_user!, unless: :whitelist_mode?
+ skip_before_action :require_authenticated_user!, unless: :limited_federation_mode?
skip_around_action :set_locale
before_action :set_rules
@@ -10,7 +10,7 @@ class Api::V1::Instances::RulesController < Api::BaseController
# Override `current_user` to avoid reading session cookies unless in whitelist mode
def current_user
- super if whitelist_mode?
+ super if limited_federation_mode?
end
def index
diff --git a/app/controllers/api/v1/instances/translation_languages_controller.rb b/app/controllers/api/v1/instances/translation_languages_controller.rb
index c4680cccb8a..78423e40e49 100644
--- a/app/controllers/api/v1/instances/translation_languages_controller.rb
+++ b/app/controllers/api/v1/instances/translation_languages_controller.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class Api::V1::Instances::TranslationLanguagesController < Api::BaseController
- skip_before_action :require_authenticated_user!, unless: :whitelist_mode?
+ skip_before_action :require_authenticated_user!, unless: :limited_federation_mode?
before_action :set_languages
diff --git a/app/controllers/api/v1/instances_controller.rb b/app/controllers/api/v1/instances_controller.rb
index 5a6701ff96b..df4a14af156 100644
--- a/app/controllers/api/v1/instances_controller.rb
+++ b/app/controllers/api/v1/instances_controller.rb
@@ -1,14 +1,14 @@
# frozen_string_literal: true
class Api::V1::InstancesController < Api::BaseController
- skip_before_action :require_authenticated_user!, unless: :whitelist_mode?
+ skip_before_action :require_authenticated_user!, unless: :limited_federation_mode?
skip_around_action :set_locale
vary_by ''
# Override `current_user` to avoid reading session cookies unless in whitelist mode
def current_user
- super if whitelist_mode?
+ super if limited_federation_mode?
end
def show
diff --git a/app/controllers/api/v1/peers/search_controller.rb b/app/controllers/api/v1/peers/search_controller.rb
index bd72b985f67..2c0eacdcae5 100644
--- a/app/controllers/api/v1/peers/search_controller.rb
+++ b/app/controllers/api/v1/peers/search_controller.rb
@@ -4,7 +4,7 @@ class Api::V1::Peers::SearchController < Api::BaseController
before_action :require_enabled_api!
before_action :set_domains
- skip_before_action :require_authenticated_user!, unless: :whitelist_mode?
+ skip_before_action :require_authenticated_user!, unless: :limited_federation_mode?
skip_around_action :set_locale
vary_by ''
@@ -17,7 +17,7 @@ class Api::V1::Peers::SearchController < Api::BaseController
private
def require_enabled_api!
- head 404 unless Setting.peers_api_enabled && !whitelist_mode?
+ head 404 unless Setting.peers_api_enabled && !limited_federation_mode?
end
def set_domains
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 66886b4519d..975315e2473 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -19,7 +19,7 @@ class ApplicationController < ActionController::Base
helper_method :use_seamless_external_login?
helper_method :omniauth_only?
helper_method :sso_account_settings
- helper_method :whitelist_mode?
+ helper_method :limited_federation_mode?
helper_method :body_class_string
helper_method :skip_csrf_meta_tags?
@@ -52,7 +52,7 @@ class ApplicationController < ActionController::Base
private
def authorized_fetch_mode?
- ENV['AUTHORIZED_FETCH'] == 'true' || Rails.configuration.x.whitelist_mode
+ ENV['AUTHORIZED_FETCH'] == 'true' || Rails.configuration.x.limited_federation_mode
end
def public_fetch_mode?
diff --git a/app/controllers/concerns/account_owned_concern.rb b/app/controllers/concerns/account_owned_concern.rb
index 25149d03fb6..3fc0938bfc7 100644
--- a/app/controllers/concerns/account_owned_concern.rb
+++ b/app/controllers/concerns/account_owned_concern.rb
@@ -4,7 +4,7 @@ module AccountOwnedConcern
extend ActiveSupport::Concern
included do
- before_action :authenticate_user!, if: -> { whitelist_mode? && request.format != :json }
+ before_action :authenticate_user!, if: -> { limited_federation_mode? && request.format != :json }
before_action :set_account, if: :account_required?
before_action :check_account_approval, if: :account_required?
before_action :check_account_suspension, if: :account_required?
diff --git a/app/controllers/concerns/api_caching_concern.rb b/app/controllers/concerns/api_caching_concern.rb
index 705abce80fd..12264d514e5 100644
--- a/app/controllers/concerns/api_caching_concern.rb
+++ b/app/controllers/concerns/api_caching_concern.rb
@@ -8,6 +8,6 @@ module ApiCachingConcern
end
def cache_even_if_authenticated!
- expires_in(5.minutes, public: true, stale_while_revalidate: 30.seconds, stale_if_error: 1.day) unless whitelist_mode?
+ expires_in(5.minutes, public: true, stale_while_revalidate: 30.seconds, stale_if_error: 1.day) unless limited_federation_mode?
end
end
diff --git a/app/controllers/follower_accounts_controller.rb b/app/controllers/follower_accounts_controller.rb
index f35af5903c6..ffdbd01802e 100644
--- a/app/controllers/follower_accounts_controller.rb
+++ b/app/controllers/follower_accounts_controller.rb
@@ -10,7 +10,7 @@ class FollowerAccountsController < ApplicationController
before_action :require_account_signature!, if: -> { request.format == :json && authorized_fetch_mode? }
skip_around_action :set_locale, if: -> { request.format == :json }
- skip_before_action :require_functional!, unless: :whitelist_mode?
+ skip_before_action :require_functional!, unless: :limited_federation_mode?
def index
respond_to do |format|
diff --git a/app/controllers/following_accounts_controller.rb b/app/controllers/following_accounts_controller.rb
index 2aa31bdf084..cce296f9fd6 100644
--- a/app/controllers/following_accounts_controller.rb
+++ b/app/controllers/following_accounts_controller.rb
@@ -10,7 +10,7 @@ class FollowingAccountsController < ApplicationController
before_action :require_account_signature!, if: -> { request.format == :json && authorized_fetch_mode? }
skip_around_action :set_locale, if: -> { request.format == :json }
- skip_before_action :require_functional!, unless: :whitelist_mode?
+ skip_before_action :require_functional!, unless: :limited_federation_mode?
def index
respond_to do |format|
diff --git a/app/controllers/media_controller.rb b/app/controllers/media_controller.rb
index 3bf5b7eba73..53eee40012a 100644
--- a/app/controllers/media_controller.rb
+++ b/app/controllers/media_controller.rb
@@ -3,9 +3,9 @@
class MediaController < ApplicationController
include Authorization
- skip_before_action :require_functional!, unless: :whitelist_mode?
+ skip_before_action :require_functional!, unless: :limited_federation_mode?
- before_action :authenticate_user!, if: :whitelist_mode?
+ before_action :authenticate_user!, if: :limited_federation_mode?
before_action :set_media_attachment
before_action :verify_permitted_status!
before_action :check_playable, only: :player
diff --git a/app/controllers/media_proxy_controller.rb b/app/controllers/media_proxy_controller.rb
index 8d480d704e2..c4230d62c38 100644
--- a/app/controllers/media_proxy_controller.rb
+++ b/app/controllers/media_proxy_controller.rb
@@ -8,7 +8,7 @@ class MediaProxyController < ApplicationController
skip_before_action :require_functional!
- before_action :authenticate_user!, if: :whitelist_mode?
+ before_action :authenticate_user!, if: :limited_federation_mode?
rescue_from ActiveRecord::RecordInvalid, with: :not_found
rescue_from Mastodon::UnexpectedResponseError, with: :not_found
diff --git a/app/controllers/statuses_controller.rb b/app/controllers/statuses_controller.rb
index 1ff0fbd6001..effaba3630f 100644
--- a/app/controllers/statuses_controller.rb
+++ b/app/controllers/statuses_controller.rb
@@ -17,7 +17,7 @@ class StatusesController < ApplicationController
after_action :set_link_headers
skip_around_action :set_locale, if: -> { request.format == :json }
- skip_before_action :require_functional!, only: [:show, :embed], unless: :whitelist_mode?
+ skip_before_action :require_functional!, only: [:show, :embed], unless: :limited_federation_mode?
content_security_policy only: :embed do |policy|
policy.frame_ancestors(false)
diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb
index 7e249dbea59..2007fe8462e 100644
--- a/app/controllers/tags_controller.rb
+++ b/app/controllers/tags_controller.rb
@@ -10,13 +10,13 @@ class TagsController < ApplicationController
vary_by -> { public_fetch_mode? ? 'Accept, Accept-Language, Cookie' : 'Accept, Accept-Language, Cookie, Signature' }
before_action :require_account_signature!, if: -> { request.format == :json && authorized_fetch_mode? }
- before_action :authenticate_user!, if: :whitelist_mode?
+ before_action :authenticate_user!, if: :limited_federation_mode?
before_action :set_local
before_action :set_tag
before_action :set_statuses, if: -> { request.format == :rss }
before_action :set_instance_presenter
- skip_before_action :require_functional!, unless: :whitelist_mode?
+ skip_before_action :require_functional!, unless: :limited_federation_mode?
def show
respond_to do |format|
diff --git a/app/helpers/domain_control_helper.rb b/app/helpers/domain_control_helper.rb
index 6fce7eb1f55..2703c1b8f86 100644
--- a/app/helpers/domain_control_helper.rb
+++ b/app/helpers/domain_control_helper.rb
@@ -10,14 +10,14 @@ module DomainControlHelper
uri_or_domain
end
- if whitelist_mode?
+ if limited_federation_mode?
!DomainAllow.allowed?(domain)
else
DomainBlock.blocked?(domain)
end
end
- def whitelist_mode?
- Rails.configuration.x.whitelist_mode
+ def limited_federation_mode?
+ Rails.configuration.x.limited_federation_mode
end
end
diff --git a/app/serializers/initial_state_serializer.rb b/app/serializers/initial_state_serializer.rb
index b90db4f58f9..bda06ef1f11 100644
--- a/app/serializers/initial_state_serializer.rb
+++ b/app/serializers/initial_state_serializer.rb
@@ -22,7 +22,7 @@ class InitialStateSerializer < ActiveModel::Serializer
repository: Mastodon::Version.repository,
source_url: instance_