GithubHelp home page GithubHelp logo

Comments (9)

fxn avatar fxn commented on August 28, 2024 1

OK, that is not good because middleware is not reloaded. In Rails 7 you won't be able to configure the provider (precisely, to avoid these situations). You should tell the autoloader to ignore lib/omni_auth:

Rails.autoloaders.main.ignore("#{config.root}/lib/omni_auth")

and issue a require call from the initializer.

Not saying this solves the whole situation, but for starters it fixes something.

from zeitwerk.

fxn avatar fxn commented on August 28, 2024

I need to read this with some time, but let me ask a couple of questions:

  1. Who defines OmniAuth::Strategies::ShieldOIDC?
  2. The provider call in the initializer is setting up Rack middleware, right?

from zeitwerk.

fragkakis avatar fragkakis commented on August 28, 2024

Hello Xavier, thank you.

  1. It is a custom strategy within our repository.
  2. Yes, this is my understanding of how omniauth works.

from zeitwerk.

fxn avatar fxn commented on August 28, 2024

Is OmniAuth::Strategies::ShieldOIDC defined in a directory that belongs to the autoload paths?

from zeitwerk.

fragkakis avatar fragkakis commented on August 28, 2024

It is defined in lib/omni_auth/strategies/shield_oidc.rb, and the autoload paths from application.rb are the following:

    config.autoload_paths += %W[
      #{config.root}/app/models/serializable
      #{config.root}/app/models/concerns
      #{config.root}/lib
      #{config.root}/demo
      #{config.root}/qa
      #{config.root}/app/mailers/concerns
    ]

from zeitwerk.

fragkakis avatar fragkakis commented on August 28, 2024

I have a workaround, but it doesn't seem the right. I added the following require statements (with the specific order, so that when application_record is loaded the two dependencies have already been loaded). I also removed the reference to the Member constant in my lib/shield_settings.rb.

# config/initializers/omniauth.rb
# ... other require statements
require "concerns/fine_grained_validations"
require "concerns/policy_scope_support"
require "application_record"

If you have any other insights, I will appreciate it if you chime in. Thank you.

from zeitwerk.

fxn avatar fxn commented on August 28, 2024

OK, we need to polish a bit more.

No reloadable code should be loaded while the application is booting. The file lib/shield_settings.rb is still reloadable, because lib is in the autoload paths. Since the middleware uses the contants defined there, you need to tell the autoloader this file has to be ignored as well:

Rails.autoloaders.main.ignore("#{config.root}/lib/shield_settings.rb")

Let's iterate until we reach a more controlled setup to address the issue with the migrations.

Ideally, no warning should be issued. This section of the upgrdading guide has some tips, but I am here to help you anyway ❤️.

from zeitwerk.

fxn avatar fxn commented on August 28, 2024

Since this is something related to how the Rails application is configured, I have moved the issue to the Rails repository (rails/rails#49310).

from zeitwerk.

eileencodes avatar eileencodes commented on August 28, 2024

I am pretty sure that the connection closed issue is fixed by rails/rails#45450 but it can't be backported to 7-0-stable because it's too big of a change in internal behavior. Upgrading to 7.1.x should fix that particular issue.

from zeitwerk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.