Skip to content

Commit 58dc914

Browse files
authored
Merge pull request #3 from oauth-xx/rails-5-2
Rails 5.2
2 parents 2d9d127 + 866ab12 commit 58dc914

File tree

9 files changed

+184
-78
lines changed

9 files changed

+184
-78
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,8 @@ test/dummy/tmp
1818
test/dummy/.sass-cache
1919
tmp
2020
vendor/ruby
21+
22+
# Ignore uploaded files in development, if ever there are any from ActiveStorage
23+
/storage/*
24+
25+
/public/assets

Gemfile.lock

Lines changed: 73 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,71 @@
11
PATH
22
remote: .
33
specs:
4-
masq (0.3.4)
4+
masq2 (1.0.0.pre.beta.1)
55
erb
66
i18n_data
7-
rails (~> 5.1.0)
7+
rails (>= 5.2.8.1)
88
rails-controller-testing
9-
ruby-openid
9+
ruby-openid2 (~> 3.1)
1010
ruby-yadis
11+
version_gem (~> 1.1, >= 1.1.6)
1112
yubikey
1213

1314
GEM
1415
remote: https://rubygems.org/
1516
specs:
16-
actioncable (5.1.7)
17-
actionpack (= 5.1.7)
17+
actioncable (5.2.8.1)
18+
actionpack (= 5.2.8.1)
1819
nio4r (~> 2.0)
19-
websocket-driver (~> 0.6.1)
20-
actionmailer (5.1.7)
21-
actionpack (= 5.1.7)
22-
actionview (= 5.1.7)
23-
activejob (= 5.1.7)
20+
websocket-driver (>= 0.6.1)
21+
actionmailer (5.2.8.1)
22+
actionpack (= 5.2.8.1)
23+
actionview (= 5.2.8.1)
24+
activejob (= 5.2.8.1)
2425
mail (~> 2.5, >= 2.5.4)
2526
rails-dom-testing (~> 2.0)
26-
actionpack (5.1.7)
27-
actionview (= 5.1.7)
28-
activesupport (= 5.1.7)
29-
rack (~> 2.0)
27+
actionpack (5.2.8.1)
28+
actionview (= 5.2.8.1)
29+
activesupport (= 5.2.8.1)
30+
rack (~> 2.0, >= 2.0.8)
3031
rack-test (>= 0.6.3)
3132
rails-dom-testing (~> 2.0)
3233
rails-html-sanitizer (~> 1.0, >= 1.0.2)
33-
actionview (5.1.7)
34-
activesupport (= 5.1.7)
34+
actionview (5.2.8.1)
35+
activesupport (= 5.2.8.1)
3536
builder (~> 3.1)
3637
erubi (~> 1.4)
3738
rails-dom-testing (~> 2.0)
3839
rails-html-sanitizer (~> 1.0, >= 1.0.3)
39-
activejob (5.1.7)
40-
activesupport (= 5.1.7)
40+
activejob (5.2.8.1)
41+
activesupport (= 5.2.8.1)
4142
globalid (>= 0.3.6)
42-
activemodel (5.1.7)
43-
activesupport (= 5.1.7)
44-
activerecord (5.1.7)
45-
activemodel (= 5.1.7)
46-
activesupport (= 5.1.7)
47-
arel (~> 8.0)
48-
activesupport (5.1.7)
43+
activemodel (5.2.8.1)
44+
activesupport (= 5.2.8.1)
45+
activerecord (5.2.8.1)
46+
activemodel (= 5.2.8.1)
47+
activesupport (= 5.2.8.1)
48+
arel (>= 9.0)
49+
activestorage (5.2.8.1)
50+
actionpack (= 5.2.8.1)
51+
activerecord (= 5.2.8.1)
52+
marcel (~> 1.0.0)
53+
activesupport (5.2.8.1)
4954
concurrent-ruby (~> 1.0, >= 1.0.2)
5055
i18n (>= 0.7, < 2)
5156
minitest (~> 5.1)
5257
tzinfo (~> 1.1)
53-
arel (8.0.0)
58+
arel (9.0.0)
59+
base64 (0.2.0)
5460
builder (3.3.0)
5561
byebug (11.1.3)
5662
cgi (0.4.1)
5763
concurrent-ruby (1.3.4)
5864
crass (1.0.6)
59-
date (3.4.0)
65+
date (3.4.1)
6066
erb (4.0.4)
6167
cgi (>= 0.3.3)
62-
erubi (1.13.0)
68+
erubi (1.13.1)
6369
globalid (1.1.0)
6470
activesupport (>= 5.0)
6571
guard-compat (1.2.1)
@@ -70,22 +76,23 @@ GEM
7076
concurrent-ruby (~> 1.0)
7177
i18n_data (0.17.1)
7278
simple_po_parser (~> 1.1)
73-
loofah (2.23.1)
79+
loofah (2.24.0)
7480
crass (~> 1.0.2)
7581
nokogiri (>= 1.12.0)
7682
mail (2.8.1)
7783
mini_mime (>= 0.1.1)
7884
net-imap
7985
net-pop
8086
net-smtp
87+
marcel (1.0.4)
8188
method_source (1.1.0)
8289
mini_mime (1.1.5)
83-
mini_portile2 (2.8.7)
84-
minitest (5.25.1)
85-
mocha (2.5.0)
90+
mini_portile2 (2.8.8)
91+
minitest (5.25.4)
92+
mocha (2.7.1)
8693
ruby2_keywords (>= 0.0.5)
8794
mysql2 (0.5.6)
88-
net-imap (0.4.17)
95+
net-imap (0.4.18)
8996
date
9097
net-protocol
9198
net-pop (0.1.2)
@@ -95,24 +102,26 @@ GEM
95102
net-smtp (0.5.0)
96103
net-protocol
97104
nio4r (2.7.4)
98-
nokogiri (1.15.6-arm64-darwin)
105+
nokogiri (1.15.7-arm64-darwin)
99106
racc (~> 1.4)
100107
pg (1.5.9)
108+
power_assert (2.0.5)
101109
racc (1.8.1)
102110
rack (2.2.10)
103-
rack-test (2.1.0)
111+
rack-test (2.2.0)
104112
rack (>= 1.3)
105-
rails (5.1.7)
106-
actioncable (= 5.1.7)
107-
actionmailer (= 5.1.7)
108-
actionpack (= 5.1.7)
109-
actionview (= 5.1.7)
110-
activejob (= 5.1.7)
111-
activemodel (= 5.1.7)
112-
activerecord (= 5.1.7)
113-
activesupport (= 5.1.7)
113+
rails (5.2.8.1)
114+
actioncable (= 5.2.8.1)
115+
actionmailer (= 5.2.8.1)
116+
actionpack (= 5.2.8.1)
117+
actionview (= 5.2.8.1)
118+
activejob (= 5.2.8.1)
119+
activemodel (= 5.2.8.1)
120+
activerecord (= 5.2.8.1)
121+
activestorage (= 5.2.8.1)
122+
activesupport (= 5.2.8.1)
114123
bundler (>= 1.3.0)
115-
railties (= 5.1.7)
124+
railties (= 5.2.8.1)
116125
sprockets-rails (>= 2.0.0)
117126
rails-controller-testing (1.0.5)
118127
actionpack (>= 5.0.1.rc1)
@@ -122,37 +131,42 @@ GEM
122131
activesupport (>= 5.0.0)
123132
minitest
124133
nokogiri (>= 1.6)
125-
rails-html-sanitizer (1.6.0)
134+
rails-html-sanitizer (1.6.2)
126135
loofah (~> 2.21)
127-
nokogiri (~> 1.14)
128-
railties (5.1.7)
129-
actionpack (= 5.1.7)
130-
activesupport (= 5.1.7)
136+
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
137+
railties (5.2.8.1)
138+
actionpack (= 5.2.8.1)
139+
activesupport (= 5.2.8.1)
131140
method_source
132141
rake (>= 0.8.7)
133-
thor (>= 0.18.1, < 2.0)
142+
thor (>= 0.19.0, < 2.0)
134143
rake (13.2.1)
135144
rb-fsevent (0.11.2)
136-
ruby-openid (2.9.2)
145+
ruby-openid2 (3.1.0)
146+
version_gem (~> 1.1, >= 1.1.4)
137147
ruby-yadis (0.3.4)
138148
ruby2_keywords (0.0.5)
139149
ruby_gntp (0.3.4)
140150
simple_po_parser (1.1.6)
141151
sprockets (4.2.1)
142152
concurrent-ruby (~> 1.0)
143153
rack (>= 2.2.4, < 4)
144-
sprockets-rails (3.2.2)
145-
actionpack (>= 4.0)
146-
activesupport (>= 4.0)
154+
sprockets-rails (3.4.2)
155+
actionpack (>= 5.2)
156+
activesupport (>= 5.2)
147157
sprockets (>= 3.0.0)
148158
sqlite3 (1.7.3)
149159
mini_portile2 (~> 2.8.0)
160+
test-unit (3.6.7)
161+
power_assert
150162
thor (1.3.2)
151163
thread_safe (0.3.6)
152-
timeout (0.4.2)
164+
timeout (0.4.3)
153165
tzinfo (1.2.11)
154166
thread_safe (~> 0.1)
155-
websocket-driver (0.6.5)
167+
version_gem (1.1.6)
168+
websocket-driver (0.7.7)
169+
base64
156170
websocket-extensions (>= 0.1.0)
157171
websocket-extensions (0.1.5)
158172
yubikey (1.4.1)
@@ -163,7 +177,7 @@ PLATFORMS
163177
DEPENDENCIES
164178
byebug
165179
guard-minitest
166-
masq!
180+
masq2!
167181
minitest
168182
mocha
169183
mysql2
@@ -172,6 +186,7 @@ DEPENDENCIES
172186
rb-fsevent
173187
ruby_gntp
174188
sqlite3
189+
test-unit (~> 3.0)
175190

176191
BUNDLED WITH
177192
2.4.22

README.md

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,62 @@ client-server communication (like requesting simple registration data).
5959
### Introduction
6060

6161
`masq2` adds ORACLE database support, as well as support for
62-
Rails 5.1, 5.2, 6.0, 6.1, 7.0, 7.1, 7.2, 8.0,
62+
Rails 5.2, 6.0, 6.1, 7.0, 7.1, 7.2, 8.0,
6363
which `masq` never had.
6464

6565
The main functionality is in the server controller, which is the endpoint for incoming
6666
OpenID requests. The server controller is supposed to only interact with relying parties
6767
a.k.a. consumer websites. It includes the OpenidServerSystem module, which provides some
6868
handy methods to access and answer OpenID requests.
6969

70+
#### v1 Release Breaking Change
71+
72+
\[📒Also Rails 5.2+ / Serialization / Psych Caveats\]
73+
74+
v1 release has a breaking change from the ancient masq v0.3.4 release.
75+
Continue reading if you think it may impact you.
76+
77+
Rails 5.2.8.1 is a security patch release to fix CVE-2022-32224.
78+
See: https://discuss.rubyonrails.org/t/cve-2022-32224-possible-rce-escalation-bug-with-serialized-columns-in-active-record/81017
79+
80+
The patch (Rails v5.2.8.1) causes an error with `masq` v0.3.4
81+
(... actually it doesn't work at all on Rails v5, but some forks have been fixed):
82+
83+
```
84+
Psych::DisallowedClass: Tried to load unspecified class: ActiveSupport::HashWithIndifferentAccess
85+
```
86+
87+
when serializing a Hash the way we had done in previous versions `app/models/masq/open_id_request.rb`:
88+
```ruby
89+
serialize :parameters, Hash
90+
```
91+
92+
so we instead switch to serializing as JSON:
93+
```ruby
94+
serialize :parameters, JSON
95+
```
96+
97+
If an implementation needs to continue using the serialized Hash,
98+
you will need to override the definition by reopening the model, and adding:
99+
100+
```ruby
101+
serialize :parameters, Hash
102+
```
103+
104+
In addition, one of the following is also needed.
105+
106+
1. Simple, but insecure fix, which reverts to previous unpatched behavior is:
107+
108+
```ruby
109+
Rails.application.config.active_record.use_yaml_unsafe_load = true
110+
```
111+
112+
2. More complex, and a bit less insecure fix, is to explicitly list the allowed classes to serialize:
113+
114+
```ruby
115+
Rails.application.config.active_record.yaml_column_permitted_classes = [Symbol, Date, Time, HashWithIndifferentAccess]
116+
```
117+
70118
### Testing
71119

72120
You can run the tests with Rake:

app/models/masq/open_id_request.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class OpenIdRequest < ActiveRecord::Base
55
before_validation :make_token, :on => :create
66

77
#attr_accessible :parameters
8-
serialize :parameters, Hash
8+
serialize :parameters, JSON
99

1010
def parameters
1111
self[:parameters]

lib/masq.rb

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
1-
require "masq/engine"
2-
require "masq/authenticated_system"
3-
require "masq/openid_server_system"
4-
require "masq/active_record_openid_store/association"
5-
require "masq/active_record_openid_store/nonce"
6-
require "masq/active_record_openid_store/openid_ar_store"
1+
# external gems
2+
require "version_gem"
3+
4+
# this library's version
5+
require_relative "masq/version"
6+
7+
require_relative "masq/engine"
8+
require_relative "masq/authenticated_system"
9+
require_relative "masq/openid_server_system"
10+
require_relative "masq/active_record_openid_store/association"
11+
require_relative "masq/active_record_openid_store/nonce"
12+
require_relative "masq/active_record_openid_store/openid_ar_store"
13+
14+
module Masq
15+
# Namespace for this library
16+
end
17+
18+
# Ensure version is configured before loading the rest of the library
19+
Masq::Version.class_eval do
20+
extend VersionGem::Basic
21+
end

lib/masq/version.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
module Masq
2-
VERSION = "0.3.4"
2+
module Version
3+
VERSION = "1.0.0-beta.1"
4+
end
35
end

masq.gemspec

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
1-
$:.push File.expand_path("../lib", __FILE__)
2-
3-
# Maintain your gem's version:
4-
require "masq/version"
1+
# Get the GEMFILE_VERSION without *require* "my_gem/version", for code coverage accuracy
2+
# See: https://github.com/simplecov-ruby/simplecov/issues/557#issuecomment-2630782358
3+
# Kernel.load because load is overloaded in RubyGems during gemspec evaluation
4+
Kernel.load("lib/masq/version.rb")
5+
gem_version = Masq::Version::VERSION
6+
Masq::Version.send(:remove_const, :VERSION)
57

68
# Describe your gem and declare its dependencies:
79
Gem::Specification.new do |s|
810
s.name = "masq2"
9-
s.version = Masq::VERSION
11+
s.version = gem_version
1012
s.authors = ["Peter Boling", "Dennis Reimann", "Bardoe Besselaar","Nikita Vasiliev"]
1113
s.email = ["[email protected]"]
1214
s.homepage = "https://github.com/oauth-xx/masq2"
13-
s.summary = "Mountable Rails engine that provides OpenID server/identity provider functionality"
14-
s.description = "Masq2 supports the current OpenID specifications (OpenID 2.0) and supports SReg, AX (fetch and store requests) and PAPE as well as some custom additions like multi-factor authentication using a yubikey"
15+
s.summary = "Mountable Rails engine that provides OpenID 2.0 server/identity provider functionality"
16+
s.description = "Masq2 supports OpenID 2.0 and supports SReg, AX (fetch and store requests) and PAPE as well as some custom additions like multi-factor authentication using a yubikey"
1517

1618
s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.md"]
1719
s.test_files = Dir["test/**/*"]
1820

19-
s.add_dependency "rails", "~> 5.1.0"
21+
s.add_dependency "version_gem", "~> 1.1", ">= 1.1.6"
22+
s.add_dependency "rails", ">= 5.2.8.1"
2023
s.add_dependency "erb"
2124
s.add_dependency "rails-controller-testing"
22-
s.add_dependency "ruby-openid"
25+
s.add_dependency "ruby-openid2", "~> 3.1"
2326
s.add_dependency "ruby-yadis"
2427
s.add_dependency "yubikey"
2528
s.add_dependency "i18n_data"

0 commit comments

Comments
 (0)