prx_auth-rails 4.0.0 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- 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 +25 -14
- data/app/views/prx_auth/rails/sessions/auth_error.html.erb +0 -7
- data/app/views/prx_auth/rails/sessions/show.html.erb +4 -1
- data/config/initializers/assets.rb +1 -1
- data/config/routes.rb +3 -3
- data/lib/prx_auth/rails/configuration.rb +16 -14
- data/lib/prx_auth/rails/engine.rb +1 -1
- data/lib/prx_auth/rails/ext/controller.rb +23 -19
- 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 +15 -13
- data/test/prx_auth/rails/ext/controller_test.rb +87 -81
- data/test/prx_auth/rails/sessions_controller_test.rb +39 -39
- 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,20 +9,30 @@ 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 =
|
12
|
+
ID_NONCE_SESSION_KEY = "id_prx_openid_nonce"
|
13
|
+
DEFAULT_SCOPES = "openid"
|
13
14
|
|
14
15
|
def new
|
15
16
|
config = PrxAuth::Rails.configuration
|
16
17
|
|
18
|
+
scope =
|
19
|
+
if config.prx_scope.present?
|
20
|
+
"#{DEFAULT_SCOPES} #{config.prx_scope}"
|
21
|
+
else
|
22
|
+
DEFAULT_SCOPES
|
23
|
+
end
|
24
|
+
|
17
25
|
id_auth_params = {
|
18
26
|
client_id: config.prx_client_id,
|
19
27
|
nonce: fetch_nonce,
|
20
|
-
response_type:
|
21
|
-
scope:
|
22
|
-
prompt:
|
28
|
+
response_type: "id_token token",
|
29
|
+
scope: scope,
|
30
|
+
prompt: "necessary"
|
23
31
|
}
|
24
32
|
|
25
|
-
|
33
|
+
url = "//" + config.id_host + "/authorize?" + id_auth_params.to_query
|
34
|
+
|
35
|
+
redirect_to url, allow_other_host: true
|
26
36
|
end
|
27
37
|
|
28
38
|
def show
|
@@ -38,13 +48,14 @@ module PrxAuth::Rails
|
|
38
48
|
end
|
39
49
|
|
40
50
|
def create
|
41
|
-
|
42
|
-
|
51
|
+
valid_and_matching = valid_nonce? && users_match?
|
52
|
+
clear_nonce!
|
53
|
+
|
54
|
+
if valid_and_matching
|
43
55
|
sign_in_user(access_token)
|
44
56
|
redirect_to after_sign_in_path_for(current_user)
|
45
57
|
else
|
46
|
-
|
47
|
-
redirect_to auth_error_sessions_path(error: 'verification_failed')
|
58
|
+
redirect_to auth_error_sessions_path(error: params[:error] || "unknown_error")
|
48
59
|
end
|
49
60
|
end
|
50
61
|
|
@@ -57,7 +68,7 @@ module PrxAuth::Rails
|
|
57
68
|
elsif defined?(super)
|
58
69
|
super
|
59
70
|
else
|
60
|
-
|
71
|
+
"/"
|
61
72
|
end
|
62
73
|
end
|
63
74
|
|
@@ -68,11 +79,11 @@ module PrxAuth::Rails
|
|
68
79
|
end
|
69
80
|
|
70
81
|
def id_token
|
71
|
-
params.require(
|
82
|
+
params.require("id_token")
|
72
83
|
end
|
73
84
|
|
74
85
|
def access_token
|
75
|
-
params.require(
|
86
|
+
params.require("access_token")
|
76
87
|
end
|
77
88
|
|
78
89
|
def id_claims
|
@@ -96,11 +107,11 @@ module PrxAuth::Rails
|
|
96
107
|
end
|
97
108
|
|
98
109
|
def valid_nonce?
|
99
|
-
id_claims[
|
110
|
+
id_claims["nonce"].present? && id_claims["nonce"] == fetch_nonce
|
100
111
|
end
|
101
112
|
|
102
113
|
def users_match?
|
103
|
-
id_claims[
|
114
|
+
id_claims["sub"].present? && id_claims["sub"] == access_claims["sub"]
|
104
115
|
end
|
105
116
|
|
106
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>
|
@@ -2,6 +2,7 @@
|
|
2
2
|
<%= form_for(:sessions, :url => PrxAuth::Rails::Engine.routes.url_helpers.sessions_path) do |f| %>
|
3
3
|
<%= hidden_field_tag :access_token, '', id: 'access-token-field' %>
|
4
4
|
<%= hidden_field_tag :id_token, '', id: 'id-token-field' %>
|
5
|
+
<%= hidden_field_tag :error, '', id: 'error-field' %>
|
5
6
|
<%= f.submit id: 'sessions-form-submit' %>
|
6
7
|
<% end %>
|
7
8
|
</div>
|
@@ -23,14 +24,16 @@
|
|
23
24
|
}
|
24
25
|
|
25
26
|
window.addEventListener("load", () => {
|
26
|
-
var idToken = document.querySelector("#id-token-field");
|
27
27
|
var accessToken = document.querySelector("#access-token-field");
|
28
|
+
var idToken = document.querySelector("#id-token-field");
|
29
|
+
var error = document.querySelector("#error-field");
|
28
30
|
var submit = document.querySelector("input#sessions-form-submit[type=submit]");
|
29
31
|
|
30
32
|
var hashParams = parseURLFragment();
|
31
33
|
|
32
34
|
accessToken.value = hashParams['access_token'];
|
33
35
|
idToken.value = hashParams['id_token'];
|
36
|
+
error.value = hashParams['error'];
|
34
37
|
|
35
38
|
submit.click();
|
36
39
|
});
|
@@ -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,16 +1,18 @@
|
|
1
1
|
class PrxAuth::Rails::Configuration
|
2
2
|
attr_accessor :install_middleware,
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
:namespace,
|
4
|
+
:prx_client_id,
|
5
|
+
:prx_scope,
|
6
|
+
:id_host,
|
7
|
+
:cert_path
|
7
8
|
|
8
|
-
DEFAULT_ID_HOST =
|
9
|
-
DEFAULT_CERT_PATH =
|
9
|
+
DEFAULT_ID_HOST = "id.prx.org"
|
10
|
+
DEFAULT_CERT_PATH = "api/v1/certs"
|
10
11
|
|
11
12
|
def initialize
|
12
13
|
@install_middleware = true
|
13
14
|
@prx_client_id = nil
|
15
|
+
@prx_scope = nil
|
14
16
|
@id_host = DEFAULT_ID_HOST
|
15
17
|
@cert_path = DEFAULT_CERT_PATH
|
16
18
|
|
@@ -19,15 +21,15 @@ class PrxAuth::Rails::Configuration
|
|
19
21
|
if defined?(::Rails)
|
20
22
|
klass = ::Rails.application.class
|
21
23
|
parent_name = if ::Rails::VERSION::MAJOR >= 6
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
24
|
+
klass.module_parent_name
|
25
|
+
else
|
26
|
+
klass.parent_name
|
27
|
+
end
|
26
28
|
klass_name = if parent_name.present?
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
29
|
+
parent_name
|
30
|
+
else
|
31
|
+
klass.name
|
32
|
+
end
|
31
33
|
|
32
34
|
klass_name.underscore.intern
|
33
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
|
@@ -52,16 +52,19 @@ module PrxAuth
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def current_user_info
|
55
|
-
session[PRX_USER_INFO_SESSION_KEY] ||=
|
55
|
+
session[PRX_USER_INFO_SESSION_KEY] ||= begin
|
56
|
+
info = fetch_userinfo
|
57
|
+
info.slice("name", "preferred_username", "email", "image_href", "apps")
|
58
|
+
end
|
56
59
|
end
|
57
60
|
|
58
61
|
def current_user_name
|
59
|
-
current_user_info[
|
62
|
+
current_user_info["name"] || current_user_info["preferred_username"] || current_user_info["email"]
|
60
63
|
end
|
61
64
|
|
62
65
|
def current_user_apps
|
63
|
-
apps = (current_user_info.try(:[],
|
64
|
-
label = name.sub(/^https?:\/\//,
|
66
|
+
apps = (current_user_info.try(:[], "apps") || []).map do |name, url|
|
67
|
+
label = name.sub(/^https?:\/\//, "").sub(/\..+/, "").capitalize
|
65
68
|
["PRX #{label}", url]
|
66
69
|
end
|
67
70
|
|
@@ -87,7 +90,7 @@ module PrxAuth
|
|
87
90
|
end
|
88
91
|
|
89
92
|
def account_name_for(account_id)
|
90
|
-
account_for(account_id).try(:[],
|
93
|
+
account_for(account_id).try(:[], "name")
|
91
94
|
end
|
92
95
|
|
93
96
|
def account_for(account_id)
|
@@ -107,7 +110,8 @@ module PrxAuth
|
|
107
110
|
missing = ids - session[PRX_ACCOUNT_MAPPING_SESSION_KEY].keys
|
108
111
|
if missing.present?
|
109
112
|
fetch_accounts(missing).each do |account|
|
110
|
-
|
113
|
+
minimal = account.slice("name", "type")
|
114
|
+
session[PRX_ACCOUNT_MAPPING_SESSION_KEY][account["id"]] = minimal
|
111
115
|
end
|
112
116
|
end
|
113
117
|
|
@@ -115,9 +119,9 @@ module PrxAuth
|
|
115
119
|
end
|
116
120
|
|
117
121
|
def fetch_accounts(ids)
|
118
|
-
ids_param = ids.map(&:to_s).join(
|
122
|
+
ids_param = ids.map(&:to_s).join(",")
|
119
123
|
resp = fetch("/api/v1/accounts?account_ids=#{ids_param}")
|
120
|
-
resp.try(:[],
|
124
|
+
resp.try(:[], "_embedded").try(:[], "prx:items") || []
|
121
125
|
end
|
122
126
|
|
123
127
|
def fetch_userinfo
|
@@ -128,8 +132,8 @@ module PrxAuth
|
|
128
132
|
url = "https://#{PrxAuth::Rails.configuration.id_host}#{path}"
|
129
133
|
options = {}
|
130
134
|
options[:ssl_verify_mode] = OpenSSL::SSL::VERIFY_NONE if ::Rails.env.development?
|
131
|
-
options[
|
132
|
-
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
|
133
137
|
end
|
134
138
|
|
135
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
|