Created
August 21, 2019 15:10
-
-
Save mark-d-holmberg/7df6af48f3b7b16a5db667695853e939 to your computer and use it in GitHub Desktop.
Because API only Rails Apps don't need no cookies!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://github.com/rails-api/rails-api/issues/72 | |
# https://github.com/rails/rails/blob/v5.2.3/railties/lib/rails/application.rb#L579 | |
Rails::Application.class_eval do | |
if defined?(::Rails.logger) | |
Rails.logger.warn '[initializers][AA_rails_hacks] - Patching Rails Application class' | |
else | |
puts '[initializers][AA_rails_hacks] - Patching Rails Application class' | |
end | |
def secret_key_base | |
if Rails.env.development? || Rails.env.test? || config.api_only == true | |
secrets.secret_key_base ||= generate_development_secret | |
else | |
validate_secret_key_base( | |
ENV["SECRET_KEY_BASE"] || credentials.secret_key_base || secrets.secret_key_base | |
) | |
end | |
end | |
def env_config | |
@app_env_config ||= begin | |
validate_secret_key_config! unless config.api_only == true | |
super.merge( | |
"action_dispatch.parameter_filter" => config.filter_parameters, | |
"action_dispatch.redirect_filter" => config.filter_redirect, | |
"action_dispatch.secret_token" => secrets.secret_token, | |
"action_dispatch.secret_key_base" => secrets.secret_key_base, | |
"action_dispatch.show_exceptions" => config.action_dispatch.show_exceptions, | |
"action_dispatch.show_detailed_exceptions" => config.consider_all_requests_local, | |
"action_dispatch.logger" => Rails.logger, | |
"action_dispatch.backtrace_cleaner" => Rails.backtrace_cleaner, | |
"action_dispatch.key_generator" => key_generator, | |
"action_dispatch.http_auth_salt" => config.action_dispatch.http_auth_salt, | |
"action_dispatch.signed_cookie_salt" => config.action_dispatch.signed_cookie_salt, | |
"action_dispatch.encrypted_cookie_salt" => config.action_dispatch.encrypted_cookie_salt, | |
"action_dispatch.encrypted_signed_cookie_salt" => config.action_dispatch.encrypted_signed_cookie_salt, | |
"action_dispatch.cookies_serializer" => config.action_dispatch.cookies_serializer, | |
"action_dispatch.cookies_digest" => config.action_dispatch.cookies_digest | |
) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment