pco-url 2.1.3 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +1 -1
- data/.ruby-version +1 -1
- data/Appraisals +8 -10
- data/CHANGELOG.md +5 -0
- data/gemfiles/{rails_5.0.gemfile → rails_6.1.gemfile} +1 -2
- data/gemfiles/{rails_5.1.gemfile → rails_edge.gemfile} +1 -2
- data/lib/pco/url.rb +10 -1
- data/lib/pco/url/engine.rb +1 -1
- data/lib/pco/url/engine/domain_middleware.rb +2 -1
- data/lib/pco/url/version.rb +1 -1
- data/spec/dummy/config/application.rb +13 -1
- data/spec/requests/{dev_domain_spec.rb → domain_middleware_spec.rb} +26 -21
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0687cb14bb063264a30307b10d9b6efcb49d8f4cbf77b711b15192fe35217048'
|
4
|
+
data.tar.gz: ece4ec24c39990c45bf02e44a564a6f9bc460af66348bdd5e97166319252612f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55eaac7abd9b009155137ee6cbfa8a339296bab1fbeb409dca080921591c6e623921f3d3accb6981e3552f1029a7d1ee4b4ec1984944112e5a4d74e198aa856b
|
7
|
+
data.tar.gz: acb674cba783b53cfe924ac820b8b5a67af7db82c0d5f399aeb81c8faabe9a3eac6a39e03322fb1fb40ef090ee8f943db784098c7572dc191a0eadbd61f92d1c
|
data/.circleci/config.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.7
|
data/Appraisals
CHANGED
@@ -1,15 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
appraise "rails-5.0" do
|
4
|
-
gem "rails", "~> 5.0.0"
|
5
|
-
gem "sqlite3", "< 1.4"
|
6
|
-
end
|
7
|
-
|
8
|
-
appraise "rails-5.1" do
|
9
|
-
gem "rails", "~> 5.1.0"
|
10
|
-
gem "sqlite3", "< 1.4"
|
11
|
-
end
|
12
|
-
|
13
3
|
appraise "rails-5.2" do
|
14
4
|
gem "rails", "~> 5.2.0"
|
15
5
|
end
|
@@ -17,3 +7,11 @@ end
|
|
17
7
|
appraise "rails-6.0" do
|
18
8
|
gem "rails", "~> 6.0.0"
|
19
9
|
end
|
10
|
+
|
11
|
+
appraise "rails-6.1" do
|
12
|
+
gem "rails", "~> 6.1.0"
|
13
|
+
end
|
14
|
+
|
15
|
+
appraise "rails-edge" do
|
16
|
+
gem "rails", git: "https://github.com/rails/rails.git", branch: "main"
|
17
|
+
end
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# v3.0.0 (2021-02-25)
|
2
|
+
|
3
|
+
* Feature: add middleware in production/staging to maintain second-level domain, e.g. planningcenter.com when generating URLs
|
4
|
+
* Chore: test on more modern versions of Ruby and Rails
|
5
|
+
|
1
6
|
# v2.1.3 (2020-01-14)
|
2
7
|
|
3
8
|
* Chore: no code changes; just bumping the version and rebuilding the gem file with proper file permissions [Tim Morgan]
|
data/lib/pco/url.rb
CHANGED
@@ -7,6 +7,13 @@ require "uri"
|
|
7
7
|
|
8
8
|
module PCO
|
9
9
|
class URL
|
10
|
+
DOMAINS = {
|
11
|
+
'development' => %w[pco.test pco.codes],
|
12
|
+
'test' => %w[pco.test pco.codes],
|
13
|
+
'staging' => %w[planningcenteronline.com planningcenter.com],
|
14
|
+
'production' => %w[planningcenteronline.com planningcenter.com],
|
15
|
+
}.freeze
|
16
|
+
|
10
17
|
class << self
|
11
18
|
def decrypt_query_params(string)
|
12
19
|
Encryption.decrypt(string)
|
@@ -82,13 +89,15 @@ module PCO
|
|
82
89
|
def domain
|
83
90
|
return @domain if @domain
|
84
91
|
|
92
|
+
return PCO::URL::Engine.domain if PCO::URL::Engine.domain
|
93
|
+
|
85
94
|
case env
|
86
95
|
when "production", "staging"
|
87
96
|
"planningcenteronline.com"
|
88
97
|
when "test"
|
89
98
|
"pco.test"
|
90
99
|
when "development"
|
91
|
-
|
100
|
+
"pco.test"
|
92
101
|
end
|
93
102
|
end
|
94
103
|
|
data/lib/pco/url/engine.rb
CHANGED
@@ -11,7 +11,8 @@ module PCO
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def call(env)
|
14
|
-
|
14
|
+
domain = env["SERVER_NAME"].downcase.match(/[a-z0-9-]+\.[a-z]+$/).to_s
|
15
|
+
PCO::URL::Engine.domain = PCO::URL::DOMAINS[Rails.env].include?(domain) ? domain : nil
|
15
16
|
@app.call(env)
|
16
17
|
end
|
17
18
|
end
|
data/lib/pco/url/version.rb
CHANGED
@@ -8,7 +8,19 @@ require "pco/url"
|
|
8
8
|
module Dummy
|
9
9
|
class Application < Rails::Application
|
10
10
|
config.eager_load = false
|
11
|
-
|
11
|
+
if Rails::VERSION::MAJOR >= 6
|
12
|
+
config.hosts << "accounts.pco.test"
|
13
|
+
config.hosts << "accounts.pco.codes"
|
14
|
+
config.hosts << "accounts.planningcenteronline.com"
|
15
|
+
config.hosts << "accounts.planningcenter.com"
|
16
|
+
config.hosts << "accounts-staging.planningcenteronline.com"
|
17
|
+
config.hosts << "accounts-staging.planningcenter.com"
|
18
|
+
|
19
|
+
# We would obviously never have this in a real Rails app, but we need it here
|
20
|
+
# to test that PCO::URL cannot get tricked by a bad host, should an attacker
|
21
|
+
# somehow sneak one through by some other means.
|
22
|
+
config.hosts << "accounts.evilplanningcenter.com"
|
23
|
+
end
|
12
24
|
config.secret_key_base = "123abc"
|
13
25
|
end
|
14
26
|
end
|
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "spec_helper"
|
2
4
|
|
3
5
|
describe PCO::URL::Engine::DomainMiddleware, type: :request do
|
4
|
-
context "in development
|
6
|
+
context "in development" do
|
5
7
|
before do
|
6
8
|
ENV["DEPLOY_ENV"] = Rails.env = "development"
|
7
9
|
end
|
@@ -10,48 +12,51 @@ describe PCO::URL::Engine::DomainMiddleware, type: :request do
|
|
10
12
|
host! "accounts.pco.test"
|
11
13
|
get "/test"
|
12
14
|
expect(response.body).to eq("http://people.pco.test")
|
15
|
+
|
13
16
|
host! "accounts.pco.codes"
|
14
17
|
get "/test"
|
15
18
|
expect(response.body).to eq("http://people.pco.codes")
|
16
19
|
end
|
17
20
|
end
|
18
21
|
|
19
|
-
context "in
|
22
|
+
context "in staging" do
|
20
23
|
before do
|
21
|
-
ENV["DEPLOY_ENV"] = Rails.env = "
|
24
|
+
ENV["DEPLOY_ENV"] = Rails.env = "staging"
|
22
25
|
end
|
23
26
|
|
24
27
|
it "sets the generated URL domain to be the same as the host" do
|
25
|
-
host! "accounts.
|
26
|
-
get "/test"
|
27
|
-
expect(response.body).to eq("http://people.pco.test")
|
28
|
-
host! "accounts.pco.codes"
|
28
|
+
host! "accounts-staging.planningcenteronline.com"
|
29
29
|
get "/test"
|
30
|
-
expect(response.body).to eq("
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context "in staging mode" do
|
35
|
-
before do
|
36
|
-
ENV["DEPLOY_ENV"] = Rails.env = "staging"
|
37
|
-
end
|
30
|
+
expect(response.body).to eq("https://people-staging.planningcenteronline.com")
|
38
31
|
|
39
|
-
|
40
|
-
host! "accounts.pco.test"
|
32
|
+
host! "accounts-staging.planningcenter.com"
|
41
33
|
get "/test"
|
42
|
-
expect(response.body).to eq("https://people-staging.
|
34
|
+
expect(response.body).to eq("https://people-staging.planningcenter.com")
|
43
35
|
end
|
44
36
|
end
|
45
37
|
|
46
|
-
context "in production
|
38
|
+
context "in production" do
|
47
39
|
before do
|
48
40
|
ENV["DEPLOY_ENV"] = Rails.env = "production"
|
49
41
|
end
|
50
42
|
|
51
|
-
it "
|
52
|
-
host! "accounts.
|
43
|
+
it "sets the generated URL domain to be the same as the host" do
|
44
|
+
host! "accounts.planningcenteronline.com"
|
53
45
|
get "/test"
|
54
46
|
expect(response.body).to eq("https://people.planningcenteronline.com")
|
47
|
+
|
48
|
+
host! "accounts.planningcenter.com"
|
49
|
+
get "/test"
|
50
|
+
expect(response.body).to eq("https://people.planningcenter.com")
|
51
|
+
end
|
52
|
+
|
53
|
+
context "when the host is something unrecognized" do
|
54
|
+
before { host! "accounts.evilplanningcenter.com" }
|
55
|
+
|
56
|
+
it "sets the generated URL domain to be .planningcenteronline.com" do
|
57
|
+
get "/test"
|
58
|
+
expect(response.body).to eq("https://people.planningcenteronline.com")
|
59
|
+
end
|
55
60
|
end
|
56
61
|
end
|
57
62
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pco-url
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Miller
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: appraisal
|
@@ -128,10 +128,10 @@ files:
|
|
128
128
|
- LICENSE.txt
|
129
129
|
- README.md
|
130
130
|
- Rakefile
|
131
|
-
- gemfiles/rails_5.0.gemfile
|
132
|
-
- gemfiles/rails_5.1.gemfile
|
133
131
|
- gemfiles/rails_5.2.gemfile
|
134
132
|
- gemfiles/rails_6.0.gemfile
|
133
|
+
- gemfiles/rails_6.1.gemfile
|
134
|
+
- gemfiles/rails_edge.gemfile
|
135
135
|
- lib/pco/url.rb
|
136
136
|
- lib/pco/url/church_center.rb
|
137
137
|
- lib/pco/url/encryption.rb
|
@@ -146,7 +146,7 @@ files:
|
|
146
146
|
- spec/pco/url/church_center_spec.rb
|
147
147
|
- spec/pco/url/encryption_spec.rb
|
148
148
|
- spec/pco_url_spec.rb
|
149
|
-
- spec/requests/
|
149
|
+
- spec/requests/domain_middleware_spec.rb
|
150
150
|
- spec/spec_helper.rb
|
151
151
|
homepage: https://github.com/ministrycentered/pco-url
|
152
152
|
licenses:
|
@@ -167,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
167
|
- !ruby/object:Gem::Version
|
168
168
|
version: '0'
|
169
169
|
requirements: []
|
170
|
-
rubygems_version: 3.
|
170
|
+
rubygems_version: 3.2.6
|
171
171
|
signing_key:
|
172
172
|
specification_version: 4
|
173
173
|
summary: Generate URLs for PCO apps in all environments
|
@@ -178,5 +178,5 @@ test_files:
|
|
178
178
|
- spec/pco/url/church_center_spec.rb
|
179
179
|
- spec/pco/url/encryption_spec.rb
|
180
180
|
- spec/pco_url_spec.rb
|
181
|
-
- spec/requests/
|
181
|
+
- spec/requests/domain_middleware_spec.rb
|
182
182
|
- spec/spec_helper.rb
|