thecore_auth_commons 3.8.1 → 3.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ea7d70694d4ed8662308a7b1079017595bc3cf7fb92770eb710bec08f96d46d
4
- data.tar.gz: ca540f3c09c4a372b6b09a8947757bd987f965bad01c463ada25efba4f3105a0
3
+ metadata.gz: 40480d888d3aa872ff12593b3cfbd498fa1d74c37d8db0f286a4e5e91c1eaf86
4
+ data.tar.gz: 4dea171fe437bb5df655898d755de6f70713a006efefbf03f20460d9721f5a94
5
5
  SHA512:
6
- metadata.gz: c4f8a315c7ba049bf758b03121ab7242dfdcdebfb16c66408a25bf71d0bea1c35506a2b672db2813a03424933212e377a16f79445d663e5923d09fe0be346940
7
- data.tar.gz: 61e5c8c8638618b6921c9d50f1bb35c387744141dbeb62254a83dc40b4cbad1be6af7b3bb00bba254ab811579ea2d45d1dcb06a7287bdeefecc99065cc379ebd
6
+ metadata.gz: 338bdae537f346a7065ea546d4a18c3406efde0965032fdb5ccf2958c8ddd7fb259871701097ffca69024bc568645aec5ddb48d8091400de93373368d67a92cf
7
+ data.tar.gz: '039054307d730155b7ae61a3083853d52707e10c0138c773b0398d4a90e4ce3fe6af44e5a50b5804c855293947fd5d213e202e21b71ccefb702322982e0b6f57'
@@ -5,5 +5,11 @@ module ThecoreAuthCommons
5
5
  initializer "thecore_auth_commons.login_failure_throttle" do |app|
6
6
  app.middleware.insert_after ActionDispatch::RemoteIp, ThecoreAuthCommons::LoginFailureThrottle
7
7
  end
8
+
9
+ # Right before Devise's Warden::Manager: the first request's Warden must see the strategies
10
+ # Devise registers when the lazily drawn routes load (host Odoo #6329).
11
+ initializer "thecore_auth_commons.load_routes_before_warden" do |app|
12
+ app.middleware.insert_before Warden::Manager, ThecoreAuthCommons::LoadRoutesBeforeWarden, app
13
+ end
8
14
  end
9
15
  end
@@ -0,0 +1,24 @@
1
+ module ThecoreAuthCommons
2
+ # Loads the application's routes before Warden::Manager sees the request (host Odoo #6329).
3
+ #
4
+ # With config.eager_load off (development, tests outside CI) Rails >= 8.0 draws the routes lazily,
5
+ # inside the router, on the first request. Devise registers Warden's strategies only when the
6
+ # routes load (Devise.configure_warden!), but Warden::Proxy copies the manager's config when the
7
+ # request enters Warden::Manager, before the router: the first request's copy had no strategy, so
8
+ # a sign-in that was the process's first request was refused with the right password.
9
+ #
10
+ # The routes still load on the first request, just one middleware earlier. Once loaded, and with
11
+ # eager_load (production loads them at boot), reload_routes_unless_loaded returns at once. Rails
12
+ # 7.2 draws the routes at boot and has no reload_routes_unless_loaded: nothing to do there.
13
+ class LoadRoutesBeforeWarden
14
+ def initialize(app, application)
15
+ @app = app
16
+ @application = application
17
+ end
18
+
19
+ def call(env)
20
+ @application.reload_routes_unless_loaded if @application.respond_to?(:reload_routes_unless_loaded)
21
+ @app.call(env)
22
+ end
23
+ end
24
+ end
@@ -1,3 +1,3 @@
1
1
  module ThecoreAuthCommons
2
- VERSION = "3.8.1".freeze
2
+ VERSION = "3.8.2".freeze
3
3
  end
@@ -14,6 +14,7 @@ require "omniauth-google-oauth2"
14
14
  require "omniauth-entra-id"
15
15
 
16
16
  require "thecore_auth_commons/login_failure_throttle"
17
+ require "thecore_auth_commons/load_routes_before_warden"
17
18
  require "thecore_auth_commons/engine"
18
19
 
19
20
  require "thecore/seed"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thecore_auth_commons
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.8.1
4
+ version: 3.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriele Tassoni
@@ -307,6 +307,7 @@ files:
307
307
  - lib/thecore/seed.rb
308
308
  - lib/thecore_auth_commons.rb
309
309
  - lib/thecore_auth_commons/engine.rb
310
+ - lib/thecore_auth_commons/load_routes_before_warden.rb
310
311
  - lib/thecore_auth_commons/login_failure_throttle.rb
311
312
  - lib/thecore_auth_commons/version.rb
312
313
  homepage: https://github.com/gabrieletassoni/thecore_auth_commons