Skip to content

Commit e9e8cf3

Browse files
committed
Update linzer to 0.7
Also updates some other dependencies in Gemfile(s) This uses the new linzer APIs and fixes an interopability bug in the signatures.
1 parent 996ac18 commit e9e8cf3

File tree

13 files changed

+274
-189
lines changed

13 files changed

+274
-189
lines changed

debug_fasp/Gemfile.lock

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ PATH
44
fasp_base (0.1.0)
55
bcrypt
66
httpx
7-
linzer
7+
linzer (>= 0.7.2)
88
openssl
99
rails (>= 8.0.0)
1010

@@ -111,6 +111,7 @@ GEM
111111
rack-test (>= 0.6.3)
112112
regexp_parser (>= 1.5, < 3.0)
113113
xpath (~> 3.2)
114+
cgi (0.4.2)
114115
concurrent-ruby (1.3.5)
115116
connection_pool (2.5.3)
116117
crack (1.0.0)
@@ -121,18 +122,20 @@ GEM
121122
debug (1.10.0)
122123
irb (~> 1.10)
123124
reline (>= 0.3.8)
124-
drb (2.2.1)
125+
drb (2.2.3)
126+
erb (5.0.1)
125127
erubi (1.13.1)
126128
et-orbi (1.2.11)
127129
tzinfo
130+
forwardable (1.3.3)
128131
fugit (1.11.1)
129132
et-orbi (~> 1, >= 1.2.11)
130133
raabro (~> 1.4)
131134
globalid (1.2.1)
132135
activesupport (>= 6.1)
133-
hashdiff (1.1.2)
136+
hashdiff (1.2.0)
134137
http-2 (1.1.1)
135-
httpx (1.4.4)
138+
httpx (1.5.0)
136139
http-2 (>= 1.0.0)
137140
i18n (1.14.7)
138141
concurrent-ruby (~> 1.0)
@@ -148,17 +151,21 @@ GEM
148151
jbuilder (2.13.0)
149152
actionview (>= 5.0.0)
150153
activesupport (>= 5.0.0)
151-
json (2.11.3)
152-
language_server-protocol (3.17.0.4)
154+
json (2.12.1)
155+
language_server-protocol (3.17.0.5)
153156
lint_roller (1.1.0)
154-
linzer (0.6.5)
157+
linzer (0.7.2)
158+
cgi (~> 0.4.2)
159+
forwardable (~> 1.3, >= 1.3.3)
160+
logger (~> 1.7, >= 1.7.0)
161+
net-http (~> 0.6.0)
155162
openssl (~> 3.0, >= 3.0.0)
156163
rack (>= 2.2, < 4.0)
157164
starry (~> 0.2)
158165
stringio (~> 3.1, >= 3.1.2)
159166
uri (~> 1.0, >= 1.0.2)
160167
logger (1.7.0)
161-
loofah (2.24.0)
168+
loofah (2.24.1)
162169
crass (~> 1.0.2)
163170
nokogiri (>= 1.12.0)
164171
mail (2.8.1)
@@ -169,9 +176,11 @@ GEM
169176
marcel (1.0.4)
170177
matrix (0.4.2)
171178
mini_mime (1.1.5)
172-
mini_portile2 (2.8.8)
179+
mini_portile2 (2.8.9)
173180
minitest (5.25.5)
174181
msgpack (1.8.0)
182+
net-http (0.6.0)
183+
uri
175184
net-imap (0.5.8)
176185
date
177186
net-protocol
@@ -215,15 +224,15 @@ GEM
215224
activesupport (>= 7.0.0)
216225
rack
217226
railties (>= 7.0.0)
218-
psych (5.2.4)
227+
psych (5.2.6)
219228
date
220229
stringio
221230
public_suffix (6.0.2)
222231
puma (6.6.0)
223232
nio4r (~> 2.0)
224233
raabro (1.4.0)
225234
racc (1.8.1)
226-
rack (3.1.14)
235+
rack (3.1.15)
227236
rack-session (2.1.1)
228237
base64 (>= 0.1.0)
229238
rack (>= 3.0.0)
@@ -245,7 +254,7 @@ GEM
245254
activesupport (= 8.0.2)
246255
bundler (>= 1.15.0)
247256
railties (= 8.0.2)
248-
rails-dom-testing (2.2.0)
257+
rails-dom-testing (2.3.0)
249258
activesupport (>= 5.0.0)
250259
minitest
251260
nokogiri (>= 1.6)
@@ -262,13 +271,14 @@ GEM
262271
zeitwerk (~> 2.6)
263272
rainbow (3.1.1)
264273
rake (13.2.1)
265-
rdoc (6.13.1)
274+
rdoc (6.14.0)
275+
erb
266276
psych (>= 4.0.0)
267277
regexp_parser (2.10.0)
268278
reline (0.6.1)
269279
io-console (~> 0.5)
270280
rexml (3.4.1)
271-
rubocop (1.75.5)
281+
rubocop (1.75.7)
272282
json (~> 2.3)
273283
language_server-protocol (~> 3.17.0.2)
274284
lint_roller (~> 1.1.0)
@@ -286,12 +296,12 @@ GEM
286296
lint_roller (~> 1.1)
287297
rubocop (>= 1.75.0, < 2.0)
288298
rubocop-ast (>= 1.38.0, < 2.0)
289-
rubocop-rails (2.31.0)
299+
rubocop-rails (2.32.0)
290300
activesupport (>= 4.2.0)
291301
lint_roller (~> 1.1)
292302
rack (>= 1.1)
293303
rubocop (>= 1.75.0, < 2.0)
294-
rubocop-ast (>= 1.38.0, < 2.0)
304+
rubocop-ast (>= 1.44.0, < 2.0)
295305
rubocop-rails-omakase (1.1.0)
296306
rubocop (>= 1.72)
297307
rubocop-performance (>= 1.24)
@@ -334,13 +344,13 @@ GEM
334344
tailwindcss-rails (4.2.3)
335345
railties (>= 7.0.0)
336346
tailwindcss-ruby (~> 4.0)
337-
tailwindcss-ruby (4.1.5)
338-
tailwindcss-ruby (4.1.5-aarch64-linux-gnu)
339-
tailwindcss-ruby (4.1.5-aarch64-linux-musl)
340-
tailwindcss-ruby (4.1.5-arm64-darwin)
341-
tailwindcss-ruby (4.1.5-x86_64-darwin)
342-
tailwindcss-ruby (4.1.5-x86_64-linux-gnu)
343-
tailwindcss-ruby (4.1.5-x86_64-linux-musl)
347+
tailwindcss-ruby (4.1.7)
348+
tailwindcss-ruby (4.1.7-aarch64-linux-gnu)
349+
tailwindcss-ruby (4.1.7-aarch64-linux-musl)
350+
tailwindcss-ruby (4.1.7-arm64-darwin)
351+
tailwindcss-ruby (4.1.7-x86_64-darwin)
352+
tailwindcss-ruby (4.1.7-x86_64-linux-gnu)
353+
tailwindcss-ruby (4.1.7-x86_64-linux-musl)
344354
thor (1.3.2)
345355
thruster (0.1.13)
346356
thruster (0.1.13-aarch64-linux)
@@ -374,7 +384,7 @@ GEM
374384
websocket-extensions (0.1.5)
375385
xpath (3.2.0)
376386
nokogiri (~> 1.8)
377-
zeitwerk (2.7.2)
387+
zeitwerk (2.7.3)
378388

379389
PLATFORMS
380390
aarch64-linux

fasp_base/Gemfile.lock

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ PATH
44
fasp_base (0.1.0)
55
bcrypt
66
httpx
7-
linzer
7+
linzer (>= 0.7.2)
88
openssl
99
rails (>= 8.0.0)
1010

@@ -90,6 +90,7 @@ GEM
9090
benchmark (0.4.0)
9191
bigdecimal (3.1.9)
9292
builder (3.3.0)
93+
cgi (0.4.2)
9394
concurrent-ruby (1.3.5)
9495
connection_pool (2.5.3)
9596
crack (1.0.0)
@@ -100,13 +101,15 @@ GEM
100101
debug (1.10.0)
101102
irb (~> 1.10)
102103
reline (>= 0.3.8)
103-
drb (2.2.1)
104+
drb (2.2.3)
105+
erb (5.0.1)
104106
erubi (1.13.1)
107+
forwardable (1.3.3)
105108
globalid (1.2.1)
106109
activesupport (>= 6.1)
107-
hashdiff (1.1.2)
110+
hashdiff (1.2.0)
108111
http-2 (1.1.1)
109-
httpx (1.4.4)
112+
httpx (1.5.0)
110113
http-2 (>= 1.0.0)
111114
i18n (1.14.7)
112115
concurrent-ruby (~> 1.0)
@@ -115,17 +118,21 @@ GEM
115118
pp (>= 0.6.0)
116119
rdoc (>= 4.0.0)
117120
reline (>= 0.4.2)
118-
json (2.11.3)
119-
language_server-protocol (3.17.0.4)
121+
json (2.12.1)
122+
language_server-protocol (3.17.0.5)
120123
lint_roller (1.1.0)
121-
linzer (0.6.5)
124+
linzer (0.7.2)
125+
cgi (~> 0.4.2)
126+
forwardable (~> 1.3, >= 1.3.3)
127+
logger (~> 1.7, >= 1.7.0)
128+
net-http (~> 0.6.0)
122129
openssl (~> 3.0, >= 3.0.0)
123130
rack (>= 2.2, < 4.0)
124131
starry (~> 0.2)
125132
stringio (~> 3.1, >= 3.1.2)
126133
uri (~> 1.0, >= 1.0.2)
127134
logger (1.7.0)
128-
loofah (2.24.0)
135+
loofah (2.24.1)
129136
crass (~> 1.0.2)
130137
nokogiri (>= 1.12.0)
131138
mail (2.8.1)
@@ -135,8 +142,10 @@ GEM
135142
net-smtp
136143
marcel (1.0.4)
137144
mini_mime (1.1.5)
138-
mini_portile2 (2.8.8)
145+
mini_portile2 (2.8.9)
139146
minitest (5.25.5)
147+
net-http (0.6.0)
148+
uri
140149
net-imap (0.5.8)
141150
date
142151
net-protocol
@@ -180,15 +189,15 @@ GEM
180189
activesupport (>= 7.0.0)
181190
rack
182191
railties (>= 7.0.0)
183-
psych (5.2.4)
192+
psych (5.2.6)
184193
date
185194
stringio
186195
public_suffix (6.0.2)
187196
puma (6.6.0)
188197
nio4r (~> 2.0)
189198
racc (1.8.1)
190-
rack (3.1.13)
191-
rack-session (2.1.0)
199+
rack (3.1.15)
200+
rack-session (2.1.1)
192201
base64 (>= 0.1.0)
193202
rack (>= 3.0.0)
194203
rack-test (2.2.0)
@@ -209,7 +218,7 @@ GEM
209218
activesupport (= 8.0.2)
210219
bundler (>= 1.15.0)
211220
railties (= 8.0.2)
212-
rails-dom-testing (2.2.0)
221+
rails-dom-testing (2.3.0)
213222
activesupport (>= 5.0.0)
214223
minitest
215224
nokogiri (>= 1.6)
@@ -226,13 +235,14 @@ GEM
226235
zeitwerk (~> 2.6)
227236
rainbow (3.1.1)
228237
rake (13.2.1)
229-
rdoc (6.13.1)
238+
rdoc (6.14.0)
239+
erb
230240
psych (>= 4.0.0)
231241
regexp_parser (2.10.0)
232242
reline (0.6.1)
233243
io-console (~> 0.5)
234244
rexml (3.4.1)
235-
rubocop (1.75.5)
245+
rubocop (1.75.7)
236246
json (~> 2.3)
237247
language_server-protocol (~> 3.17.0.2)
238248
lint_roller (~> 1.1.0)
@@ -250,12 +260,12 @@ GEM
250260
lint_roller (~> 1.1)
251261
rubocop (>= 1.75.0, < 2.0)
252262
rubocop-ast (>= 1.38.0, < 2.0)
253-
rubocop-rails (2.31.0)
263+
rubocop-rails (2.32.0)
254264
activesupport (>= 4.2.0)
255265
lint_roller (~> 1.1)
256266
rack (>= 1.1)
257267
rubocop (>= 1.75.0, < 2.0)
258-
rubocop-ast (>= 1.38.0, < 2.0)
268+
rubocop-ast (>= 1.44.0, < 2.0)
259269
rubocop-rails-omakase (1.1.0)
260270
rubocop (>= 1.72)
261271
rubocop-performance (>= 1.24)
@@ -292,7 +302,7 @@ GEM
292302
base64
293303
websocket-extensions (>= 0.1.0)
294304
websocket-extensions (0.1.5)
295-
zeitwerk (2.7.2)
305+
zeitwerk (2.7.3)
296306

297307
PLATFORMS
298308
aarch64-linux

fasp_base/app/controllers/concerns/fasp_base/api_authentication.rb

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def current_user
2929
def require_authentication
3030
validate_content_digest!
3131
validate_signature!
32-
rescue Error, Linzer::Error, ActiveRecord::RecordNotFound => e
32+
rescue Error, ::Linzer::VerifyError, ActiveRecord::RecordNotFound => e
3333
logger.debug("Authentication error: #{e}")
3434
authentication_error
3535
end
@@ -52,37 +52,23 @@ def validate_content_digest!
5252
end
5353

5454
def validate_signature!
55-
signature_input = request.headers["signature-input"]&.encode("UTF-8")
56-
raise Error, "signature-input is missing" if signature_input.blank?
57-
58-
keyid = signature_input.match(KEYID_PATTERN)[1]
59-
server = Server.find(keyid)
60-
linzer_request = Linzer.new_request(
61-
request.method,
62-
request.original_url,
63-
{},
64-
{
65-
"content-digest" => request.headers["content-digest"],
66-
"signature-input" => signature_input,
67-
"signature" => request.headers["signature"]
68-
}
69-
)
70-
message = Linzer::Message.new(linzer_request)
71-
key = Linzer.new_ed25519_public_key(server.public_key_pem, keyid)
72-
signature = Linzer::Signature.build(message.headers)
73-
Linzer.verify(key, message, signature)
55+
raise Error, "signature-input is missing" if request.headers["signature-input"].blank?
56+
57+
server = nil
58+
59+
::Linzer.verify!(request.rack_request, no_older_than: 300) do |keyid|
60+
server = Server.find(keyid)
61+
::Linzer.new_ed25519_public_key(server.public_key_pem, keyid)
62+
end
63+
7464
@current_server = server
7565
end
7666

7767
def sign_response
7868
response.headers["content-digest"] = "sha-256=:#{OpenSSL::Digest.base64digest("sha256", response.body || "")}:"
7969

80-
linzer_response = Linzer.new_response(response.body, response.status, { "content-digest" => response.headers["content-digest"] })
81-
message = Linzer::Message.new(linzer_response)
82-
key = Linzer.new_ed25519_key(current_server.fasp_private_key_pem)
83-
signature = Linzer.sign(key, message, %w[@status content-digest])
84-
85-
response.headers.merge!(signature.to_h)
70+
key = ::Linzer.new_ed25519_key(current_server.fasp_private_key_pem)
71+
::Linzer.sign!(response, key:, components: %w[@status content-digest])
8672
end
8773
end
8874
end

fasp_base/fasp_base.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
2020
spec.add_dependency "rails", ">= 8.0.0"
2121
spec.add_dependency "bcrypt"
2222
spec.add_dependency "httpx"
23-
spec.add_dependency "linzer"
23+
spec.add_dependency "linzer", ">= 0.7.2"
2424
spec.add_dependency "openssl"
2525

2626
spec.add_development_dependency "webmock"

fasp_base/lib/fasp_base.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
require "fasp_base/version"
22
require "fasp_base/engine"
33
require "fasp_base/integration_test_helper"
4+
require "fasp_base/linzer/adapter/action_dispatch/response"
5+
require "fasp_base/linzer/adapter/httpx/request"
6+
require "fasp_base/linzer/adapter/httpx/response"
47
require "fasp_base/request"
58

69
module FaspBase

0 commit comments

Comments
 (0)