Sha256: ad6d8ac111491aad9804de160899ac2d8ab4a84829a1bcd9057452bcf456b014

Contents?: true

Size: 1.88 KB

Versions: 1

Compression:

Stored size: 1.88 KB

Contents

require 'secure_headers'
require_relative './secure_headers'

module CoalescingPanda
  class Engine < ::Rails::Engine
    config.autoload_once_paths += Dir["#{config.root}/lib/**/"]
    isolate_namespace CoalescingPanda

    config.generators do |g|
      g.test_framework :rspec
      g.fixture_replacement :factory_girl, :dir => 'spec/factories'
    end

    initializer :append_migrations do |app|
      unless app.root.to_s.match root.to_s
        config.paths["db/migrate"].expanded.each do |expanded_path|
          app.config.paths["db/migrate"] << expanded_path
        end
      end
    end

    initializer 'coalescing_panda.app_controller' do |app|
      OAUTH_10_SUPPORT = true
      ActiveSupport.on_load(:action_controller) do
        include CoalescingPanda::ControllerHelpers
      end
    end

    initializer 'coalescing_panda.assets' do |app|
      app.config.assets.precompile << 'coalescing_panda/manifest.js'
    end

    initializer 'cloaescing_panda.route_helper' do |route|
      ActionDispatch::Routing::Mapper.send :include, CoalescingPanda::RouteHelpers
    end

    config.after_initialize do |app|
      ActiveSupport.on_load(:action_controller) do
        #force the routes to load
        Rails.application.reload_routes!
        CoalescingPanda::propagate_lti_navigation
      end
    end

    initializer :secure_headers do |app|
      begin
        ::SecureHeaders::Configuration.default do |config|
          CoalescingPanda::SecureHeaders.apply_defaults(config)
        end
      rescue ::SecureHeaders::Configuration::AlreadyConfiguredError
        # The App already applied settings
      end

      ::SecureHeaders::Configuration.override(:safari_override) do |config|
        config.cookies = SecureHeaders::OPT_OUT
      end

      ::SecureHeaders::Configuration.override(:allow_inline_scripts) do |config|
        config.csp[:script_src] << "'unsafe-inline'"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
coalescing_panda-5.2.2 lib/coalescing_panda/engine.rb