Skip to content

Commit 613bdf1

Browse files
committed
security: bump solrengine to 0.2.0 + mount auth engine
Replaces the local SessionsController + sessions/new view with the bundled Solrengine::Auth::Engine. The local controller had the SIWS replay vulnerability — verifier only checked that the signed message contained some nonce-looking string, never bound it to user.nonce. solrengine-auth 0.2.0 fixes this at the verifier level (secure_compare of expected_nonce:) and the bundled controller passes user.nonce to it, so mounting the engine inherits the fix with no per-app plumbing. - bundle update solrengine -> 0.2.0 (pulls auth 0.2.0 + programs 0.2.0) - Delete app/controllers/sessions_controller.rb - Delete app/views/sessions/new.html.erb - Delete test/controllers/sessions_controller_test.rb (gem covers it) - routes.rb: replace 4 explicit auth routes with mount Solrengine::Auth::Engine => "/auth", as: :solrengine_auth - Swap login_path / logout_path / auth_nonce_path / auth_verify_path helpers to solrengine_auth.* in ApplicationController#authenticate!, pages/landing, dashboard/show - authenticate! respond_to html (redirect) + json (401 + code) so agents don't get HTML redirects on expired sessions - transfers_controller_test.rb: switch to absolute path strings for main-app routes. Rails' ActionDispatch::Integration::Session swaps its _routes context to the engine's after any request into the mounted engine, so both new_transfer_path and main_app.new_transfer_path start resolving to /auth/transfers/new. Using "/transfers/new" sidesteps the helper entirely.
1 parent ea969b0 commit 613bdf1

9 files changed

Lines changed: 85 additions & 287 deletions

File tree

Gemfile.lock

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,65 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
actioncable (8.0.4)
5-
actionpack (= 8.0.4)
6-
activesupport (= 8.0.4)
4+
actioncable (8.0.5)
5+
actionpack (= 8.0.5)
6+
activesupport (= 8.0.5)
77
nio4r (~> 2.0)
88
websocket-driver (>= 0.6.1)
99
zeitwerk (~> 2.6)
10-
actionmailbox (8.0.4)
11-
actionpack (= 8.0.4)
12-
activejob (= 8.0.4)
13-
activerecord (= 8.0.4)
14-
activestorage (= 8.0.4)
15-
activesupport (= 8.0.4)
10+
actionmailbox (8.0.5)
11+
actionpack (= 8.0.5)
12+
activejob (= 8.0.5)
13+
activerecord (= 8.0.5)
14+
activestorage (= 8.0.5)
15+
activesupport (= 8.0.5)
1616
mail (>= 2.8.0)
17-
actionmailer (8.0.4)
18-
actionpack (= 8.0.4)
19-
actionview (= 8.0.4)
20-
activejob (= 8.0.4)
21-
activesupport (= 8.0.4)
17+
actionmailer (8.0.5)
18+
actionpack (= 8.0.5)
19+
actionview (= 8.0.5)
20+
activejob (= 8.0.5)
21+
activesupport (= 8.0.5)
2222
mail (>= 2.8.0)
2323
rails-dom-testing (~> 2.2)
24-
actionpack (8.0.4)
25-
actionview (= 8.0.4)
26-
activesupport (= 8.0.4)
24+
actionpack (8.0.5)
25+
actionview (= 8.0.5)
26+
activesupport (= 8.0.5)
2727
nokogiri (>= 1.8.5)
2828
rack (>= 2.2.4)
2929
rack-session (>= 1.0.1)
3030
rack-test (>= 0.6.3)
3131
rails-dom-testing (~> 2.2)
3232
rails-html-sanitizer (~> 1.6)
3333
useragent (~> 0.16)
34-
actiontext (8.0.4)
35-
actionpack (= 8.0.4)
36-
activerecord (= 8.0.4)
37-
activestorage (= 8.0.4)
38-
activesupport (= 8.0.4)
34+
actiontext (8.0.5)
35+
actionpack (= 8.0.5)
36+
activerecord (= 8.0.5)
37+
activestorage (= 8.0.5)
38+
activesupport (= 8.0.5)
3939
globalid (>= 0.6.0)
4040
nokogiri (>= 1.8.5)
41-
actionview (8.0.4)
42-
activesupport (= 8.0.4)
41+
actionview (8.0.5)
42+
activesupport (= 8.0.5)
4343
builder (~> 3.1)
4444
erubi (~> 1.11)
4545
rails-dom-testing (~> 2.2)
4646
rails-html-sanitizer (~> 1.6)
47-
activejob (8.0.4)
48-
activesupport (= 8.0.4)
47+
activejob (8.0.5)
48+
activesupport (= 8.0.5)
4949
globalid (>= 0.3.6)
50-
activemodel (8.0.4)
51-
activesupport (= 8.0.4)
52-
activerecord (8.0.4)
53-
activemodel (= 8.0.4)
54-
activesupport (= 8.0.4)
50+
activemodel (8.0.5)
51+
activesupport (= 8.0.5)
52+
activerecord (8.0.5)
53+
activemodel (= 8.0.5)
54+
activesupport (= 8.0.5)
5555
timeout (>= 0.4.0)
56-
activestorage (8.0.4)
57-
actionpack (= 8.0.4)
58-
activejob (= 8.0.4)
59-
activerecord (= 8.0.4)
60-
activesupport (= 8.0.4)
56+
activestorage (8.0.5)
57+
actionpack (= 8.0.5)
58+
activejob (= 8.0.5)
59+
activerecord (= 8.0.5)
60+
activesupport (= 8.0.5)
6161
marcel (~> 1.0)
62-
activesupport (8.0.4)
62+
activesupport (8.0.5)
6363
base64
6464
benchmark (>= 0.3)
6565
bigdecimal
@@ -81,7 +81,7 @@ GEM
8181
bcrypt_pbkdf (1.1.2-arm64-darwin)
8282
bcrypt_pbkdf (1.1.2-x86_64-darwin)
8383
benchmark (0.5.0)
84-
bigdecimal (4.0.1)
84+
bigdecimal (4.1.2)
8585
bindex (0.8.1)
8686
bootsnap (1.23.0)
8787
msgpack (~> 1.2)
@@ -104,7 +104,7 @@ GEM
104104
railties (>= 6.1)
105105
drb (2.2.3)
106106
ed25519 (1.4.0)
107-
erb (6.0.2)
107+
erb (6.0.3)
108108
erubi (1.13.1)
109109
et-orbi (1.4.0)
110110
tzinfo
@@ -174,7 +174,7 @@ GEM
174174
mcp (0.8.0)
175175
json-schema (>= 4.1)
176176
mini_mime (1.1.5)
177-
minitest (6.0.2)
177+
minitest (6.0.4)
178178
drb (~> 2.0)
179179
prism (~> 1.5)
180180
msgpack (1.8.0)
@@ -231,46 +231,46 @@ GEM
231231
nio4r (~> 2.0)
232232
raabro (1.4.0)
233233
racc (1.8.1)
234-
rack (3.2.5)
235-
rack-session (2.1.1)
234+
rack (3.2.6)
235+
rack-session (2.1.2)
236236
base64 (>= 0.1.0)
237237
rack (>= 3.0.0)
238238
rack-test (2.2.0)
239239
rack (>= 1.3)
240240
rackup (2.3.1)
241241
rack (>= 3)
242-
rails (8.0.4)
243-
actioncable (= 8.0.4)
244-
actionmailbox (= 8.0.4)
245-
actionmailer (= 8.0.4)
246-
actionpack (= 8.0.4)
247-
actiontext (= 8.0.4)
248-
actionview (= 8.0.4)
249-
activejob (= 8.0.4)
250-
activemodel (= 8.0.4)
251-
activerecord (= 8.0.4)
252-
activestorage (= 8.0.4)
253-
activesupport (= 8.0.4)
242+
rails (8.0.5)
243+
actioncable (= 8.0.5)
244+
actionmailbox (= 8.0.5)
245+
actionmailer (= 8.0.5)
246+
actionpack (= 8.0.5)
247+
actiontext (= 8.0.5)
248+
actionview (= 8.0.5)
249+
activejob (= 8.0.5)
250+
activemodel (= 8.0.5)
251+
activerecord (= 8.0.5)
252+
activestorage (= 8.0.5)
253+
activesupport (= 8.0.5)
254254
bundler (>= 1.15.0)
255-
railties (= 8.0.4)
255+
railties (= 8.0.5)
256256
rails-dom-testing (2.3.0)
257257
activesupport (>= 5.0.0)
258258
minitest
259259
nokogiri (>= 1.6)
260260
rails-html-sanitizer (1.7.0)
261261
loofah (~> 2.25)
262262
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)
263-
railties (8.0.4)
264-
actionpack (= 8.0.4)
265-
activesupport (= 8.0.4)
263+
railties (8.0.5)
264+
actionpack (= 8.0.5)
265+
activesupport (= 8.0.5)
266266
irb (~> 1.13)
267267
rackup (>= 1.0.0)
268268
rake (>= 12.2)
269269
thor (~> 1.0, >= 1.2.2)
270270
tsort (>= 0.2)
271271
zeitwerk (~> 2.6)
272272
rainbow (3.1.1)
273-
rake (13.3.1)
273+
rake (13.4.2)
274274
rb-fsevent (0.11.2)
275275
rb-inotify (0.11.1)
276276
ffi (~> 1.0)
@@ -328,18 +328,18 @@ GEM
328328
fugit (~> 1.11)
329329
railties (>= 7.1)
330330
thor (>= 1.3.1)
331-
solrengine (0.1.0)
332-
solrengine-auth (~> 0.1)
333-
solrengine-programs (~> 0.1)
331+
solrengine (0.2.0)
332+
solrengine-auth (~> 0.2)
333+
solrengine-programs (~> 0.2)
334334
solrengine-realtime (~> 0.1)
335335
solrengine-rpc (~> 0.1)
336336
solrengine-tokens (~> 0.1)
337337
solrengine-transactions (~> 0.1)
338-
solrengine-auth (0.1.0)
338+
solrengine-auth (0.2.0)
339339
base58 (~> 0.2)
340340
ed25519 (~> 1.4)
341341
rails (>= 7.1)
342-
solrengine-programs (0.1.0)
342+
solrengine-programs (0.2.0)
343343
base58 (~> 0.2)
344344
borsh (~> 0.2)
345345
ed25519 (~> 1.3)

app/controllers/application_controller.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ def logged_in?
1616
end
1717

1818
def authenticate!
19-
redirect_to login_path unless logged_in?
19+
return if logged_in?
20+
respond_to do |format|
21+
format.html { redirect_to solrengine_auth.login_path }
22+
format.json { render json: { error: "Not authenticated", code: "unauthenticated" }, status: :unauthorized }
23+
end
2024
end
2125
end

app/controllers/sessions_controller.rb

Lines changed: 0 additions & 60 deletions
This file was deleted.

app/views/dashboard/show.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
</button>
3131

3232
<%# Disconnect %>
33-
<%= button_to "Disconnect", logout_path, method: :delete, class: "text-gray-500 hover:text-white text-xs cursor-pointer transition-colors" %>
33+
<%= button_to "Disconnect", solrengine_auth.logout_path, method: :delete, class: "text-gray-500 hover:text-white text-xs cursor-pointer transition-colors" %>
3434
</div>
3535
</div>
3636
</nav>

app/views/pages/landing.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</div>
1111
<div class="flex items-center gap-4">
1212
<a href="https://github.com/solrengine/wallet-train" target="_blank" class="text-gray-400 hover:text-white text-sm transition-colors">GitHub</a>
13-
<%= link_to "Launch App", login_path, class: "bg-gradient-to-r from-purple-600 to-blue-600 hover:from-purple-500 hover:to-blue-500 text-white text-sm font-medium py-2 px-4 rounded-lg transition-all duration-200" %>
13+
<%= link_to "Launch App", solrengine_auth.login_path, class: "bg-gradient-to-r from-purple-600 to-blue-600 hover:from-purple-500 hover:to-blue-500 text-white text-sm font-medium py-2 px-4 rounded-lg transition-all duration-200" %>
1414
</div>
1515
</div>
1616
</nav>
@@ -30,7 +30,7 @@
3030
</p>
3131

3232
<div class="flex flex-wrap gap-4">
33-
<%= link_to login_path, class: "inline-flex items-center gap-2 bg-gradient-to-r from-purple-600 to-blue-600 hover:from-purple-500 hover:to-blue-500 text-white font-semibold py-3 px-6 rounded-xl transition-all duration-200" do %>
33+
<%= link_to solrengine_auth.login_path, class: "inline-flex items-center gap-2 bg-gradient-to-r from-purple-600 to-blue-600 hover:from-purple-500 hover:to-blue-500 text-white font-semibold py-3 px-6 rounded-xl transition-all duration-200" do %>
3434
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
3535
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1" />
3636
</svg>

app/views/sessions/new.html.erb

Lines changed: 0 additions & 41 deletions
This file was deleted.

config/routes.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@
22
# Health check
33
get "up" => "rails/health#show", as: :rails_health_check
44

5-
# Authentication
6-
get "login", to: "sessions#new", as: :login
7-
get "auth/nonce", to: "sessions#nonce", as: :auth_nonce
8-
post "auth/verify", to: "sessions#create", as: :auth_verify
9-
delete "logout", to: "sessions#destroy", as: :logout
5+
# SIWS authentication — bundled controller from solrengine-auth.
6+
mount Solrengine::Auth::Engine => "/auth", as: :solrengine_auth
107

118
# Dashboard
129
get "dashboard", to: "dashboard#show", as: :dashboard

0 commit comments

Comments
 (0)