railties 6.0.0 → 7.1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +699 -245
- data/MIT-LICENSE +1 -1
- data/RDOC_MAIN.md +99 -0
- data/README.rdoc +7 -8
- data/lib/minitest/rails_plugin.rb +80 -2
- data/lib/rails/all.rb +0 -1
- data/lib/rails/api/task.rb +37 -5
- data/lib/rails/app_updater.rb +9 -6
- data/lib/rails/application/bootstrap.rb +52 -14
- data/lib/rails/application/configuration.rb +327 -86
- data/lib/rails/application/default_middleware_stack.rb +33 -7
- data/lib/rails/application/dummy_config.rb +19 -0
- data/lib/rails/application/finisher.rb +94 -113
- data/lib/rails/application/routes_reloader.rb +17 -3
- data/lib/rails/application.rb +258 -201
- data/lib/rails/application_controller.rb +3 -4
- data/lib/rails/autoloaders/inflector.rb +21 -0
- data/lib/rails/autoloaders.rb +42 -42
- data/lib/rails/backtrace_cleaner.rb +13 -8
- data/lib/rails/cli.rb +5 -2
- data/lib/rails/code_statistics.rb +6 -4
- data/lib/rails/code_statistics_calculator.rb +16 -7
- data/lib/rails/command/actions.rb +10 -12
- data/lib/rails/command/base.rb +66 -46
- data/lib/rails/command/behavior.rb +3 -3
- data/lib/rails/command/environment_argument.rb +33 -17
- data/lib/rails/command/helpers/editor.rb +17 -12
- data/lib/rails/command.rb +90 -32
- data/lib/rails/commands/about/about_command.rb +14 -0
- data/lib/rails/commands/application/application_command.rb +2 -0
- data/lib/rails/commands/console/console_command.rb +17 -13
- data/lib/rails/commands/credentials/USAGE +54 -39
- data/lib/rails/commands/credentials/credentials_command/diffing.rb +53 -0
- data/lib/rails/commands/credentials/credentials_command.rb +83 -60
- data/lib/rails/commands/db/system/change/change_command.rb +8 -2
- data/lib/rails/commands/dbconsole/dbconsole_command.rb +39 -124
- data/lib/rails/commands/destroy/destroy_command.rb +3 -2
- data/lib/rails/commands/dev/dev_command.rb +1 -6
- data/lib/rails/commands/encrypted/USAGE +15 -20
- data/lib/rails/commands/encrypted/encrypted_command.rb +46 -35
- data/lib/rails/commands/gem_help/USAGE +16 -0
- data/lib/rails/commands/gem_help/gem_help_command.rb +13 -0
- data/lib/rails/commands/generate/generate_command.rb +3 -3
- data/lib/rails/commands/help/USAGE +15 -14
- data/lib/rails/commands/help/help_command.rb +21 -2
- data/lib/rails/commands/initializers/initializers_command.rb +1 -4
- data/lib/rails/commands/middleware/middleware_command.rb +17 -0
- data/lib/rails/commands/new/new_command.rb +2 -0
- data/lib/rails/commands/notes/notes_command.rb +5 -14
- data/lib/rails/commands/plugin/plugin_command.rb +2 -0
- data/lib/rails/commands/rake/rake_command.rb +27 -23
- data/lib/rails/commands/restart/restart_command.rb +14 -0
- data/lib/rails/commands/routes/routes_command.rb +13 -1
- data/lib/rails/commands/runner/USAGE +14 -12
- data/lib/rails/commands/runner/runner_command.rb +34 -21
- data/lib/rails/commands/secret/secret_command.rb +13 -0
- data/lib/rails/commands/secrets/USAGE +44 -43
- data/lib/rails/commands/secrets/secrets_command.rb +20 -38
- data/lib/rails/commands/server/server_command.rb +40 -64
- data/lib/rails/commands/test/USAGE +14 -0
- data/lib/rails/commands/test/test_command.rb +58 -16
- data/lib/rails/commands/unused_routes/unused_routes_command.rb +75 -0
- data/lib/rails/commands/version/version_command.rb +1 -0
- data/lib/rails/configuration.rb +53 -23
- data/lib/rails/console/app.rb +1 -4
- data/lib/rails/console/helpers.rb +2 -2
- data/lib/rails/deprecator.rb +7 -0
- data/lib/rails/engine/configuration.rb +54 -9
- data/lib/rails/engine/updater.rb +1 -1
- data/lib/rails/engine.rb +105 -81
- data/lib/rails/gem_version.rb +5 -5
- data/lib/rails/generators/actions/create_migration.rb +9 -5
- data/lib/rails/generators/actions.rb +275 -97
- data/lib/rails/generators/active_model.rb +28 -14
- data/lib/rails/generators/app_base.rb +487 -165
- data/lib/rails/generators/app_name.rb +3 -14
- data/lib/rails/generators/base.rb +42 -31
- data/lib/rails/generators/database.rb +41 -4
- data/lib/rails/generators/erb/mailer/mailer_generator.rb +0 -1
- data/lib/rails/generators/erb/mailer/templates/layout.html.erb.tt +1 -1
- data/lib/rails/generators/erb/scaffold/scaffold_generator.rb +2 -1
- data/lib/rails/generators/erb/scaffold/templates/_form.html.erb.tt +11 -11
- data/lib/rails/generators/erb/scaffold/templates/edit.html.erb.tt +8 -4
- data/lib/rails/generators/erb/scaffold/templates/index.html.erb.tt +11 -28
- data/lib/rails/generators/erb/scaffold/templates/new.html.erb.tt +7 -3
- data/lib/rails/generators/erb/scaffold/templates/partial.html.erb.tt +17 -0
- data/lib/rails/generators/erb/scaffold/templates/show.html.erb.tt +8 -17
- data/lib/rails/generators/erb.rb +1 -2
- data/lib/rails/generators/generated_attribute.rb +60 -19
- data/lib/rails/generators/migration.rb +4 -8
- data/lib/rails/generators/model_helpers.rb +29 -4
- data/lib/rails/generators/named_base.rb +15 -15
- data/lib/rails/generators/rails/app/USAGE +23 -6
- data/lib/rails/generators/rails/app/app_generator.rb +151 -80
- data/lib/rails/generators/rails/app/templates/Dockerfile.tt +103 -0
- data/lib/rails/generators/rails/app/templates/Gemfile.tt +44 -54
- data/lib/rails/generators/rails/app/templates/Rakefile.tt +1 -1
- data/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css.tt +2 -2
- data/lib/rails/generators/rails/app/templates/app/mailers/application_mailer.rb.tt +2 -2
- data/lib/rails/generators/rails/app/templates/app/models/application_record.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +4 -9
- data/lib/rails/generators/rails/app/templates/app/views/layouts/mailer.html.erb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/bin/rails.tt +3 -3
- data/lib/rails/generators/rails/app/templates/bin/rake.tt +2 -2
- data/lib/rails/generators/rails/app/templates/bin/setup.tt +19 -15
- data/lib/rails/generators/rails/app/templates/config/application.rb.tt +18 -23
- data/lib/rails/generators/rails/app/templates/config/boot.rb.tt +3 -3
- data/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml.tt +5 -6
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml.tt +12 -11
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml.tt +17 -16
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcsqlite3.yml.tt +5 -5
- data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml.tt +12 -11
- data/lib/rails/generators/rails/app/templates/config/databases/oracle.yml.tt +12 -11
- data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml.tt +17 -18
- data/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml.tt +4 -4
- data/lib/rails/generators/rails/app/templates/config/databases/sqlserver.yml.tt +14 -13
- data/lib/rails/generators/rails/app/templates/config/databases/trilogy.yml.tt +59 -0
- data/lib/rails/generators/rails/app/templates/config/environment.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +32 -14
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +42 -55
- data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +27 -15
- data/lib/rails/generators/rails/app/templates/config/initializers/assets.rb.tt +3 -5
- data/lib/rails/generators/rails/app/templates/config/initializers/content_security_policy.rb.tt +21 -28
- data/lib/rails/generators/rails/app/templates/config/initializers/cors.rb.tt +3 -3
- data/lib/rails/generators/rails/app/templates/config/initializers/filter_parameter_logging.rb.tt +6 -2
- data/lib/rails/generators/rails/app/templates/config/initializers/inflections.rb.tt +4 -4
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_7_1.rb.tt +284 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/permissions_policy.rb.tt +13 -0
- data/lib/rails/generators/rails/app/templates/config/locales/en.yml +13 -15
- data/lib/rails/generators/rails/app/templates/config/puma.rb.tt +17 -20
- data/lib/rails/generators/rails/app/templates/config/routes.rb.tt +8 -1
- data/lib/rails/generators/rails/app/templates/config/storage.yml.tt +5 -5
- data/lib/rails/generators/rails/app/templates/config.ru.tt +2 -1
- data/lib/rails/generators/rails/app/templates/db/seeds.rb.tt +7 -5
- data/lib/rails/generators/rails/app/templates/docker-entrypoint.tt +10 -0
- data/lib/rails/generators/rails/app/templates/dockerignore.tt +43 -0
- data/lib/rails/generators/rails/app/templates/gitattributes.tt +9 -0
- data/lib/rails/generators/rails/app/templates/gitignore.tt +12 -9
- data/lib/rails/generators/rails/app/templates/node-version.tt +1 -0
- data/lib/rails/generators/rails/app/templates/test/channels/application_cable/connection_test.rb.tt +10 -8
- data/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt +13 -11
- data/lib/rails/generators/rails/application_record/application_record_generator.rb +4 -0
- data/lib/rails/generators/rails/benchmark/USAGE +19 -0
- data/lib/rails/generators/rails/benchmark/benchmark_generator.rb +30 -0
- data/lib/rails/generators/rails/benchmark/templates/benchmark.rb.tt +15 -0
- data/lib/rails/generators/rails/controller/USAGE +13 -5
- data/lib/rails/generators/rails/controller/controller_generator.rb +7 -42
- data/lib/rails/generators/rails/controller/templates/controller.rb.tt +1 -5
- data/lib/rails/generators/rails/credentials/credentials_generator.rb +30 -25
- data/lib/rails/generators/rails/credentials/templates/credentials.yml.tt +8 -0
- data/lib/rails/generators/rails/db/system/change/change_generator.rb +31 -1
- data/lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb +6 -2
- data/lib/rails/generators/rails/encryption_key_file/encryption_key_file_generator.rb +1 -2
- data/lib/rails/generators/rails/generator/USAGE +2 -2
- data/lib/rails/generators/rails/generator/generator_generator.rb +0 -1
- data/lib/rails/generators/rails/generator/templates/%file_name%_generator.rb.tt +1 -1
- data/lib/rails/generators/rails/generator/templates/USAGE.tt +1 -1
- data/lib/rails/generators/rails/helper/USAGE +2 -3
- data/lib/rails/generators/rails/integration_test/USAGE +2 -2
- data/lib/rails/generators/rails/migration/USAGE +22 -12
- data/lib/rails/generators/rails/model/model_generator.rb +4 -0
- data/lib/rails/generators/rails/plugin/USAGE +17 -6
- data/lib/rails/generators/rails/plugin/plugin_generator.rb +86 -46
- data/lib/rails/generators/rails/plugin/templates/%name%.gemspec.tt +15 -20
- data/lib/rails/generators/rails/plugin/templates/Gemfile.tt +10 -39
- data/lib/rails/generators/rails/plugin/templates/MIT-LICENSE.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/README.md.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/Rakefile.tt +4 -18
- data/lib/rails/generators/rails/plugin/templates/app/controllers/%namespaced_name%/application_controller.rb.tt +0 -1
- data/lib/rails/generators/rails/plugin/templates/app/mailers/%namespaced_name%/application_mailer.rb.tt +2 -2
- data/lib/rails/generators/rails/plugin/templates/app/views/layouts/%namespaced_name%/application.html.erb.tt +0 -3
- data/lib/rails/generators/rails/plugin/templates/bin/rails.tt +7 -22
- data/lib/rails/generators/rails/plugin/templates/gitignore.tt +10 -14
- data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/engine.rb.tt +2 -2
- data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/version.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%.rb.tt +1 -0
- data/lib/rails/generators/rails/plugin/templates/rails/boot.rb.tt +3 -3
- data/lib/rails/generators/rails/plugin/templates/test/%namespaced_name%_test.rb.tt +4 -4
- data/lib/rails/generators/rails/plugin/templates/test/integration/navigation_test.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/test/test_helper.rb.tt +6 -14
- data/lib/rails/generators/rails/resource/USAGE +4 -4
- data/lib/rails/generators/rails/resource/resource_generator.rb +6 -0
- data/lib/rails/generators/rails/resource_route/resource_route_generator.rb +2 -27
- data/lib/rails/generators/rails/scaffold/USAGE +5 -5
- data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +2 -20
- data/lib/rails/generators/rails/scaffold_controller/USAGE +2 -2
- data/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +7 -2
- data/lib/rails/generators/rails/scaffold_controller/templates/api_controller.rb.tt +2 -6
- data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb.tt +7 -11
- data/lib/rails/generators/rails/system_test/USAGE +2 -2
- data/lib/rails/generators/rails/task/USAGE +3 -3
- data/lib/rails/generators/resource_helpers.rb +2 -2
- data/lib/rails/generators/test_case.rb +3 -3
- data/lib/rails/generators/test_unit/controller/controller_generator.rb +2 -0
- data/lib/rails/generators/test_unit/controller/templates/functional_test.rb.tt +3 -3
- data/lib/rails/generators/test_unit/generator/generator_generator.rb +0 -1
- data/lib/rails/generators/test_unit/generator/templates/generator_test.rb.tt +3 -3
- data/lib/rails/generators/test_unit/integration/integration_generator.rb +0 -1
- data/lib/rails/generators/test_unit/integration/templates/integration_test.rb.tt +1 -1
- data/lib/rails/generators/test_unit/job/templates/unit_test.rb.tt +1 -1
- data/lib/rails/generators/test_unit/mailer/templates/functional_test.rb.tt +1 -1
- data/lib/rails/generators/test_unit/model/templates/fixtures.yml.tt +3 -3
- data/lib/rails/generators/test_unit/model/templates/unit_test.rb.tt +1 -1
- data/lib/rails/generators/test_unit/plugin/templates/%file_name%_test.rb.tt +1 -1
- data/lib/rails/generators/test_unit/plugin/templates/test_helper.rb +2 -2
- data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +4 -5
- data/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb.tt +6 -6
- data/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb.tt +8 -8
- data/lib/rails/generators/test_unit/scaffold/templates/system_test.rb.tt +9 -11
- data/lib/rails/generators/testing/assertions.rb +2 -2
- data/lib/rails/generators/testing/{behaviour.rb → behavior.rb} +8 -7
- data/lib/rails/generators.rb +43 -45
- data/lib/rails/health_controller.rb +55 -0
- data/lib/rails/info.rb +4 -4
- data/lib/rails/info_controller.rb +30 -13
- data/lib/rails/initializable.rb +1 -1
- data/lib/rails/mailers_controller.rb +18 -9
- data/lib/rails/paths.rb +28 -19
- data/lib/rails/rack/logger.rb +17 -17
- data/lib/rails/rackup/server.rb +15 -0
- data/lib/rails/railtie/configurable.rb +0 -1
- data/lib/rails/railtie/configuration.rb +15 -3
- data/lib/rails/railtie.rb +80 -37
- data/lib/rails/ruby_version_check.rb +5 -3
- data/lib/rails/secrets.rb +14 -9
- data/lib/rails/source_annotation_extractor.rb +69 -34
- data/lib/rails/tasks/engine.rake +8 -11
- data/lib/rails/tasks/framework.rake +4 -6
- data/lib/rails/tasks/log.rake +1 -1
- data/lib/rails/tasks/misc.rake +4 -15
- data/lib/rails/tasks/statistics.rake +9 -6
- data/lib/rails/tasks/tmp.rake +13 -6
- data/lib/rails/tasks/yarn.rake +17 -6
- data/lib/rails/tasks/zeitwerk.rake +16 -41
- data/lib/rails/tasks.rb +0 -6
- data/lib/rails/templates/layouts/application.html.erb +15 -0
- data/lib/rails/templates/rails/mailers/email.html.erb +46 -11
- data/lib/rails/templates/rails/mailers/index.html.erb +14 -7
- data/lib/rails/templates/rails/mailers/mailer.html.erb +11 -5
- data/lib/rails/templates/rails/welcome/index.html.erb +65 -48
- data/lib/rails/test_help.rb +13 -14
- data/lib/rails/test_unit/line_filtering.rb +1 -1
- data/lib/rails/test_unit/railtie.rb +0 -4
- data/lib/rails/test_unit/reporter.rb +8 -3
- data/lib/rails/test_unit/runner.rb +61 -19
- data/lib/rails/test_unit/test_parser.rb +88 -0
- data/lib/rails/test_unit/testing.rake +17 -36
- data/lib/rails/testing/maintain_test_schema.rb +16 -0
- data/lib/rails/version.rb +1 -1
- data/lib/rails/welcome_controller.rb +1 -0
- data/lib/rails/zeitwerk_checker.rb +15 -0
- data/lib/rails.rb +31 -23
- metadata +89 -58
- data/RDOC_MAIN.rdoc +0 -98
- data/lib/rails/application/dummy_erb_compiler.rb +0 -18
- data/lib/rails/command/spellchecker.rb +0 -58
- data/lib/rails/generators/css/assets/assets_generator.rb +0 -15
- data/lib/rails/generators/css/assets/templates/stylesheet.css +0 -4
- data/lib/rails/generators/css/scaffold/scaffold_generator.rb +0 -18
- data/lib/rails/generators/rails/app/templates/app/javascript/channels/consumer.js +0 -6
- data/lib/rails/generators/rails/app/templates/app/javascript/channels/index.js +0 -5
- data/lib/rails/generators/rails/app/templates/app/javascript/packs/application.js.tt +0 -23
- data/lib/rails/generators/rails/app/templates/bin/yarn.tt +0 -10
- data/lib/rails/generators/rails/app/templates/config/databases/frontbase.yml.tt +0 -50
- data/lib/rails/generators/rails/app/templates/config/databases/ibm_db.yml.tt +0 -86
- data/lib/rails/generators/rails/app/templates/config/initializers/application_controller_renderer.rb.tt +0 -8
- data/lib/rails/generators/rails/app/templates/config/initializers/backtrace_silencers.rb.tt +0 -7
- data/lib/rails/generators/rails/app/templates/config/initializers/cookies_serializer.rb.tt +0 -5
- data/lib/rails/generators/rails/app/templates/config/initializers/mime_types.rb.tt +0 -4
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_6_0.rb.tt +0 -45
- data/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt +0 -16
- data/lib/rails/generators/rails/app/templates/config/spring.rb.tt +0 -6
- data/lib/rails/generators/rails/app/templates/package.json.tt +0 -11
- data/lib/rails/generators/rails/assets/USAGE +0 -17
- data/lib/rails/generators/rails/assets/assets_generator.rb +0 -26
- data/lib/rails/generators/rails/assets/templates/stylesheet.css +0 -4
- data/lib/rails/generators/rails/model/USAGE +0 -114
- data/lib/rails/generators/rails/plugin/templates/rails/application.rb.tt +0 -23
- data/lib/rails/generators/rails/scaffold/templates/scaffold.css +0 -80
- data/lib/rails/tasks/annotations.rake +0 -22
- data/lib/rails/tasks/dev.rake +0 -11
- data/lib/rails/tasks/initializers.rake +0 -9
- data/lib/rails/tasks/middleware.rake +0 -9
- data/lib/rails/tasks/restart.rake +0 -9
- data/lib/rails/tasks/routes.rake +0 -9
@@ -1,27 +1,31 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "ipaddr"
|
4
|
+
require "active_support/core_ext/array/wrap"
|
4
5
|
require "active_support/core_ext/kernel/reporting"
|
5
6
|
require "active_support/file_update_checker"
|
7
|
+
require "active_support/configuration_file"
|
6
8
|
require "rails/engine/configuration"
|
7
9
|
require "rails/source_annotation_extractor"
|
8
10
|
|
9
11
|
module Rails
|
10
12
|
class Application
|
11
13
|
class Configuration < ::Rails::Engine::Configuration
|
12
|
-
attr_accessor :allow_concurrency, :asset_host, :autoflush_log,
|
14
|
+
attr_accessor :allow_concurrency, :asset_host, :assume_ssl, :autoflush_log,
|
13
15
|
:cache_classes, :cache_store, :consider_all_requests_local, :console,
|
14
|
-
:eager_load, :exceptions_app, :file_watcher, :filter_parameters,
|
15
|
-
:force_ssl, :helpers_paths, :hosts, :
|
16
|
-
:railties_order, :relative_url_root, :secret_key_base,
|
16
|
+
:eager_load, :exceptions_app, :file_watcher, :filter_parameters, :precompile_filter_parameters,
|
17
|
+
:force_ssl, :helpers_paths, :hosts, :host_authorization, :logger, :log_formatter,
|
18
|
+
:log_tags, :railties_order, :relative_url_root, :secret_key_base,
|
17
19
|
:ssl_options, :public_file_server,
|
18
20
|
:session_options, :time_zone, :reload_classes_only_on_change,
|
19
|
-
:beginning_of_week, :filter_redirect, :x,
|
20
|
-
:read_encrypted_secrets, :
|
21
|
+
:beginning_of_week, :filter_redirect, :x,
|
22
|
+
:read_encrypted_secrets, :content_security_policy_report_only,
|
21
23
|
:content_security_policy_nonce_generator, :content_security_policy_nonce_directives,
|
22
|
-
:require_master_key, :credentials, :disable_sandbox, :
|
24
|
+
:require_master_key, :credentials, :disable_sandbox, :sandbox_by_default,
|
25
|
+
:add_autoload_paths_to_load_path, :rake_eager_load, :server_timing, :log_file_size,
|
26
|
+
:dom_testing_default_html_version
|
23
27
|
|
24
|
-
attr_reader :encoding, :api_only, :loaded_config_version, :
|
28
|
+
attr_reader :encoding, :api_only, :loaded_config_version, :log_level
|
25
29
|
|
26
30
|
def initialize(*)
|
27
31
|
super
|
@@ -31,16 +35,24 @@ module Rails
|
|
31
35
|
@filter_parameters = []
|
32
36
|
@filter_redirect = []
|
33
37
|
@helpers_paths = []
|
34
|
-
|
38
|
+
if Rails.env.development?
|
39
|
+
@hosts = ActionDispatch::HostAuthorization::ALLOWED_HOSTS_IN_DEVELOPMENT +
|
40
|
+
ENV["RAILS_DEVELOPMENT_HOSTS"].to_s.split(",").map(&:strip)
|
41
|
+
else
|
42
|
+
@hosts = []
|
43
|
+
end
|
44
|
+
@host_authorization = {}
|
35
45
|
@public_file_server = ActiveSupport::OrderedOptions.new
|
36
46
|
@public_file_server.enabled = true
|
37
47
|
@public_file_server.index_name = "index"
|
48
|
+
@assume_ssl = false
|
38
49
|
@force_ssl = false
|
39
50
|
@ssl_options = {}
|
40
51
|
@session_store = nil
|
41
52
|
@time_zone = "UTC"
|
42
53
|
@beginning_of_week = :monday
|
43
54
|
@log_level = :debug
|
55
|
+
@log_file_size = nil
|
44
56
|
@generators = app_generators
|
45
57
|
@cache_store = [ :file_store, "#{root}/tmp/cache/" ]
|
46
58
|
@railties_order = [:all]
|
@@ -63,15 +75,39 @@ module Rails
|
|
63
75
|
@content_security_policy_nonce_directives = nil
|
64
76
|
@require_master_key = false
|
65
77
|
@loaded_config_version = nil
|
66
|
-
@credentials = ActiveSupport::
|
67
|
-
@credentials.content_path = default_credentials_content_path
|
68
|
-
@credentials.key_path = default_credentials_key_path
|
69
|
-
@autoloader = :classic
|
78
|
+
@credentials = ActiveSupport::InheritableOptions.new(credentials_defaults)
|
70
79
|
@disable_sandbox = false
|
80
|
+
@sandbox_by_default = false
|
71
81
|
@add_autoload_paths_to_load_path = true
|
82
|
+
@permissions_policy = nil
|
83
|
+
@rake_eager_load = false
|
84
|
+
@server_timing = false
|
85
|
+
@dom_testing_default_html_version = :html4
|
72
86
|
end
|
73
87
|
|
88
|
+
# Loads default configuration values for a target version. This includes
|
89
|
+
# defaults for versions prior to the target version. See the
|
90
|
+
# {configuration guide}[https://guides.rubyonrails.org/configuring.html#versioned-default-values]
|
91
|
+
# for the default values associated with a particular version.
|
74
92
|
def load_defaults(target_version)
|
93
|
+
# To introduce a change in behavior, follow these steps:
|
94
|
+
# 1. Add an accessor on the target object (e.g. the ActiveJob class for
|
95
|
+
# global Active Job config).
|
96
|
+
# 2. Set a default value there preserving existing behavior for existing
|
97
|
+
# applications.
|
98
|
+
# 3. Implement the behavior change based on the config value.
|
99
|
+
# 4. In the section below corresponding to the next release of Rails,
|
100
|
+
# configure the default value.
|
101
|
+
# 5. Add a commented out section in the `new_framework_defaults` to
|
102
|
+
# configure the default value again.
|
103
|
+
# 6. Update the guide in `configuring.md`.
|
104
|
+
|
105
|
+
# To remove configurable deprecated behavior, follow these steps:
|
106
|
+
# 1. Update or remove the entry in the guides.
|
107
|
+
# 2. Remove the references below.
|
108
|
+
# 3. Remove the legacy code paths and config check.
|
109
|
+
# 4. Remove the config accessor.
|
110
|
+
|
75
111
|
case target_version.to_s
|
76
112
|
when "5.0"
|
77
113
|
if respond_to?(:action_controller)
|
@@ -109,7 +145,7 @@ module Rails
|
|
109
145
|
|
110
146
|
if respond_to?(:active_support)
|
111
147
|
active_support.use_authenticated_message_encryption = true
|
112
|
-
active_support.
|
148
|
+
active_support.hash_digest_class = OpenSSL::Digest::SHA1
|
113
149
|
end
|
114
150
|
|
115
151
|
if respond_to?(:action_controller)
|
@@ -122,34 +158,176 @@ module Rails
|
|
122
158
|
when "6.0"
|
123
159
|
load_defaults "5.2"
|
124
160
|
|
125
|
-
self.autoloader = :zeitwerk if RUBY_ENGINE == "ruby"
|
126
|
-
|
127
161
|
if respond_to?(:action_view)
|
128
162
|
action_view.default_enforce_utf8 = false
|
129
163
|
end
|
130
164
|
|
131
165
|
if respond_to?(:action_dispatch)
|
132
166
|
action_dispatch.use_cookies_with_metadata = true
|
133
|
-
action_dispatch.return_only_media_type_on_content_type = false
|
134
167
|
end
|
135
168
|
|
136
169
|
if respond_to?(:action_mailer)
|
137
170
|
action_mailer.delivery_job = "ActionMailer::MailDeliveryJob"
|
138
171
|
end
|
139
172
|
|
173
|
+
if respond_to?(:active_storage)
|
174
|
+
active_storage.queues.analysis = :active_storage_analysis
|
175
|
+
active_storage.queues.purge = :active_storage_purge
|
176
|
+
end
|
177
|
+
|
178
|
+
if respond_to?(:active_record)
|
179
|
+
active_record.collection_cache_versioning = true
|
180
|
+
end
|
181
|
+
when "6.1"
|
182
|
+
load_defaults "6.0"
|
183
|
+
|
184
|
+
if respond_to?(:active_record)
|
185
|
+
active_record.has_many_inversing = true
|
186
|
+
end
|
187
|
+
|
140
188
|
if respond_to?(:active_job)
|
141
|
-
active_job.
|
189
|
+
active_job.retry_jitter = 0.15
|
190
|
+
end
|
191
|
+
|
192
|
+
if respond_to?(:action_dispatch)
|
193
|
+
action_dispatch.cookies_same_site_protection = :lax
|
194
|
+
action_dispatch.ssl_default_redirect_status = 308
|
195
|
+
end
|
196
|
+
|
197
|
+
if respond_to?(:action_view)
|
198
|
+
action_view.form_with_generates_remote_forms = false
|
199
|
+
action_view.preload_links_header = true
|
142
200
|
end
|
143
201
|
|
144
202
|
if respond_to?(:active_storage)
|
145
|
-
active_storage.
|
146
|
-
|
203
|
+
active_storage.track_variants = true
|
204
|
+
|
205
|
+
active_storage.queues.analysis = nil
|
206
|
+
active_storage.queues.purge = nil
|
207
|
+
end
|
147
208
|
|
148
|
-
|
209
|
+
if respond_to?(:action_mailbox)
|
210
|
+
action_mailbox.queues.incineration = nil
|
211
|
+
action_mailbox.queues.routing = nil
|
212
|
+
end
|
213
|
+
|
214
|
+
if respond_to?(:action_mailer)
|
215
|
+
action_mailer.deliver_later_queue_name = nil
|
216
|
+
end
|
217
|
+
|
218
|
+
ActiveSupport.utc_to_local_returns_utc_offset_times = true
|
219
|
+
when "7.0"
|
220
|
+
load_defaults "6.1"
|
221
|
+
|
222
|
+
if respond_to?(:action_dispatch)
|
223
|
+
action_dispatch.default_headers = {
|
224
|
+
"X-Frame-Options" => "SAMEORIGIN",
|
225
|
+
"X-XSS-Protection" => "0",
|
226
|
+
"X-Content-Type-Options" => "nosniff",
|
227
|
+
"X-Download-Options" => "noopen",
|
228
|
+
"X-Permitted-Cross-Domain-Policies" => "none",
|
229
|
+
"Referrer-Policy" => "strict-origin-when-cross-origin"
|
230
|
+
}
|
231
|
+
action_dispatch.cookies_serializer = :json
|
232
|
+
end
|
233
|
+
|
234
|
+
if respond_to?(:action_view)
|
235
|
+
action_view.button_to_generates_button_tag = true
|
236
|
+
action_view.apply_stylesheet_media_default = false
|
237
|
+
end
|
238
|
+
|
239
|
+
if respond_to?(:active_support)
|
240
|
+
active_support.hash_digest_class = OpenSSL::Digest::SHA256
|
241
|
+
active_support.key_generator_hash_digest_class = OpenSSL::Digest::SHA256
|
242
|
+
active_support.cache_format_version = 7.0
|
243
|
+
active_support.executor_around_test_case = true
|
244
|
+
end
|
245
|
+
|
246
|
+
if respond_to?(:action_mailer)
|
247
|
+
action_mailer.smtp_timeout = 5
|
248
|
+
end
|
249
|
+
|
250
|
+
if respond_to?(:active_storage)
|
251
|
+
active_storage.video_preview_arguments =
|
252
|
+
"-vf 'select=eq(n\\,0)+eq(key\\,1)+gt(scene\\,0.015),loop=loop=-1:size=2,trim=start_frame=1'" \
|
253
|
+
" -frames:v 1 -f image2"
|
254
|
+
|
255
|
+
active_storage.variant_processor = :vips
|
256
|
+
active_storage.multiple_file_field_include_hidden = true
|
149
257
|
end
|
150
258
|
|
151
259
|
if respond_to?(:active_record)
|
152
|
-
active_record.
|
260
|
+
active_record.verify_foreign_keys_for_fixtures = true
|
261
|
+
active_record.partial_inserts = false
|
262
|
+
active_record.automatic_scope_inversing = true
|
263
|
+
end
|
264
|
+
|
265
|
+
if respond_to?(:action_controller)
|
266
|
+
action_controller.raise_on_open_redirects = true
|
267
|
+
action_controller.wrap_parameters_by_default = true
|
268
|
+
end
|
269
|
+
when "7.1"
|
270
|
+
load_defaults "7.0"
|
271
|
+
|
272
|
+
self.add_autoload_paths_to_load_path = false
|
273
|
+
self.precompile_filter_parameters = true
|
274
|
+
self.dom_testing_default_html_version = defined?(Nokogiri::HTML5) ? :html5 : :html4
|
275
|
+
|
276
|
+
if Rails.env.local?
|
277
|
+
self.log_file_size = 100 * 1024 * 1024
|
278
|
+
end
|
279
|
+
|
280
|
+
if respond_to?(:active_record)
|
281
|
+
active_record.run_commit_callbacks_on_first_saved_instances_in_transaction = false
|
282
|
+
active_record.commit_transaction_on_non_local_return = true
|
283
|
+
active_record.allow_deprecated_singular_associations_name = false
|
284
|
+
active_record.sqlite3_adapter_strict_strings_by_default = true
|
285
|
+
active_record.query_log_tags_format = :sqlcommenter
|
286
|
+
active_record.raise_on_assign_to_attr_readonly = true
|
287
|
+
active_record.belongs_to_required_validates_foreign_key = false
|
288
|
+
active_record.before_committed_on_all_records = true
|
289
|
+
active_record.default_column_serializer = nil
|
290
|
+
active_record.encryption.hash_digest_class = OpenSSL::Digest::SHA256
|
291
|
+
active_record.encryption.support_sha1_for_non_deterministic_encryption = false
|
292
|
+
active_record.marshalling_format_version = 7.1
|
293
|
+
active_record.run_after_transaction_callbacks_in_order_defined = true
|
294
|
+
active_record.generate_secure_token_on = :initialize
|
295
|
+
end
|
296
|
+
|
297
|
+
if respond_to?(:action_dispatch)
|
298
|
+
action_dispatch.default_headers = {
|
299
|
+
"X-Frame-Options" => "SAMEORIGIN",
|
300
|
+
"X-XSS-Protection" => "0",
|
301
|
+
"X-Content-Type-Options" => "nosniff",
|
302
|
+
"X-Permitted-Cross-Domain-Policies" => "none",
|
303
|
+
"Referrer-Policy" => "strict-origin-when-cross-origin"
|
304
|
+
}
|
305
|
+
action_dispatch.debug_exception_log_level = :error
|
306
|
+
end
|
307
|
+
|
308
|
+
if respond_to?(:active_job)
|
309
|
+
active_job.use_big_decimal_serializer = true
|
310
|
+
end
|
311
|
+
|
312
|
+
if respond_to?(:active_support)
|
313
|
+
active_support.cache_format_version = 7.1
|
314
|
+
active_support.message_serializer = :json_allow_marshal
|
315
|
+
active_support.use_message_serializer_for_metadata = true
|
316
|
+
active_support.raise_on_invalid_cache_expiration_time = true
|
317
|
+
end
|
318
|
+
|
319
|
+
if respond_to?(:action_controller)
|
320
|
+
action_controller.allow_deprecated_parameters_hash_equality = false
|
321
|
+
end
|
322
|
+
|
323
|
+
if defined?(Rails::HTML::Sanitizer) # nested ifs to avoid linter errors
|
324
|
+
if respond_to?(:action_view)
|
325
|
+
action_view.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor
|
326
|
+
end
|
327
|
+
|
328
|
+
if respond_to?(:action_text)
|
329
|
+
action_text.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor
|
330
|
+
end
|
153
331
|
end
|
154
332
|
else
|
155
333
|
raise "Unknown version #{target_version.to_s.inspect}"
|
@@ -158,6 +336,34 @@ module Rails
|
|
158
336
|
@loaded_config_version = target_version
|
159
337
|
end
|
160
338
|
|
339
|
+
def reloading_enabled?
|
340
|
+
enable_reloading
|
341
|
+
end
|
342
|
+
|
343
|
+
def enable_reloading
|
344
|
+
!cache_classes
|
345
|
+
end
|
346
|
+
|
347
|
+
def enable_reloading=(value)
|
348
|
+
self.cache_classes = !value
|
349
|
+
end
|
350
|
+
|
351
|
+
ENABLE_DEPENDENCY_LOADING_WARNING = <<~MSG
|
352
|
+
This flag addressed a limitation of the `classic` autoloader and has no effect nowadays.
|
353
|
+
To fix this deprecation, please just delete the reference.
|
354
|
+
MSG
|
355
|
+
private_constant :ENABLE_DEPENDENCY_LOADING_WARNING
|
356
|
+
|
357
|
+
def enable_dependency_loading
|
358
|
+
Rails.deprecator.warn(ENABLE_DEPENDENCY_LOADING_WARNING)
|
359
|
+
@enable_dependency_loading
|
360
|
+
end
|
361
|
+
|
362
|
+
def enable_dependency_loading=(value)
|
363
|
+
Rails.deprecator.warn(ENABLE_DEPENDENCY_LOADING_WARNING)
|
364
|
+
@enable_dependency_loading = value
|
365
|
+
end
|
366
|
+
|
161
367
|
def encoding=(value)
|
162
368
|
@encoding = value
|
163
369
|
silence_warnings do
|
@@ -173,6 +379,15 @@ module Rails
|
|
173
379
|
@debug_exception_response_format ||= :api
|
174
380
|
end
|
175
381
|
|
382
|
+
def log_level=(level)
|
383
|
+
@log_level = level
|
384
|
+
@broadcast_log_level = level
|
385
|
+
end
|
386
|
+
|
387
|
+
def broadcast_log_level # :nodoc:
|
388
|
+
defined?(@broadcast_log_level) ? @broadcast_log_level : nil
|
389
|
+
end
|
390
|
+
|
176
391
|
def debug_exception_response_format
|
177
392
|
@debug_exception_response_format || :default
|
178
393
|
end
|
@@ -195,21 +410,22 @@ module Rails
|
|
195
410
|
end
|
196
411
|
end
|
197
412
|
|
198
|
-
# Load the database
|
199
|
-
#
|
200
|
-
# configuration values
|
201
|
-
# method.
|
413
|
+
# Load the <tt>config/database.yml</tt> to create the Rake tasks for
|
414
|
+
# multiple databases without loading the environment and filling in the
|
415
|
+
# environment specific configuration values.
|
202
416
|
#
|
203
|
-
#
|
204
|
-
# tags and load the database.yml for the rake tasks.
|
417
|
+
# Do not use this method, use #database_configuration instead.
|
205
418
|
def load_database_yaml # :nodoc:
|
206
419
|
if path = paths["config/database"].existent.first
|
207
|
-
require "rails/application/
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
420
|
+
require "rails/application/dummy_config"
|
421
|
+
original_rails_config = Rails.application.config
|
422
|
+
|
423
|
+
begin
|
424
|
+
Rails.application.config = DummyConfig.new(original_rails_config)
|
425
|
+
ActiveSupport::ConfigurationFile.parse(Pathname.new(path))
|
426
|
+
ensure
|
427
|
+
Rails.application.config = original_rails_config
|
428
|
+
end
|
213
429
|
else
|
214
430
|
{}
|
215
431
|
end
|
@@ -221,14 +437,23 @@ module Rails
|
|
221
437
|
path = paths["config/database"].existent.first
|
222
438
|
yaml = Pathname.new(path) if path
|
223
439
|
|
224
|
-
config = if yaml
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
440
|
+
config = if yaml&.exist?
|
441
|
+
loaded_yaml = ActiveSupport::ConfigurationFile.parse(yaml)
|
442
|
+
if (shared = loaded_yaml.delete("shared"))
|
443
|
+
loaded_yaml.each do |env, config|
|
444
|
+
if config.is_a?(Hash) && config.values.all?(Hash)
|
445
|
+
if shared.is_a?(Hash) && shared.values.all?(Hash)
|
446
|
+
config.map do |name, sub_config|
|
447
|
+
sub_config.reverse_merge!(shared[name])
|
448
|
+
end
|
449
|
+
else
|
450
|
+
config.map do |name, sub_config|
|
451
|
+
sub_config.reverse_merge!(shared)
|
452
|
+
end
|
453
|
+
end
|
454
|
+
else
|
455
|
+
config.reverse_merge!(shared)
|
456
|
+
end
|
232
457
|
end
|
233
458
|
end
|
234
459
|
Hash.new(shared).merge(loaded_yaml)
|
@@ -241,14 +466,34 @@ module Rails
|
|
241
466
|
end
|
242
467
|
|
243
468
|
config
|
244
|
-
rescue Psych::SyntaxError => e
|
245
|
-
raise "YAML syntax error occurred while parsing #{paths["config/database"].first}. " \
|
246
|
-
"Please note that YAML must be consistently indented using spaces. Tabs are not allowed. " \
|
247
|
-
"Error: #{e.message}"
|
248
469
|
rescue => e
|
249
470
|
raise e, "Cannot load database configuration:\n#{e.message}", e.backtrace
|
250
471
|
end
|
251
472
|
|
473
|
+
def autoload_lib(ignore:)
|
474
|
+
lib = root.join("lib")
|
475
|
+
|
476
|
+
# Set as a string to have the same type as default autoload paths, for
|
477
|
+
# consistency.
|
478
|
+
autoload_paths << lib.to_s
|
479
|
+
eager_load_paths << lib.to_s
|
480
|
+
|
481
|
+
ignored_abspaths = Array.wrap(ignore).map { lib.join(_1) }
|
482
|
+
Rails.autoloaders.main.ignore(ignored_abspaths)
|
483
|
+
end
|
484
|
+
|
485
|
+
def autoload_lib_once(ignore:)
|
486
|
+
lib = root.join("lib")
|
487
|
+
|
488
|
+
# Set as a string to have the same type as default autoload paths, for
|
489
|
+
# consistency.
|
490
|
+
autoload_once_paths << lib.to_s
|
491
|
+
eager_load_paths << lib.to_s
|
492
|
+
|
493
|
+
ignored_abspaths = Array.wrap(ignore).map { lib.join(_1) }
|
494
|
+
Rails.autoloaders.once.ignore(ignored_abspaths)
|
495
|
+
end
|
496
|
+
|
252
497
|
def colorize_logging
|
253
498
|
ActiveSupport::LogSubscriber.colorize_logging
|
254
499
|
end
|
@@ -258,34 +503,38 @@ module Rails
|
|
258
503
|
generators.colorize_logging = val
|
259
504
|
end
|
260
505
|
|
506
|
+
# Specifies what class to use to store the session. Possible values
|
507
|
+
# are +:cache_store+, +:cookie_store+, +:mem_cache_store+, a custom
|
508
|
+
# store, or +:disabled+. +:disabled+ tells \Rails not to deal with
|
509
|
+
# sessions.
|
510
|
+
#
|
511
|
+
# Additional options will be set as +session_options+:
|
512
|
+
#
|
513
|
+
# config.session_store :cookie_store, key: "_your_app_session"
|
514
|
+
# config.session_options # => {key: "_your_app_session"}
|
515
|
+
#
|
516
|
+
# If a custom store is specified as a symbol, it will be resolved to
|
517
|
+
# the +ActionDispatch::Session+ namespace:
|
518
|
+
#
|
519
|
+
# # use ActionDispatch::Session::MyCustomStore as the session store
|
520
|
+
# config.session_store :my_custom_store
|
261
521
|
def session_store(new_session_store = nil, **options)
|
262
522
|
if new_session_store
|
263
|
-
if new_session_store == :active_record_store
|
264
|
-
begin
|
265
|
-
ActionDispatch::Session::ActiveRecordStore
|
266
|
-
rescue NameError
|
267
|
-
raise "`ActiveRecord::SessionStore` is extracted out of Rails into a gem. " \
|
268
|
-
"Please add `activerecord-session_store` to your Gemfile to use it."
|
269
|
-
end
|
270
|
-
end
|
271
|
-
|
272
523
|
@session_store = new_session_store
|
273
524
|
@session_options = options || {}
|
274
525
|
else
|
275
526
|
case @session_store
|
276
527
|
when :disabled
|
277
528
|
nil
|
278
|
-
when :active_record_store
|
279
|
-
ActionDispatch::Session::ActiveRecordStore
|
280
529
|
when Symbol
|
281
|
-
ActionDispatch::Session.
|
530
|
+
ActionDispatch::Session.resolve_store(@session_store)
|
282
531
|
else
|
283
532
|
@session_store
|
284
533
|
end
|
285
534
|
end
|
286
535
|
end
|
287
536
|
|
288
|
-
def session_store?
|
537
|
+
def session_store? # :nodoc:
|
289
538
|
@session_store
|
290
539
|
end
|
291
540
|
|
@@ -293,6 +542,7 @@ module Rails
|
|
293
542
|
Rails::SourceAnnotationExtractor::Annotation
|
294
543
|
end
|
295
544
|
|
545
|
+
# Configures the ActionDispatch::ContentSecurityPolicy.
|
296
546
|
def content_security_policy(&block)
|
297
547
|
if block_given?
|
298
548
|
@content_security_policy = ActionDispatch::ContentSecurityPolicy.new(&block)
|
@@ -301,15 +551,12 @@ module Rails
|
|
301
551
|
end
|
302
552
|
end
|
303
553
|
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
@
|
308
|
-
when :zeitwerk
|
309
|
-
require "zeitwerk"
|
310
|
-
@autoloader = autoloader
|
554
|
+
# Configures the ActionDispatch::PermissionsPolicy.
|
555
|
+
def permissions_policy(&block)
|
556
|
+
if block_given?
|
557
|
+
@permissions_policy = ActionDispatch::PermissionsPolicy.new(&block)
|
311
558
|
else
|
312
|
-
|
559
|
+
@permissions_policy
|
313
560
|
end
|
314
561
|
end
|
315
562
|
|
@@ -325,14 +572,18 @@ module Rails
|
|
325
572
|
f
|
326
573
|
end
|
327
574
|
|
328
|
-
|
575
|
+
def inspect # :nodoc:
|
576
|
+
"#<#{self.class.name}:#{'%#016x' % (object_id << 1)}>"
|
577
|
+
end
|
578
|
+
|
579
|
+
class Custom # :nodoc:
|
329
580
|
def initialize
|
330
581
|
@configurations = Hash.new
|
331
582
|
end
|
332
583
|
|
333
584
|
def method_missing(method, *args)
|
334
|
-
if method
|
335
|
-
@configurations[
|
585
|
+
if method.end_with?("=")
|
586
|
+
@configurations[:"#{method[0..-2]}"] = args.first
|
336
587
|
else
|
337
588
|
@configurations.fetch(method) {
|
338
589
|
@configurations[method] = ActiveSupport::OrderedOptions.new
|
@@ -346,24 +597,14 @@ module Rails
|
|
346
597
|
end
|
347
598
|
|
348
599
|
private
|
349
|
-
def
|
350
|
-
|
351
|
-
|
352
|
-
else
|
353
|
-
root.join("config", "credentials.yml.enc")
|
354
|
-
end
|
355
|
-
end
|
600
|
+
def credentials_defaults
|
601
|
+
content_path = root.join("config/credentials/#{Rails.env}.yml.enc")
|
602
|
+
content_path = root.join("config/credentials.yml.enc") if !content_path.exist?
|
356
603
|
|
357
|
-
|
358
|
-
if
|
359
|
-
root.join("config", "credentials", "#{Rails.env}.key")
|
360
|
-
else
|
361
|
-
root.join("config", "master.key")
|
362
|
-
end
|
363
|
-
end
|
604
|
+
key_path = root.join("config/credentials/#{Rails.env}.key")
|
605
|
+
key_path = root.join("config/master.key") if !key_path.exist?
|
364
606
|
|
365
|
-
|
366
|
-
File.exist?(root.join("config", "credentials", "#{Rails.env}.yml.enc"))
|
607
|
+
{ content_path: content_path, key_path: key_path }
|
367
608
|
end
|
368
609
|
end
|
369
610
|
end
|
@@ -13,10 +13,17 @@ module Rails
|
|
13
13
|
|
14
14
|
def build_stack
|
15
15
|
ActionDispatch::MiddlewareStack.new do |middleware|
|
16
|
-
|
16
|
+
unless Array(config.hosts).empty?
|
17
|
+
middleware.use ::ActionDispatch::HostAuthorization, config.hosts, **config.host_authorization
|
18
|
+
end
|
19
|
+
|
20
|
+
if config.assume_ssl
|
21
|
+
middleware.use ::ActionDispatch::AssumeSSL
|
22
|
+
end
|
17
23
|
|
18
24
|
if config.force_ssl
|
19
|
-
middleware.use ::ActionDispatch::SSL, config.ssl_options
|
25
|
+
middleware.use ::ActionDispatch::SSL, **config.ssl_options,
|
26
|
+
ssl_default_redirect_status: config.action_dispatch.ssl_default_redirect_status
|
20
27
|
end
|
21
28
|
|
22
29
|
middleware.use ::Rack::Sendfile, config.action_dispatch.x_sendfile_header
|
@@ -41,17 +48,21 @@ module Rails
|
|
41
48
|
|
42
49
|
middleware.use ::ActionDispatch::Executor, app.executor
|
43
50
|
|
51
|
+
middleware.use ::ActionDispatch::ServerTiming if config.server_timing
|
44
52
|
middleware.use ::Rack::Runtime
|
45
53
|
middleware.use ::Rack::MethodOverride unless config.api_only
|
46
|
-
middleware.use ::ActionDispatch::RequestId
|
54
|
+
middleware.use ::ActionDispatch::RequestId, header: config.action_dispatch.request_id_header
|
47
55
|
middleware.use ::ActionDispatch::RemoteIp, config.action_dispatch.ip_spoofing_check, config.action_dispatch.trusted_proxies
|
48
56
|
|
49
57
|
middleware.use ::Rails::Rack::Logger, config.log_tags
|
50
58
|
middleware.use ::ActionDispatch::ShowExceptions, show_exceptions_app
|
51
59
|
middleware.use ::ActionDispatch::DebugExceptions, app, config.debug_exception_response_format
|
52
|
-
middleware.use ::ActionDispatch::ActionableExceptions
|
53
60
|
|
54
|
-
|
61
|
+
if config.consider_all_requests_local
|
62
|
+
middleware.use ::ActionDispatch::ActionableExceptions
|
63
|
+
end
|
64
|
+
|
65
|
+
if config.reloading_enabled?
|
55
66
|
middleware.use ::ActionDispatch::Reloader, app.reloader
|
56
67
|
end
|
57
68
|
|
@@ -63,11 +74,12 @@ module Rails
|
|
63
74
|
config.session_options[:secure] = true
|
64
75
|
end
|
65
76
|
middleware.use config.session_store, config.session_options
|
66
|
-
middleware.use ::ActionDispatch::Flash
|
67
77
|
end
|
68
78
|
|
69
79
|
unless config.api_only
|
80
|
+
middleware.use ::ActionDispatch::Flash
|
70
81
|
middleware.use ::ActionDispatch::ContentSecurityPolicy::Middleware
|
82
|
+
middleware.use ::ActionDispatch::PermissionsPolicy::Middleware
|
71
83
|
end
|
72
84
|
|
73
85
|
middleware.use ::Rack::Head
|
@@ -75,11 +87,25 @@ module Rails
|
|
75
87
|
middleware.use ::Rack::ETag, "no-cache"
|
76
88
|
|
77
89
|
middleware.use ::Rack::TempfileReaper unless config.api_only
|
90
|
+
|
91
|
+
if config.respond_to?(:active_record)
|
92
|
+
if selector_options = config.active_record.database_selector
|
93
|
+
resolver = config.active_record.database_resolver
|
94
|
+
context = config.active_record.database_resolver_context
|
95
|
+
|
96
|
+
middleware.use ::ActiveRecord::Middleware::DatabaseSelector, resolver, context, selector_options
|
97
|
+
end
|
98
|
+
|
99
|
+
if shard_resolver = config.active_record.shard_resolver
|
100
|
+
options = config.active_record.shard_selector || {}
|
101
|
+
|
102
|
+
middleware.use ::ActiveRecord::Middleware::ShardSelector, shard_resolver, options
|
103
|
+
end
|
104
|
+
end
|
78
105
|
end
|
79
106
|
end
|
80
107
|
|
81
108
|
private
|
82
|
-
|
83
109
|
def load_rack_cache
|
84
110
|
rack_cache = config.action_dispatch.rack_cache
|
85
111
|
return unless rack_cache
|