jbbarth / redmine_omniauth_cas

CAS authentication plugin for Redmine through OmniAuth
MIT License
19 stars 14 forks source link

Unable to add OmniAuth::Builder middleware as the middleware stack is frozen #28

Closed pini-gh closed 3 months ago

pini-gh commented 6 months ago

Hi,

Many thanks for this plugin :smile:

I'm trying to upgrade our redmine instance from 4.2.10 to 5.x, and with whichever 5.x release I try (tried 5.0.0, 5.0.5 and 5.1.1) I encounter this error when running the command RAILS_ENV=production rake redmine:plugins:

/!\ Unable to add OmniAuth::Builder middleware as the middleware stack is frozen

Here is the complete log of the installation:

$ docker exec -it redmine /bin/bash
root@redmine:/usr/src/redmine# cd plugins/
root@redmine:/usr/src/redmine/plugins# git clone https://github.com/jbbarth/redmine_omniauth_cas.git
Cloning into 'redmine_omniauth_cas'...
remote: Enumerating objects: 726, done.
remote: Counting objects: 100% (131/131), done.
remote: Compressing objects: 100% (82/82), done.
remote: Total 726 (delta 67), reused 91 (delta 36), pack-reused 595
Receiving objects: 100% (726/726), 100.89 KiB | 983.00 KiB/s, done.
Resolving deltas: 100% (298/298), done.
root@redmine:/usr/src/redmine/plugins# bundle install
Your Gemfile lists the gem puma (>= 0) more than once.
You should probably keep only one of them.
Remove any duplicate entries and specify the gem only once.
While it's not a problem now, it could cause errors if you change the version of one of them later.
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Fetching hashie 5.0.0
Installing hashie 5.0.0
Fetching omniauth 1.9.2
Installing omniauth 1.9.2
Fetching omniauth-cas 1.1.1
Installing omniauth-cas 1.1.1
Bundle complete! 44 Gemfile dependencies, 77 gems now installed.
Gems in the groups 'development' and 'test' were not installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
root@redmine:/usr/src/redmine/plugins# cd ..
root@redmine:/usr/src/redmine# RAILS_ENV=production rake redmine:plugins
W, [2024-02-24T14:16:22.826247 #64]  WARN -- : Unable to add OmniAuth::Builder middleware as the middleware stack is frozen
/!\ Unable to add OmniAuth::Builder middleware as the middleware stack is frozen
W, [2024-02-24T14:16:22.975757 #64]  WARN -- : Creating scope :system. Overwriting existing method Enumeration.system.
W, [2024-02-24T14:16:23.143663 #64]  WARN -- : Creating scope :sorted. Overwriting existing method User.sorted.

Then after restarting the instance it fails with:

=> Booting Puma
=> Rails 6.1.7.6 application starting in production 
=> Run `bin/rails server --help` for more startup options
W, [2024-02-24T14:21:06.660219 #1]  WARN -- : Unable to add OmniAuth::Builder middleware as the middleware stack is frozen
/!\ Unable to add OmniAuth::Builder middleware as the middleware stack is frozen
W, [2024-02-24T14:21:06.784926 #1]  WARN -- : Creating scope :system. Overwriting existing method Enumeration.system.
W, [2024-02-24T14:21:06.961181 #1]  WARN -- : Creating scope :sorted. Overwriting existing method User.sorted.
Exiting
/usr/local/bundle/gems/zeitwerk-2.6.13/lib/zeitwerk/loader/helpers.rb:135:in `const_get': uninitialized constant Omniauth::DynamicFullHost (NameError)

    parent.const_get(cname, false)
          ^^^^^^^^^^
        from /usr/local/bundle/gems/zeitwerk-2.6.13/lib/zeitwerk/loader/helpers.rb:135:in `cget'
        from /usr/local/bundle/gems/zeitwerk-2.6.13/lib/zeitwerk/loader/eager_load.rb:175:in `block in actual_eager_load_dir'
        from /usr/local/bundle/gems/zeitwerk-2.6.13/lib/zeitwerk/loader/helpers.rb:40:in `block in ls'
        from /usr/local/bundle/gems/zeitwerk-2.6.13/lib/zeitwerk/loader/helpers.rb:25:in `each'
        from /usr/local/bundle/gems/zeitwerk-2.6.13/lib/zeitwerk/loader/helpers.rb:25:in `ls'
        from /usr/local/bundle/gems/zeitwerk-2.6.13/lib/zeitwerk/loader/eager_load.rb:170:in `actual_eager_load_dir'
        from /usr/local/bundle/gems/zeitwerk-2.6.13/lib/zeitwerk/loader/eager_load.rb:17:in `block (2 levels) in eager_load'
        from /usr/local/bundle/gems/zeitwerk-2.6.13/lib/zeitwerk/loader/eager_load.rb:16:in `each'
        from /usr/local/bundle/gems/zeitwerk-2.6.13/lib/zeitwerk/loader/eager_load.rb:16:in `block in eager_load'
        from /usr/local/bundle/gems/zeitwerk-2.6.13/lib/zeitwerk/loader/eager_load.rb:10:in `synchronize'
        from /usr/local/bundle/gems/zeitwerk-2.6.13/lib/zeitwerk/loader/eager_load.rb:10:in `eager_load'
        from /usr/local/bundle/gems/zeitwerk-2.6.13/lib/zeitwerk/loader.rb:379:in `block in eager_load_all'
        from /usr/local/bundle/gems/zeitwerk-2.6.13/lib/zeitwerk/loader.rb:377:in `each'
        from /usr/local/bundle/gems/zeitwerk-2.6.13/lib/zeitwerk/loader.rb:377:in `eager_load_all'
        from /usr/local/bundle/gems/railties-6.1.7.6/lib/rails/application/finisher.rb:133:in `block in <module:Finisher>'
        from /usr/local/bundle/gems/railties-6.1.7.6/lib/rails/initializable.rb:32:in `instance_exec'
        from /usr/local/bundle/gems/railties-6.1.7.6/lib/rails/initializable.rb:32:in `run'
        from /usr/local/bundle/gems/railties-6.1.7.6/lib/rails/initializable.rb:61:in `block in run_initializers'
        from /usr/local/lib/ruby/3.2.0/tsort.rb:228:in `block in tsort_each'
        from /usr/local/lib/ruby/3.2.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
        from /usr/local/lib/ruby/3.2.0/tsort.rb:431:in `each_strongly_connected_component_from'
        from /usr/local/lib/ruby/3.2.0/tsort.rb:349:in `block in each_strongly_connected_component'
        from /usr/local/lib/ruby/3.2.0/tsort.rb:347:in `each'
        from /usr/local/lib/ruby/3.2.0/tsort.rb:347:in `call'
        from /usr/local/lib/ruby/3.2.0/tsort.rb:347:in `each_strongly_connected_component'
        from /usr/local/lib/ruby/3.2.0/tsort.rb:226:in `tsort_each'
        from /usr/local/lib/ruby/3.2.0/tsort.rb:205:in `tsort_each'
        from /usr/local/bundle/gems/railties-6.1.7.6/lib/rails/initializable.rb:60:in `run_initializers'
        from /usr/local/bundle/gems/railties-6.1.7.6/lib/rails/application.rb:391:in `initialize!'
        from /usr/src/redmine/config/environment.rb:16:in `<top (required)>'
        from config.ru:3:in `require_relative'
        from config.ru:3:in `block in <main>'
        from /usr/local/bundle/gems/rack-2.2.8/lib/rack/builder.rb:116:in `eval'
        from /usr/local/bundle/gems/rack-2.2.8/lib/rack/builder.rb:116:in `new_from_string'
        from /usr/local/bundle/gems/rack-2.2.8/lib/rack/builder.rb:105:in `load_file'
        from /usr/local/bundle/gems/rack-2.2.8/lib/rack/builder.rb:66:in `parse_file'
        from /usr/local/bundle/gems/rack-2.2.8/lib/rack/server.rb:349:in `build_app_and_options_from_config'
        from /usr/local/bundle/gems/rack-2.2.8/lib/rack/server.rb:249:in `app'
        from /usr/local/bundle/gems/rack-2.2.8/lib/rack/server.rb:422:in `wrapped_app'
        from /usr/local/bundle/gems/rack-2.2.8/lib/rack/server.rb:312:in `block in start'
        from /usr/local/bundle/gems/rack-2.2.8/lib/rack/server.rb:379:in `handle_profiling'
        from /usr/local/bundle/gems/rack-2.2.8/lib/rack/server.rb:311:in `start'
        from /usr/local/bundle/gems/railties-6.1.7.6/lib/rails/commands/server/server_command.rb:39:in `start'
        from /usr/local/bundle/gems/railties-6.1.7.6/lib/rails/commands/server/server_command.rb:144:in `block in perform'
        from <internal:kernel>:90:in `tap'
        from /usr/local/bundle/gems/railties-6.1.7.6/lib/rails/commands/server/server_command.rb:135:in `perform'
        from /usr/local/bundle/gems/thor-1.3.0/lib/thor/command.rb:28:in `run'
        from /usr/local/bundle/gems/thor-1.3.0/lib/thor/invocation.rb:127:in `invoke_command'
        from /usr/local/bundle/gems/thor-1.3.0/lib/thor.rb:527:in `dispatch'
        from /usr/local/bundle/gems/railties-6.1.7.6/lib/rails/command/base.rb:69:in `perform'
        from /usr/local/bundle/gems/railties-6.1.7.6/lib/rails/command.rb:48:in `invoke'
        from /usr/local/bundle/gems/railties-6.1.7.6/lib/rails/commands.rb:18:in `<top (required)>'
        from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
        from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
        from bin/rails:4:in `<main>'

Any clue appreciated :smile:

dgeo commented 4 months ago

same here… but no clue :(

pini-gh commented 4 months ago

With no answer at all from the devs I've switched to redmine_openid_connect. It's not perfect, but at least I've been able to patch it so that it works with our LemonLDAP::NG instance.

mingming-cn commented 3 months ago

I have fixed this issue. Please check https://github.com/mingming-cn/redmine_omniauth_cas or https://github.com/jbbarth/redmine_omniauth_cas/pull/30

dgeo commented 3 months ago

thank you @mingming-cn, it works for me™ with apereo's cas server

nanego commented 3 months ago

I have merged @mingming-cn's pull request to the master branch. Thank you for your contribution.