From f9ef84358eb3a68f47ab820a0a5a8b28653e08bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Gal=C3=A1n?= Date: Wed, 30 Aug 2023 11:37:40 +0200 Subject: [PATCH 1/5] Upgrade application to rails 5.0.7.2 --- Gemfile | 6 +- Gemfile.lock | 202 +++++++++++++--------- app/assets/config/manifest.js | 3 + app/models/account.rb | 2 +- app/models/application_record.rb | 5 + bin/rails | 6 +- bin/rake | 4 - config/application.rb | 19 +- config/boot.rb | 5 +- config/environment.rb | 2 +- config/environments/development.rb | 31 +++- config/environments/production.rb | 58 ++++--- config/environments/test.rb | 9 +- config/initializers/assets.rb | 3 + config/initializers/cookies_serializer.rb | 4 +- config/initializers/session_store.rb | 2 +- config/initializers/wrap_parameters.rb | 4 +- config/secrets.yml | 6 +- 18 files changed, 216 insertions(+), 155 deletions(-) create mode 100644 app/assets/config/manifest.js create mode 100644 app/models/application_record.rb diff --git a/Gemfile b/Gemfile index 08053d8..48a8776 100644 --- a/Gemfile +++ b/Gemfile @@ -5,11 +5,11 @@ gem 'ruby-saml', '~> 1.7.0' gem 'byebug' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '4.1.5' +gem 'rails', '5.0.7.2' # Use sqlite3 as the database for Active Record gem 'sqlite3' # Use SCSS for stylesheets -gem 'sass-rails', '~> 4.0.3' +gem 'sass-rails' # Use Uglifier as compressor for JavaScript assets #gem 'uglifier', '>= 1.3.0' # Use CoffeeScript for .js.coffee assets and views @@ -40,4 +40,4 @@ gem 'spring', group: :development # Use debugger # gem 'debugger', group: [:development, :test] - +gem 'activemodel-serializers-xml' diff --git a/Gemfile.lock b/Gemfile.lock index 247fc3c..a5a3e48 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,116 +1,164 @@ GEM remote: https://rubygems.org/ specs: - actionmailer (4.1.5) - actionpack (= 4.1.5) - actionview (= 4.1.5) - mail (~> 2.5.4) - actionpack (4.1.5) - actionview (= 4.1.5) - activesupport (= 4.1.5) - rack (~> 1.5.2) - rack-test (~> 0.6.2) - actionview (4.1.5) - activesupport (= 4.1.5) + actioncable (5.0.7.2) + actionpack (= 5.0.7.2) + nio4r (>= 1.2, < 3.0) + websocket-driver (~> 0.6.1) + actionmailer (5.0.7.2) + actionpack (= 5.0.7.2) + actionview (= 5.0.7.2) + activejob (= 5.0.7.2) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.0.7.2) + actionview (= 5.0.7.2) + activesupport (= 5.0.7.2) + rack (~> 2.0) + rack-test (~> 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.0.7.2) + activesupport (= 5.0.7.2) builder (~> 3.1) erubis (~> 2.7.0) - activemodel (4.1.5) - activesupport (= 4.1.5) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.0.7.2) + activesupport (= 5.0.7.2) + globalid (>= 0.3.6) + activemodel (5.0.7.2) + activesupport (= 5.0.7.2) + activemodel-serializers-xml (1.0.2) + activemodel (> 5.x) + activesupport (> 5.x) builder (~> 3.1) - activerecord (4.1.5) - activemodel (= 4.1.5) - activesupport (= 4.1.5) - arel (~> 5.0.0) - activesupport (4.1.5) - i18n (~> 0.6, >= 0.6.9) - json (~> 1.7, >= 1.7.7) + activerecord (5.0.7.2) + activemodel (= 5.0.7.2) + activesupport (= 5.0.7.2) + arel (~> 7.0) + activesupport (5.0.7.2) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) minitest (~> 5.1) - thread_safe (~> 0.1) tzinfo (~> 1.1) - arel (5.0.1.20140414130214) + arel (7.1.4) builder (3.2.2) byebug (3.5.1) columnize (~> 0.8) debugger-linecache (~> 1.2) slop (~> 3.6) columnize (0.9.0) + concurrent-ruby (1.2.2) + crass (1.0.6) + date (3.3.3) debugger-linecache (1.2.0) erubis (2.7.0) - hike (1.2.3) + ffi (1.15.5) + globalid (1.1.0) + activesupport (>= 5.0) i18n (0.7.0) - jbuilder (2.2.6) - activesupport (>= 3.0.0, < 5) - multi_json (~> 1.2) - json (1.8.1) - macaddr (1.7.1) - systemu (~> 2.6.2) - mail (2.5.4) - mime-types (~> 1.16) - treetop (~> 1.4.8) - mime-types (1.25.1) - mini_portile (0.6.2) + jbuilder (2.11.5) + actionview (>= 5.0.0) + activesupport (>= 5.0.0) + loofah (2.21.3) + crass (~> 1.0.2) + nokogiri (>= 1.12.0) + mail (2.8.1) + mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp + method_source (1.0.0) + mini_mime (1.1.5) + mini_portile2 (2.8.4) minitest (5.5.0) - multi_json (1.10.1) - nokogiri (1.6.6.2) - mini_portile (~> 0.6.0) - polyglot (0.3.5) - rack (1.5.2) - rack-test (0.6.2) + net-imap (0.3.7) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.1) + timeout + net-smtp (0.3.3) + net-protocol + nio4r (2.5.9) + nokogiri (1.13.10) + mini_portile2 (~> 2.8.0) + racc (~> 1.4) + racc (1.7.1) + rack (2.2.8) + rack-test (0.6.3) rack (>= 1.0) - rails (4.1.5) - actionmailer (= 4.1.5) - actionpack (= 4.1.5) - actionview (= 4.1.5) - activemodel (= 4.1.5) - activerecord (= 4.1.5) - activesupport (= 4.1.5) - bundler (>= 1.3.0, < 2.0) - railties (= 4.1.5) - sprockets-rails (~> 2.0) - railties (4.1.5) - actionpack (= 4.1.5) - activesupport (= 4.1.5) + rails (5.0.7.2) + actioncable (= 5.0.7.2) + actionmailer (= 5.0.7.2) + actionpack (= 5.0.7.2) + actionview (= 5.0.7.2) + activejob (= 5.0.7.2) + activemodel (= 5.0.7.2) + activerecord (= 5.0.7.2) + activesupport (= 5.0.7.2) + bundler (>= 1.3.0) + railties (= 5.0.7.2) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.2.0) + activesupport (>= 5.0.0) + minitest + nokogiri (>= 1.6) + rails-html-sanitizer (1.5.0) + loofah (~> 2.19, >= 2.19.1) + railties (5.0.7.2) + actionpack (= 5.0.7.2) + activesupport (= 5.0.7.2) + method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rake (10.4.2) - sass (3.2.19) - sass-rails (4.0.5) - railties (>= 4.0.0, < 5.0) - sass (~> 3.2.2) - sprockets (~> 2.8, < 3.0) - sprockets-rails (~> 2.0) + ruby-saml (1.7.2) + nokogiri (>= 1.5.10) + sass-rails (6.0.0) + sassc-rails (~> 2.1, >= 2.1.1) + sassc (2.4.0) + ffi (~> 1.9) + sassc-rails (2.1.2) + railties (>= 4.0.0) + sassc (>= 2.0) + sprockets (> 3.0) + sprockets-rails + tilt slop (3.6.0) spring (1.2.0) - sprockets (2.12.3) - hike (~> 1.2) - multi_json (~> 1.0) - rack (~> 1.0) - tilt (~> 1.1, != 1.3.0) - sprockets-rails (2.2.2) - actionpack (>= 3.0) - activesupport (>= 3.0) - sprockets (>= 2.8, < 4.0) + sprockets (4.2.0) + concurrent-ruby (~> 1.0) + rack (>= 2.2.4, < 4) + sprockets-rails (3.2.2) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) sqlite3 (1.3.10) - systemu (2.6.5) thor (0.19.1) thread_safe (0.3.4) tilt (1.4.1) - treetop (1.4.15) - polyglot - polyglot (>= 0.3.1) + timeout (0.4.0) tzinfo (1.2.2) thread_safe (~> 0.1) - uuid (2.3.7) - macaddr (~> 1.0) + websocket-driver (0.6.5) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) PLATFORMS ruby DEPENDENCIES + activemodel-serializers-xml byebug jbuilder (~> 2.0) - rails (= 4.1.5) - ruby-saml (~> 1.3.0) - sass-rails (~> 4.0.3) + rails (= 5.0.7.2) + ruby-saml (~> 1.7.0) + sass-rails spring sqlite3 + +BUNDLED WITH + 2.4.10 diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js new file mode 100644 index 0000000..5cc2c08 --- /dev/null +++ b/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css \ No newline at end of file diff --git a/app/models/account.rb b/app/models/account.rb index 1209ed5..e8cf87e 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -1,4 +1,4 @@ -class Account < ActiveRecord::Base +class Account < ApplicationRecord def self.get_saml_settings(url_base) # this is just for testing purposes. # should retrieve SAML-settings based on subdomain, IP-address, NameID or similar diff --git a/app/models/application_record.rb b/app/models/application_record.rb new file mode 100644 index 0000000..71fbba5 --- /dev/null +++ b/app/models/application_record.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/bin/rails b/bin/rails index 7feb6a3..0739660 100755 --- a/bin/rails +++ b/bin/rails @@ -1,8 +1,4 @@ #!/usr/bin/env ruby -begin - load File.expand_path("../spring", __FILE__) -rescue LoadError -end -APP_PATH = File.expand_path('../../config/application', __FILE__) +APP_PATH = File.expand_path('../config/application', __dir__) require_relative '../config/boot' require 'rails/commands' diff --git a/bin/rake b/bin/rake index 8017a02..1724048 100755 --- a/bin/rake +++ b/bin/rake @@ -1,8 +1,4 @@ #!/usr/bin/env ruby -begin - load File.expand_path("../spring", __FILE__) -rescue LoadError -end require_relative '../config/boot' require 'rake' Rake.application.run diff --git a/config/application.rb b/config/application.rb index bb0e706..90e4ddc 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,13 +1,6 @@ -require File.expand_path('../boot', __FILE__) +require_relative 'boot' -# Pick the frameworks you want: -require "active_model/railtie" -require "active_record/railtie" -require "action_controller/railtie" -require "action_mailer/railtie" -require "action_view/railtie" -require "sprockets/railtie" -# require "rails/test_unit/railtie" +require 'rails/all' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. @@ -18,13 +11,5 @@ class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. - - # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. - # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. - # config.time_zone = 'Central Time (US & Canada)' - - # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. - # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] - # config.i18n.default_locale = :de end end diff --git a/config/boot.rb b/config/boot.rb index 5e5f0c1..30f5120 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,4 +1,3 @@ -# Set up gems listed in the Gemfile. -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) -require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) +require 'bundler/setup' # Set up gems listed in the Gemfile. diff --git a/config/environment.rb b/config/environment.rb index ee8d90d..426333b 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,5 +1,5 @@ # Load the Rails application. -require File.expand_path('../application', __FILE__) +require_relative 'application' # Initialize the Rails application. Rails.application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb index ddf0e90..e64889c 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -9,13 +9,28 @@ # Do not eager load code on boot. config.eager_load = false - # Show full error reports and disable caching. - config.consider_all_requests_local = true - config.action_controller.perform_caching = false + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + if Rails.root.join('tmp/caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => 'public, max-age=172800' + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false + config.action_mailer.perform_caching = false + # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log @@ -27,11 +42,13 @@ # number of complex assets. config.assets.debug = true - # Adds additional error checking when serving assets at runtime. - # Checks for improperly declared sprockets dependencies. - # Raises helpful error messages. - config.assets.raise_runtime_errors = true + # Suppress logger output for asset requests. + config.assets.quiet = true # Raises error for missing translations # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + # config.file_watcher = ActiveSupport::EventedFileUpdateChecker end diff --git a/config/environments/production.rb b/config/environments/production.rb index a8836c3..9e78eb4 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -14,13 +14,9 @@ config.consider_all_requests_local = false config.action_controller.perform_caching = true - # Enable Rack::Cache to put a simple HTTP cache in front of your application - # Add `rack-cache` to your Gemfile before enabling this. - # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. - # config.action_dispatch.rack_cache = true - - # Disable Rails's static asset server (Apache or nginx will already do this). - config.serve_static_assets = false + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? # Compress JavaScripts and CSS. config.assets.js_compressor = :uglifier @@ -29,36 +25,37 @@ # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = false - # Generate digests for assets URLs. - config.assets.digest = true + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb - # `config.assets.precompile` has moved to config/initializers/assets.rb + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' # Specifies the header that your server uses for sending files. - # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache - # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Mount Action Cable outside main process or domain + # config.action_cable.mount_path = nil + # config.action_cable.url = 'wss://example.com/cable' + # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true - # Set to :debug to see everything in the log. - config.log_level = :info + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug # Prepend all log lines with the following tags. - # config.log_tags = [ :subdomain, :uuid ] - - # Use a different logger for distributed setups. - # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + config.log_tags = [ :request_id ] # Use a different cache store in production. # config.cache_store = :mem_cache_store - # Enable serving of images, stylesheets, and JavaScripts from an asset server. - # config.action_controller.asset_host = "http://assets.example.com" - - # Precompile additional assets. - # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. - # config.assets.precompile += %w( search.js ) + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "rails_saml_#{Rails.env}" + config.action_mailer.perform_caching = false # Ignore bad email addresses and do not raise email delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors. @@ -71,12 +68,19 @@ # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify - # Disable automatic flushing of the log to improve performance. - # config.autoflush_log = false - # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false end diff --git a/config/environments/test.rb b/config/environments/test.rb index 053f5b6..30587ef 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -12,9 +12,11 @@ # preloads Rails for running tests, you may have to set it to true. config.eager_load = false - # Configure static asset server for tests with Cache-Control for performance. - config.serve_static_assets = true - config.static_cache_control = 'public, max-age=3600' + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => 'public, max-age=3600' + } # Show full error reports and disable caching. config.consider_all_requests_local = true @@ -25,6 +27,7 @@ # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false + config.action_mailer.perform_caching = false # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index d2f4ec3..01ef3e6 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -3,6 +3,9 @@ # Version of your assets, change this if you want to expire all your assets. Rails.application.config.assets.version = '1.0' +# Add additional assets to the asset load path +# Rails.application.config.assets.paths << Emoji.images_path + # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. # Rails.application.config.assets.precompile += %w( search.js ) diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb index 7a06a89..5a6a32d 100644 --- a/config/initializers/cookies_serializer.rb +++ b/config/initializers/cookies_serializer.rb @@ -1,3 +1,5 @@ # Be sure to restart your server when you modify this file. -Rails.application.config.action_dispatch.cookies_serializer = :json \ No newline at end of file +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index 94ace26..dc3ff94 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,3 +1,3 @@ # Be sure to restart your server when you modify this file. -Rails.application.config.session_store :cookie_store, key: '_rails-saml_session' +Rails.application.config.session_store :cookie_store, key: '_rails_saml_session' diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb index 33725e9..bbfc396 100644 --- a/config/initializers/wrap_parameters.rb +++ b/config/initializers/wrap_parameters.rb @@ -5,10 +5,10 @@ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. ActiveSupport.on_load(:action_controller) do - wrap_parameters format: [:json] if respond_to?(:wrap_parameters) + wrap_parameters format: [:json] end # To enable root element in JSON for ActiveRecord objects. # ActiveSupport.on_load(:active_record) do -# self.include_root_in_json = true +# self.include_root_in_json = true # end diff --git a/config/secrets.yml b/config/secrets.yml index 8621bb8..ea357ac 100644 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -5,16 +5,16 @@ # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attacks. -# You can use `rake secret` to generate a secure secret key. +# You can use `rails secret` to generate a secure secret key. # Make sure the secrets in this file are kept private # if you're sharing your code publicly. development: - secret_key_base: 2e14d0541d40eaa64ac9bc06105907990e049f0d64c9e225fb712abb90815d7f18de6d5e83e593b37adbf10c70138b645a68a733085f591b4cb719623975a628 + secret_key_base: ab55f359a9f2f70322e212fd08c1a4e1bed3850a3f2b6fc4f05499c359d9f9051ad0f6cf686c07237d12b0821532f331affa9e382f68ab9fd2519218027c431c test: - secret_key_base: 0fa2052cc63eb48f2cc3ea70e1cc14156bf3939ae08f02b7b3d1d920ede7621963b34569ad26ed3c83fbd2b465a4d313cba12eb784ece602c1e00d96cd6c4f14 + secret_key_base: 1579c71ef401c48f14f5b005191aba03f9a095106809824cb1dd00840b0a841b0a3298b5b95d34b7b824e568462df872716ef013dde250f2e37290a37d3583d0 # Do not keep production secrets in the repository, # instead read values from the environment. From f30fa44344f81fd2febe97254eeb2a7dd6e570e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Gal=C3=A1n?= Date: Wed, 30 Aug 2023 11:52:05 +0200 Subject: [PATCH 2/5] Upgrade application to rails 5.1.7 --- Gemfile | 4 +- Gemfile.lock | 80 +++++++++++++++--------------- config/application.rb | 3 ++ config/environments/development.rb | 4 +- config/environments/production.rb | 7 ++- config/environments/test.rb | 2 +- config/initializers/assets.rb | 9 ++-- config/locales/en.yml | 10 ++++ config/secrets.yml | 18 +++++-- 9 files changed, 84 insertions(+), 53 deletions(-) diff --git a/Gemfile b/Gemfile index 48a8776..d671ead 100644 --- a/Gemfile +++ b/Gemfile @@ -1,11 +1,11 @@ source 'https://rubygems.org' -gem 'ruby-saml', '~> 1.7.0' +gem 'ruby-saml' gem 'byebug' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '5.0.7.2' +gem 'rails', '5.1.7' # Use sqlite3 as the database for Active Record gem 'sqlite3' # Use SCSS for stylesheets diff --git a/Gemfile.lock b/Gemfile.lock index a5a3e48..43db72b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,48 +1,48 @@ GEM remote: https://rubygems.org/ specs: - actioncable (5.0.7.2) - actionpack (= 5.0.7.2) - nio4r (>= 1.2, < 3.0) + actioncable (5.1.7) + actionpack (= 5.1.7) + nio4r (~> 2.0) websocket-driver (~> 0.6.1) - actionmailer (5.0.7.2) - actionpack (= 5.0.7.2) - actionview (= 5.0.7.2) - activejob (= 5.0.7.2) + actionmailer (5.1.7) + actionpack (= 5.1.7) + actionview (= 5.1.7) + activejob (= 5.1.7) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.0.7.2) - actionview (= 5.0.7.2) - activesupport (= 5.0.7.2) + actionpack (5.1.7) + actionview (= 5.1.7) + activesupport (= 5.1.7) rack (~> 2.0) - rack-test (~> 0.6.3) + rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.0.7.2) - activesupport (= 5.0.7.2) + actionview (5.1.7) + activesupport (= 5.1.7) builder (~> 3.1) - erubis (~> 2.7.0) + erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.0.7.2) - activesupport (= 5.0.7.2) + activejob (5.1.7) + activesupport (= 5.1.7) globalid (>= 0.3.6) - activemodel (5.0.7.2) - activesupport (= 5.0.7.2) + activemodel (5.1.7) + activesupport (= 5.1.7) activemodel-serializers-xml (1.0.2) activemodel (> 5.x) activesupport (> 5.x) builder (~> 3.1) - activerecord (5.0.7.2) - activemodel (= 5.0.7.2) - activesupport (= 5.0.7.2) - arel (~> 7.0) - activesupport (5.0.7.2) + activerecord (5.1.7) + activemodel (= 5.1.7) + activesupport (= 5.1.7) + arel (~> 8.0) + activesupport (5.1.7) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) - arel (7.1.4) + arel (8.0.0) builder (3.2.2) byebug (3.5.1) columnize (~> 0.8) @@ -53,7 +53,7 @@ GEM crass (1.0.6) date (3.3.3) debugger-linecache (1.2.0) - erubis (2.7.0) + erubi (1.12.0) ffi (1.15.5) globalid (1.1.0) activesupport (>= 5.0) @@ -90,17 +90,17 @@ GEM rack (2.2.8) rack-test (0.6.3) rack (>= 1.0) - rails (5.0.7.2) - actioncable (= 5.0.7.2) - actionmailer (= 5.0.7.2) - actionpack (= 5.0.7.2) - actionview (= 5.0.7.2) - activejob (= 5.0.7.2) - activemodel (= 5.0.7.2) - activerecord (= 5.0.7.2) - activesupport (= 5.0.7.2) + rails (5.1.7) + actioncable (= 5.1.7) + actionmailer (= 5.1.7) + actionpack (= 5.1.7) + actionview (= 5.1.7) + activejob (= 5.1.7) + activemodel (= 5.1.7) + activerecord (= 5.1.7) + activesupport (= 5.1.7) bundler (>= 1.3.0) - railties (= 5.0.7.2) + railties (= 5.1.7) sprockets-rails (>= 2.0.0) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) @@ -108,9 +108,9 @@ GEM nokogiri (>= 1.6) rails-html-sanitizer (1.5.0) loofah (~> 2.19, >= 2.19.1) - railties (5.0.7.2) - actionpack (= 5.0.7.2) - activesupport (= 5.0.7.2) + railties (5.1.7) + actionpack (= 5.1.7) + activesupport (= 5.1.7) method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) @@ -154,8 +154,8 @@ DEPENDENCIES activemodel-serializers-xml byebug jbuilder (~> 2.0) - rails (= 5.0.7.2) - ruby-saml (~> 1.7.0) + rails (= 5.1.7) + ruby-saml sass-rails spring sqlite3 diff --git a/config/application.rb b/config/application.rb index 90e4ddc..fd4dbf5 100644 --- a/config/application.rb +++ b/config/application.rb @@ -8,6 +8,9 @@ module RailsSaml class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 5.1 + # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. diff --git a/config/environments/development.rb b/config/environments/development.rb index e64889c..5187e22 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -18,7 +18,7 @@ config.cache_store = :memory_store config.public_file_server.headers = { - 'Cache-Control' => 'public, max-age=172800' + 'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}" } else config.action_controller.perform_caching = false @@ -50,5 +50,5 @@ # Use an evented file watcher to asynchronously detect changes in source code, # routes, locales, etc. This feature depends on the listen gem. - # config.file_watcher = ActiveSupport::EventedFileUpdateChecker + config.file_watcher = ActiveSupport::EventedFileUpdateChecker end diff --git a/config/environments/production.rb b/config/environments/production.rb index 9e78eb4..8332f56 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -14,6 +14,11 @@ config.consider_all_requests_local = false config.action_controller.perform_caching = true + # Attempt to read encrypted secrets from `config/secrets.yml.enc`. + # Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or + # `config/secrets.yml.key`. + config.read_encrypted_secrets = true + # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? @@ -78,7 +83,7 @@ if ENV["RAILS_LOG_TO_STDOUT"].present? logger = ActiveSupport::Logger.new(STDOUT) logger.formatter = config.log_formatter - config.logger = ActiveSupport::TaggedLogging.new(logger) + config.logger = ActiveSupport::TaggedLogging.new(logger) end # Do not dump schema after migrations. diff --git a/config/environments/test.rb b/config/environments/test.rb index 30587ef..8e5cbde 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -15,7 +15,7 @@ # Configure public file server for tests with Cache-Control for performance. config.public_file_server.enabled = true config.public_file_server.headers = { - 'Cache-Control' => 'public, max-age=3600' + 'Cache-Control' => "public, max-age=#{1.hour.seconds.to_i}" } # Show full error reports and disable caching. diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 01ef3e6..4b828e8 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -3,9 +3,12 @@ # Version of your assets, change this if you want to expire all your assets. Rails.application.config.assets.version = '1.0' -# Add additional assets to the asset load path +# Add additional assets to the asset load path. # Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') # Precompile additional assets. -# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. -# Rails.application.config.assets.precompile += %w( search.js ) +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/config/locales/en.yml b/config/locales/en.yml index 0653957..decc5a8 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -16,6 +16,16 @@ # # This would use the information in config/locales/es.yml. # +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# 'true': 'foo' +# # To learn more, please read the Rails Internationalization guide # available at http://guides.rubyonrails.org/i18n.html. diff --git a/config/secrets.yml b/config/secrets.yml index ea357ac..ab72c69 100644 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -10,13 +10,23 @@ # Make sure the secrets in this file are kept private # if you're sharing your code publicly. +# Shared secrets are available across all environments. + +# shared: +# api_key: a1B2c3D4e5F6 + +# Environmental secrets are only available for that specific environment. + development: - secret_key_base: ab55f359a9f2f70322e212fd08c1a4e1bed3850a3f2b6fc4f05499c359d9f9051ad0f6cf686c07237d12b0821532f331affa9e382f68ab9fd2519218027c431c + secret_key_base: cec58cd381ca132fe0da299475eaf53a5691d4aa88b1feab53006b310a62d0c8c3f4ff82c7d06596f5d325e9718bd1ca412610c309d585990ac3e35c602ca227 test: - secret_key_base: 1579c71ef401c48f14f5b005191aba03f9a095106809824cb1dd00840b0a841b0a3298b5b95d34b7b824e568462df872716ef013dde250f2e37290a37d3583d0 + secret_key_base: a437a6ad16bf16dc94d4a7fa67a9d53d366d942b1a8dd96bc8a98de87726d2ad2c4fe40a9d426bbfcfce830a1c9710b1d36fbb9ec425fd0b7ab07c1bbc716508 + +# Do not keep production secrets in the unencrypted secrets file. +# Instead, either read values from the environment. +# Or, use `bin/rails secrets:setup` to configure encrypted secrets +# and move the `production:` environment over there. -# Do not keep production secrets in the repository, -# instead read values from the environment. production: secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> From 17202015ae6755f890afba0e06b3010fe678703a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Gal=C3=A1n?= Date: Wed, 30 Aug 2023 13:25:58 +0200 Subject: [PATCH 3/5] Upgrade application to rails 5.1.7 no versioned files and updated Gemfile --- Gemfile | 4 +++ Gemfile.lock | 35 ++++++++++--------- bin/yarn | 11 ++++++ .../new_framework_defaults_5_1.rb | 14 ++++++++ 4 files changed, 48 insertions(+), 16 deletions(-) create mode 100755 bin/yarn create mode 100644 config/initializers/new_framework_defaults_5_1.rb diff --git a/Gemfile b/Gemfile index d671ead..e238358 100644 --- a/Gemfile +++ b/Gemfile @@ -41,3 +41,7 @@ gem 'spring', group: :development # Use debugger # gem 'debugger', group: [:development, :test] gem 'activemodel-serializers-xml' + +group :development do + gem 'listen' +end diff --git a/Gemfile.lock b/Gemfile.lock index 43db72b..166fabb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -43,24 +43,23 @@ GEM minitest (~> 5.1) tzinfo (~> 1.1) arel (8.0.0) - builder (3.2.2) - byebug (3.5.1) - columnize (~> 0.8) - debugger-linecache (~> 1.2) - slop (~> 3.6) - columnize (0.9.0) + builder (3.2.4) + byebug (11.1.3) concurrent-ruby (1.2.2) crass (1.0.6) date (3.3.3) - debugger-linecache (1.2.0) erubi (1.12.0) ffi (1.15.5) globalid (1.1.0) activesupport (>= 5.0) - i18n (0.7.0) + i18n (1.14.1) + concurrent-ruby (~> 1.0) jbuilder (2.11.5) actionview (>= 5.0.0) activesupport (>= 5.0.0) + listen (3.8.0) + rb-fsevent (~> 0.10, >= 0.10.3) + rb-inotify (~> 0.9, >= 0.9.10) loofah (2.21.3) crass (~> 1.0.2) nokogiri (>= 1.12.0) @@ -72,7 +71,7 @@ GEM method_source (1.0.0) mini_mime (1.1.5) mini_portile2 (2.8.4) - minitest (5.5.0) + minitest (5.19.0) net-imap (0.3.7) date net-protocol @@ -114,7 +113,10 @@ GEM method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rake (10.4.2) + rake (13.0.6) + rb-fsevent (0.11.2) + rb-inotify (0.10.1) + ffi (~> 1.0) ruby-saml (1.7.2) nokogiri (>= 1.5.10) sass-rails (6.0.0) @@ -127,8 +129,7 @@ GEM sprockets (> 3.0) sprockets-rails tilt - slop (3.6.0) - spring (1.2.0) + spring (3.1.1) sprockets (4.2.0) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) @@ -137,11 +138,12 @@ GEM activesupport (>= 4.0) sprockets (>= 3.0.0) sqlite3 (1.3.10) - thor (0.19.1) - thread_safe (0.3.4) - tilt (1.4.1) + mini_portile2 (~> 2.8.0) + thor (1.2.2) + thread_safe (0.3.6) + tilt (2.2.0) timeout (0.4.0) - tzinfo (1.2.2) + tzinfo (1.2.11) thread_safe (~> 0.1) websocket-driver (0.6.5) websocket-extensions (>= 0.1.0) @@ -154,6 +156,7 @@ DEPENDENCIES activemodel-serializers-xml byebug jbuilder (~> 2.0) + listen rails (= 5.1.7) ruby-saml sass-rails diff --git a/bin/yarn b/bin/yarn new file mode 100755 index 0000000..c2bacef --- /dev/null +++ b/bin/yarn @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +VENDOR_PATH = File.expand_path('..', __dir__) +Dir.chdir(VENDOR_PATH) do + begin + exec "yarnpkg #{ARGV.join(" ")}" + rescue Errno::ENOENT + $stderr.puts "Yarn executable was not detected in the system." + $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" + exit 1 + end +end diff --git a/config/initializers/new_framework_defaults_5_1.rb b/config/initializers/new_framework_defaults_5_1.rb new file mode 100644 index 0000000..9010abd --- /dev/null +++ b/config/initializers/new_framework_defaults_5_1.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. +# +# This file contains migration options to ease your Rails 5.1 upgrade. +# +# Once upgraded flip defaults one by one to migrate to the new default. +# +# Read the Guide for Upgrading Ruby on Rails for more info on each option. + +# Make `form_with` generate non-remote forms. +Rails.application.config.action_view.form_with_generates_remote_forms = false + +# Unknown asset fallback will return the path passed in when the given +# asset is not present in the asset pipeline. +# Rails.application.config.assets.unknown_asset_fallback = false From 00a73a084f413762b60f4fbc0de22d2a98fad47a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Gal=C3=A1n?= Date: Wed, 30 Aug 2023 13:29:55 +0200 Subject: [PATCH 4/5] Add puma gem and delete old ruby-version restriction --- .ruby-version | 1 - Gemfile | 1 + Gemfile.lock | 3 +++ 3 files changed, 4 insertions(+), 1 deletion(-) delete mode 100644 .ruby-version diff --git a/.ruby-version b/.ruby-version deleted file mode 100644 index 0660e18..0000000 --- a/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -ruby-2.0.2@ruby-saml-example diff --git a/Gemfile b/Gemfile index e238358..201031d 100644 --- a/Gemfile +++ b/Gemfile @@ -28,6 +28,7 @@ gem 'jbuilder', '~> 2.0' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring', group: :development +gem 'puma' # Use ActiveModel has_secure_password # gem 'bcrypt', '~> 3.1.7' diff --git a/Gemfile.lock b/Gemfile.lock index 166fabb..0857f60 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -85,6 +85,8 @@ GEM nokogiri (1.13.10) mini_portile2 (~> 2.8.0) racc (~> 1.4) + puma (6.2.2) + nio4r (~> 2.0) racc (1.7.1) rack (2.2.8) rack-test (0.6.3) @@ -157,6 +159,7 @@ DEPENDENCIES byebug jbuilder (~> 2.0) listen + puma rails (= 5.1.7) ruby-saml sass-rails From f00a8cec47ca300ca48481e8245ec99013aabb80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Gal=C3=A1n?= Date: Wed, 30 Aug 2023 13:31:55 +0200 Subject: [PATCH 5/5] update ruby-saml gem --- Gemfile.lock | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 0857f60..04f7a44 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -119,8 +119,10 @@ GEM rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) - ruby-saml (1.7.2) - nokogiri (>= 1.5.10) + rexml (3.2.6) + ruby-saml (1.15.0) + nokogiri (>= 1.13.10) + rexml sass-rails (6.0.0) sassc-rails (~> 2.1, >= 2.1.1) sassc (2.4.0)