prx_auth-rails 4.1.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.git-blame-ignore-revs +2 -0
- data/.github/workflows/check-project-std.yml +23 -0
- data/Gemfile +1 -1
- data/Guardfile +5 -5
- data/Rakefile +3 -3
- data/app/controllers/prx_auth/rails/sessions_controller.rb +15 -14
- data/app/views/prx_auth/rails/sessions/auth_error.html.erb +0 -7
- data/config/initializers/assets.rb +1 -1
- data/config/routes.rb +3 -3
- data/lib/prx_auth/rails/configuration.rb +15 -15
- data/lib/prx_auth/rails/engine.rb +1 -1
- data/lib/prx_auth/rails/ext/controller.rb +20 -20
- data/lib/prx_auth/rails/railtie.rb +3 -3
- data/lib/prx_auth/rails/token.rb +17 -4
- data/lib/prx_auth/rails/version.rb +1 -1
- data/lib/prx_auth/rails.rb +3 -3
- data/prx_auth-rails.gemspec +25 -26
- data/test/dummy/app/controllers/application_controller.rb +3 -3
- data/test/dummy/app/mailers/application_mailer.rb +2 -2
- data/test/dummy/bin/rails +1 -1
- data/test/dummy/bin/setup +7 -7
- data/test/dummy/config/boot.rb +2 -2
- data/test/dummy/config/environments/development.rb +2 -2
- data/test/dummy/config/environments/production.rb +5 -5
- data/test/dummy/config/environments/test.rb +2 -2
- data/test/dummy/config/initializers/assets.rb +1 -1
- data/test/dummy/config/initializers/prx_auth.rb +7 -7
- data/test/dummy/config/routes.rb +2 -2
- data/test/prx_auth/rails/configuration_test.rb +14 -15
- data/test/prx_auth/rails/ext/controller_test.rb +80 -81
- data/test/prx_auth/rails/sessions_controller_test.rb +39 -41
- data/test/prx_auth/rails/token_test.rb +44 -16
- data/test/prx_auth/rails_test.rb +11 -12
- data/test/test_helper.rb +15 -17
- metadata +21 -68
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 297ff153a8884223afeca8d74d809f965e297e1766acf522ef442070d35682ab
|
4
|
+
data.tar.gz: 97af5447b5a9d5449a289f055680c42b7c213503f3ba3fa4af4825f9083da479
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32017811c9336ecdfc7e93196918ebbed6fa04c6616c0f36453319c3bdc2c4caa309fe47b3fc40573ab206efee375193867ca36a0466b0366a6980d0d2761e1f
|
7
|
+
data.tar.gz: 578ed2609ec2213d5bbb8397cdf2fabc82b71e43e59b26128df26bd6075a219712ecd15ec23143f4ef54903cfb02f5bd7afb8140cb8ff35323213880c5b3d95b
|
@@ -0,0 +1,23 @@
|
|
1
|
+
name: Check project standards
|
2
|
+
|
3
|
+
on:
|
4
|
+
push
|
5
|
+
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
lint:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
env:
|
11
|
+
RAILS_ENV: test
|
12
|
+
steps:
|
13
|
+
- name: Checkout code
|
14
|
+
uses: actions/checkout@v3
|
15
|
+
with:
|
16
|
+
fetch-depth: 0
|
17
|
+
- name: Install Ruby and gems
|
18
|
+
uses: ruby/setup-ruby@v1
|
19
|
+
with:
|
20
|
+
ruby-version: '3.0'
|
21
|
+
bundler-cache: true
|
22
|
+
- name: Lint Ruby files
|
23
|
+
run: bundle exec standardrb
|
data/Gemfile
CHANGED
data/Guardfile
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
guard :minitest, all_after_pass: true do
|
2
|
-
watch(%r{^test/(.*)
|
3
|
-
watch(%r{^lib/(.*/)?([^/]+)\.rb})
|
4
|
-
watch(%r{^lib/(.+)\.rb})
|
5
|
-
watch(%r{^lib/(.+)\.rb})
|
2
|
+
watch(%r{^test/(.*)/?test_(.*)\.rb})
|
3
|
+
watch(%r{^lib/(.*/)?([^/]+)\.rb}) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
|
4
|
+
watch(%r{^lib/(.+)\.rb}) { |m| "test/#{m[1]}_test.rb" }
|
5
|
+
watch(%r{^lib/(.+)\.rb}) { |m| "test/#{m[1]}_test.rb" }
|
6
6
|
watch(%r{^test/.+_test\.rb})
|
7
|
-
watch(%r{^test/test_helper\.rb})
|
7
|
+
watch(%r{^test/test_helper\.rb}) { "test" }
|
8
8
|
end
|
data/Rakefile
CHANGED
@@ -6,12 +6,12 @@ load "rails/tasks/engine.rake"
|
|
6
6
|
load "rails/tasks/statistics.rake"
|
7
7
|
|
8
8
|
require "bundler/gem_tasks"
|
9
|
-
require
|
9
|
+
require "rake"
|
10
10
|
require "rake/testtask"
|
11
11
|
|
12
12
|
Rake::TestTask.new(:test) do |t|
|
13
|
-
t.libs <<
|
14
|
-
t.pattern =
|
13
|
+
t.libs << "test"
|
14
|
+
t.pattern = "test/**/*_test.rb"
|
15
15
|
t.verbose = false
|
16
16
|
end
|
17
17
|
|
@@ -9,8 +9,8 @@ module PrxAuth::Rails
|
|
9
9
|
before_action :set_nonce!, only: [:new, :show]
|
10
10
|
before_action :set_after_sign_in_path
|
11
11
|
|
12
|
-
ID_NONCE_SESSION_KEY =
|
13
|
-
DEFAULT_SCOPES =
|
12
|
+
ID_NONCE_SESSION_KEY = "id_prx_openid_nonce"
|
13
|
+
DEFAULT_SCOPES = "openid"
|
14
14
|
|
15
15
|
def new
|
16
16
|
config = PrxAuth::Rails.configuration
|
@@ -25,12 +25,12 @@ module PrxAuth::Rails
|
|
25
25
|
id_auth_params = {
|
26
26
|
client_id: config.prx_client_id,
|
27
27
|
nonce: fetch_nonce,
|
28
|
-
response_type:
|
28
|
+
response_type: "id_token token",
|
29
29
|
scope: scope,
|
30
|
-
prompt:
|
30
|
+
prompt: "necessary"
|
31
31
|
}
|
32
32
|
|
33
|
-
url =
|
33
|
+
url = "//" + config.id_host + "/authorize?" + id_auth_params.to_query
|
34
34
|
|
35
35
|
redirect_to url, allow_other_host: true
|
36
36
|
end
|
@@ -48,13 +48,14 @@ module PrxAuth::Rails
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def create
|
51
|
-
|
52
|
-
|
51
|
+
valid_and_matching = valid_nonce? && users_match?
|
52
|
+
clear_nonce!
|
53
|
+
|
54
|
+
if valid_and_matching
|
53
55
|
sign_in_user(access_token)
|
54
56
|
redirect_to after_sign_in_path_for(current_user)
|
55
57
|
else
|
56
|
-
|
57
|
-
redirect_to auth_error_sessions_path(error: params[:error] || 'unknown_error')
|
58
|
+
redirect_to auth_error_sessions_path(error: params[:error] || "unknown_error")
|
58
59
|
end
|
59
60
|
end
|
60
61
|
|
@@ -67,7 +68,7 @@ module PrxAuth::Rails
|
|
67
68
|
elsif defined?(super)
|
68
69
|
super
|
69
70
|
else
|
70
|
-
|
71
|
+
"/"
|
71
72
|
end
|
72
73
|
end
|
73
74
|
|
@@ -78,11 +79,11 @@ module PrxAuth::Rails
|
|
78
79
|
end
|
79
80
|
|
80
81
|
def id_token
|
81
|
-
params.require(
|
82
|
+
params.require("id_token")
|
82
83
|
end
|
83
84
|
|
84
85
|
def access_token
|
85
|
-
params.require(
|
86
|
+
params.require("access_token")
|
86
87
|
end
|
87
88
|
|
88
89
|
def id_claims
|
@@ -106,11 +107,11 @@ module PrxAuth::Rails
|
|
106
107
|
end
|
107
108
|
|
108
109
|
def valid_nonce?
|
109
|
-
id_claims[
|
110
|
+
id_claims["nonce"].present? && id_claims["nonce"] == fetch_nonce
|
110
111
|
end
|
111
112
|
|
112
113
|
def users_match?
|
113
|
-
id_claims[
|
114
|
+
id_claims["sub"].present? && id_claims["sub"] == access_claims["sub"]
|
114
115
|
end
|
115
116
|
|
116
117
|
def validate_token(token)
|
@@ -1,13 +1,6 @@
|
|
1
1
|
<div class='main'>
|
2
2
|
<section>
|
3
3
|
<h3>Not authorized for this application.</h3>
|
4
|
-
|
5
|
-
<p>Message was: <pre><%= @auth_error_message %></pre>
|
6
|
-
<% if @auth_error_message == 'invalid_scope' %>
|
7
|
-
Did you add a row in the account_applications table on id.prx?
|
8
|
-
<% end %>
|
9
|
-
</p>
|
10
|
-
|
11
4
|
<p>
|
12
5
|
<a href="<%= new_sessions_path %>">Try logging in again</a>
|
13
6
|
</p>
|
@@ -1 +1 @@
|
|
1
|
-
Rails.application.config.assets.precompile << %w
|
1
|
+
Rails.application.config.assets.precompile << %w[prx_auth-rails_manifest.js]
|
data/config/routes.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PrxAuth::Rails::Engine.routes.draw do
|
2
|
-
scope module:
|
3
|
-
resource
|
4
|
-
get
|
2
|
+
scope module: "prx_auth/rails" do
|
3
|
+
resource "sessions", except: :index, defaults: {format: "html"} do
|
4
|
+
get "auth_error", to: "sessions#auth_error"
|
5
5
|
end
|
6
6
|
end
|
7
7
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
class PrxAuth::Rails::Configuration
|
2
2
|
attr_accessor :install_middleware,
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
:namespace,
|
4
|
+
:prx_client_id,
|
5
|
+
:prx_scope,
|
6
|
+
:id_host,
|
7
|
+
:cert_path
|
8
8
|
|
9
|
-
DEFAULT_ID_HOST =
|
10
|
-
DEFAULT_CERT_PATH =
|
9
|
+
DEFAULT_ID_HOST = "id.prx.org"
|
10
|
+
DEFAULT_CERT_PATH = "api/v1/certs"
|
11
11
|
|
12
12
|
def initialize
|
13
13
|
@install_middleware = true
|
@@ -21,15 +21,15 @@ class PrxAuth::Rails::Configuration
|
|
21
21
|
if defined?(::Rails)
|
22
22
|
klass = ::Rails.application.class
|
23
23
|
parent_name = if ::Rails::VERSION::MAJOR >= 6
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
klass.module_parent_name
|
25
|
+
else
|
26
|
+
klass.parent_name
|
27
|
+
end
|
28
28
|
klass_name = if parent_name.present?
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
parent_name
|
30
|
+
else
|
31
|
+
klass.name
|
32
|
+
end
|
33
33
|
|
34
34
|
klass_name.underscore.intern
|
35
35
|
end
|
@@ -1,18 +1,18 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "prx_auth/rails/token"
|
2
|
+
require "open-uri"
|
3
3
|
|
4
4
|
module PrxAuth
|
5
5
|
module Rails
|
6
6
|
module Controller
|
7
7
|
class SessionTokenExpiredError < RuntimeError; end
|
8
8
|
|
9
|
-
PRX_AUTH_ENV_KEY =
|
10
|
-
PRX_JWT_SESSION_KEY =
|
9
|
+
PRX_AUTH_ENV_KEY = "prx.auth".freeze
|
10
|
+
PRX_JWT_SESSION_KEY = "prx.auth.jwt".freeze
|
11
11
|
# subtracted from the JWT ttl
|
12
|
-
PRX_JWT_REFRESH_TTL = 300
|
13
|
-
PRX_ACCOUNT_MAPPING_SESSION_KEY =
|
14
|
-
PRX_USER_INFO_SESSION_KEY =
|
15
|
-
PRX_REFRESH_BACK_KEY =
|
12
|
+
PRX_JWT_REFRESH_TTL = 300
|
13
|
+
PRX_ACCOUNT_MAPPING_SESSION_KEY = "prx.auth.account.mapping".freeze
|
14
|
+
PRX_USER_INFO_SESSION_KEY = "prx.auth.info".freeze
|
15
|
+
PRX_REFRESH_BACK_KEY = "prx.auth.back".freeze
|
16
16
|
|
17
17
|
def prx_auth_token
|
18
18
|
env_token || session_token
|
@@ -24,7 +24,7 @@ module PrxAuth
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def set_after_sign_in_path
|
27
|
-
return if
|
27
|
+
return if instance_of?(PrxAuth::Rails::SessionsController)
|
28
28
|
|
29
29
|
session[PRX_REFRESH_BACK_KEY] = request.fullpath
|
30
30
|
end
|
@@ -54,17 +54,17 @@ module PrxAuth
|
|
54
54
|
def current_user_info
|
55
55
|
session[PRX_USER_INFO_SESSION_KEY] ||= begin
|
56
56
|
info = fetch_userinfo
|
57
|
-
info.slice(
|
57
|
+
info.slice("name", "preferred_username", "email", "image_href", "apps")
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
61
|
def current_user_name
|
62
|
-
current_user_info[
|
62
|
+
current_user_info["name"] || current_user_info["preferred_username"] || current_user_info["email"]
|
63
63
|
end
|
64
64
|
|
65
65
|
def current_user_apps
|
66
|
-
apps = (current_user_info.try(:[],
|
67
|
-
label = name.sub(/^https?:\/\//,
|
66
|
+
apps = (current_user_info.try(:[], "apps") || []).map do |name, url|
|
67
|
+
label = name.sub(/^https?:\/\//, "").sub(/\..+/, "").capitalize
|
68
68
|
["PRX #{label}", url]
|
69
69
|
end
|
70
70
|
|
@@ -90,7 +90,7 @@ module PrxAuth
|
|
90
90
|
end
|
91
91
|
|
92
92
|
def account_name_for(account_id)
|
93
|
-
account_for(account_id).try(:[],
|
93
|
+
account_for(account_id).try(:[], "name")
|
94
94
|
end
|
95
95
|
|
96
96
|
def account_for(account_id)
|
@@ -110,8 +110,8 @@ module PrxAuth
|
|
110
110
|
missing = ids - session[PRX_ACCOUNT_MAPPING_SESSION_KEY].keys
|
111
111
|
if missing.present?
|
112
112
|
fetch_accounts(missing).each do |account|
|
113
|
-
minimal = account.slice(
|
114
|
-
session[PRX_ACCOUNT_MAPPING_SESSION_KEY][account[
|
113
|
+
minimal = account.slice("name", "type")
|
114
|
+
session[PRX_ACCOUNT_MAPPING_SESSION_KEY][account["id"]] = minimal
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
@@ -119,9 +119,9 @@ module PrxAuth
|
|
119
119
|
end
|
120
120
|
|
121
121
|
def fetch_accounts(ids)
|
122
|
-
ids_param = ids.map(&:to_s).join(
|
122
|
+
ids_param = ids.map(&:to_s).join(",")
|
123
123
|
resp = fetch("/api/v1/accounts?account_ids=#{ids_param}")
|
124
|
-
resp.try(:[],
|
124
|
+
resp.try(:[], "_embedded").try(:[], "prx:items") || []
|
125
125
|
end
|
126
126
|
|
127
127
|
def fetch_userinfo
|
@@ -132,8 +132,8 @@ module PrxAuth
|
|
132
132
|
url = "https://#{PrxAuth::Rails.configuration.id_host}#{path}"
|
133
133
|
options = {}
|
134
134
|
options[:ssl_verify_mode] = OpenSSL::SSL::VERIFY_NONE if ::Rails.env.development?
|
135
|
-
options[
|
136
|
-
JSON.parse(URI.open(url, options).read)
|
135
|
+
options["Authorization"] = "Bearer #{token}" if token
|
136
|
+
JSON.parse(URI.open(url, options).read) # standard:disable Security/Open
|
137
137
|
end
|
138
138
|
|
139
139
|
# token from data set by prx_auth rack middleware
|
data/lib/prx_auth/rails/token.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "rack/prx_auth"
|
2
2
|
|
3
3
|
class PrxAuth::Rails::Token
|
4
4
|
def initialize(token_data)
|
@@ -6,17 +6,17 @@ class PrxAuth::Rails::Token
|
|
6
6
|
@namespace = PrxAuth::Rails.configuration.namespace
|
7
7
|
end
|
8
8
|
|
9
|
-
def authorized?(resource, namespace=nil, scope=nil)
|
9
|
+
def authorized?(resource, namespace = nil, scope = nil)
|
10
10
|
namespace, scope = @namespace, namespace if scope.nil? && !namespace.nil?
|
11
11
|
@token_data.authorized?(resource, namespace, scope)
|
12
12
|
end
|
13
13
|
|
14
|
-
def globally_authorized?(namespace, scope=nil)
|
14
|
+
def globally_authorized?(namespace, scope = nil)
|
15
15
|
namespace, scope = @namespace, namespace if scope.nil?
|
16
16
|
@token_data.globally_authorized?(namespace, scope)
|
17
17
|
end
|
18
18
|
|
19
|
-
def resources(namespace=nil, scope=nil)
|
19
|
+
def resources(namespace = nil, scope = nil)
|
20
20
|
namespace, scope = @namespace, namespace if scope.nil? && !namespace.nil?
|
21
21
|
@token_data.resources(namespace, scope)
|
22
22
|
end
|
@@ -32,4 +32,17 @@ class PrxAuth::Rails::Token
|
|
32
32
|
def authorized_account_ids(scope)
|
33
33
|
@token_data.authorized_account_ids(scope)
|
34
34
|
end
|
35
|
+
|
36
|
+
def except!(*resources)
|
37
|
+
@token_data = @token_data.except(*resources)
|
38
|
+
self
|
39
|
+
end
|
40
|
+
|
41
|
+
def except(*resources)
|
42
|
+
dup.except!(*resources)
|
43
|
+
end
|
44
|
+
|
45
|
+
def empty_resources?
|
46
|
+
@token_data.empty_resources?
|
47
|
+
end
|
35
48
|
end
|
data/lib/prx_auth/rails.rb
CHANGED
@@ -27,10 +27,10 @@ module PrxAuth
|
|
27
27
|
host = configuration.id_host
|
28
28
|
path = configuration.cert_path
|
29
29
|
protocol =
|
30
|
-
if host.include?(
|
31
|
-
|
30
|
+
if host.include?("localhost") || host.include?("127.0.0.1")
|
31
|
+
"http"
|
32
32
|
else
|
33
|
-
|
33
|
+
"https"
|
34
34
|
end
|
35
35
|
|
36
36
|
app.middleware.insert_after Rack::Head, Rack::PrxAuth,
|
data/prx_auth-rails.gemspec
CHANGED
@@ -1,37 +1,36 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
3
|
+
require "prx_auth/rails/version"
|
5
4
|
|
6
5
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name
|
8
|
-
spec.version
|
9
|
-
spec.authors
|
10
|
-
spec.email
|
11
|
-
spec.description
|
12
|
-
spec.summary
|
13
|
-
spec.homepage
|
14
|
-
spec.license
|
6
|
+
spec.name = "prx_auth-rails"
|
7
|
+
spec.version = PrxAuth::Rails::VERSION
|
8
|
+
spec.authors = ["Chris Rhoden"]
|
9
|
+
spec.email = ["carhoden@gmail.com"]
|
10
|
+
spec.description = "Rails integration for next generation PRX Authorization system."
|
11
|
+
spec.summary = "Rails integration for next generation PRX Authorization system."
|
12
|
+
spec.homepage = "https://github.com/PRX/prx_auth-rails"
|
13
|
+
spec.license = "MIT"
|
15
14
|
|
16
|
-
spec.required_ruby_version =
|
15
|
+
spec.required_ruby_version = ">= 2.3"
|
17
16
|
|
18
|
-
spec.files
|
19
|
-
spec.executables
|
20
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
|
+
spec.files = `git ls-files`.split($/)
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
21
19
|
spec.require_paths = ["lib"]
|
22
20
|
|
23
|
-
spec.add_runtime_dependency
|
21
|
+
spec.add_runtime_dependency "actionpack"
|
24
22
|
|
25
|
-
spec.add_development_dependency
|
26
|
-
spec.add_development_dependency
|
27
|
-
spec.add_development_dependency
|
28
|
-
spec.add_development_dependency
|
29
|
-
spec.add_development_dependency
|
30
|
-
spec.add_development_dependency
|
23
|
+
spec.add_development_dependency "bundler"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "coveralls", "~> 0"
|
26
|
+
spec.add_development_dependency "guard"
|
27
|
+
spec.add_development_dependency "guard-minitest"
|
28
|
+
spec.add_development_dependency "m", "~> 1.5"
|
31
29
|
spec.add_development_dependency "rails", "~> 6.1.0"
|
32
|
-
spec.add_development_dependency
|
33
|
-
spec.add_development_dependency
|
34
|
-
spec.add_development_dependency
|
30
|
+
spec.add_development_dependency "pry"
|
31
|
+
spec.add_development_dependency "sqlite3"
|
32
|
+
spec.add_development_dependency "webmock"
|
33
|
+
spec.add_development_dependency "standard"
|
35
34
|
|
36
|
-
spec.add_runtime_dependency
|
35
|
+
spec.add_runtime_dependency "prx_auth", ">= 1.8.0"
|
37
36
|
end
|
data/test/dummy/bin/rails
CHANGED
data/test/dummy/bin/setup
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
require "fileutils"
|
3
3
|
|
4
4
|
# path to your application root.
|
5
|
-
APP_ROOT = File.expand_path(
|
5
|
+
APP_ROOT = File.expand_path("..", __dir__)
|
6
6
|
|
7
7
|
def system!(*args)
|
8
8
|
system(*args) || abort("\n== Command #{args} failed ==")
|
@@ -13,9 +13,9 @@ FileUtils.chdir APP_ROOT do
|
|
13
13
|
# This script is idempotent, so that you can run it at any time and get an expectable outcome.
|
14
14
|
# Add necessary setup steps to this file.
|
15
15
|
|
16
|
-
puts
|
17
|
-
system!
|
18
|
-
system(
|
16
|
+
puts "== Installing dependencies =="
|
17
|
+
system! "gem install bundler --conservative"
|
18
|
+
system("bundle check") || system!("bundle install")
|
19
19
|
|
20
20
|
# puts "\n== Copying sample files =="
|
21
21
|
# unless File.exist?('config/database.yml')
|
@@ -23,11 +23,11 @@ FileUtils.chdir APP_ROOT do
|
|
23
23
|
# end
|
24
24
|
|
25
25
|
puts "\n== Preparing database =="
|
26
|
-
system!
|
26
|
+
system! "bin/rails db:prepare"
|
27
27
|
|
28
28
|
puts "\n== Removing old logs and tempfiles =="
|
29
|
-
system!
|
29
|
+
system! "bin/rails log:clear tmp:clear"
|
30
30
|
|
31
31
|
puts "\n== Restarting application server =="
|
32
|
-
system!
|
32
|
+
system! "bin/rails restart"
|
33
33
|
end
|
data/test/dummy/config/boot.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Set up gems listed in the Gemfile.
|
2
|
-
ENV[
|
2
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__)
|
3
3
|
|
4
4
|
require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
|
5
|
-
$LOAD_PATH.unshift File.expand_path(
|
5
|
+
$LOAD_PATH.unshift File.expand_path("../../../lib", __dir__)
|
@@ -16,13 +16,13 @@ Rails.application.configure do
|
|
16
16
|
|
17
17
|
# Enable/disable caching. By default caching is disabled.
|
18
18
|
# Run rails dev:cache to toggle caching.
|
19
|
-
if Rails.root.join(
|
19
|
+
if Rails.root.join("tmp", "caching-dev.txt").exist?
|
20
20
|
config.action_controller.perform_caching = true
|
21
21
|
config.action_controller.enable_fragment_cache_logging = true
|
22
22
|
|
23
23
|
config.cache_store = :memory_store
|
24
24
|
config.public_file_server.headers = {
|
25
|
-
|
25
|
+
"Cache-Control" => "public, max-age=#{2.days.to_i}"
|
26
26
|
}
|
27
27
|
else
|
28
28
|
config.action_controller.perform_caching = false
|
@@ -13,7 +13,7 @@ Rails.application.configure do
|
|
13
13
|
config.eager_load = true
|
14
14
|
|
15
15
|
# Full error reports are disabled and caching is turned on.
|
16
|
-
config.consider_all_requests_local
|
16
|
+
config.consider_all_requests_local = false
|
17
17
|
config.action_controller.perform_caching = true
|
18
18
|
|
19
19
|
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
|
@@ -22,7 +22,7 @@ Rails.application.configure do
|
|
22
22
|
|
23
23
|
# Disable serving static files from the `/public` folder by default since
|
24
24
|
# Apache or NGINX already handles this.
|
25
|
-
config.public_file_server.enabled = ENV[
|
25
|
+
config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
|
26
26
|
|
27
27
|
# Compress CSS using a preprocessor.
|
28
28
|
# config.assets.css_compressor = :sass
|
@@ -53,7 +53,7 @@ Rails.application.configure do
|
|
53
53
|
config.log_level = :info
|
54
54
|
|
55
55
|
# Prepend all log lines with the following tags.
|
56
|
-
config.log_tags = [
|
56
|
+
config.log_tags = [:request_id]
|
57
57
|
|
58
58
|
# Use a different cache store in production.
|
59
59
|
# config.cache_store = :mem_cache_store
|
@@ -89,9 +89,9 @@ Rails.application.configure do
|
|
89
89
|
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
|
90
90
|
|
91
91
|
if ENV["RAILS_LOG_TO_STDOUT"].present?
|
92
|
-
logger
|
92
|
+
logger = ActiveSupport::Logger.new($stdout)
|
93
93
|
logger.formatter = config.log_formatter
|
94
|
-
config.logger
|
94
|
+
config.logger = ActiveSupport::TaggedLogging.new(logger)
|
95
95
|
end
|
96
96
|
|
97
97
|
# Do not dump schema after migrations.
|
@@ -19,11 +19,11 @@ Rails.application.configure do
|
|
19
19
|
# Configure public file server for tests with Cache-Control for performance.
|
20
20
|
config.public_file_server.enabled = true
|
21
21
|
config.public_file_server.headers = {
|
22
|
-
|
22
|
+
"Cache-Control" => "public, max-age=#{1.hour.to_i}"
|
23
23
|
}
|
24
24
|
|
25
25
|
# Show full error reports and disable caching.
|
26
|
-
config.consider_all_requests_local
|
26
|
+
config.consider_all_requests_local = true
|
27
27
|
config.action_controller.perform_caching = false
|
28
28
|
config.cache_store = :null_store
|
29
29
|
|