Skip to content

Make warden available across entire application #19017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 27, 2025
Merged

Conversation

NobodysNightmare
Copy link
Contributor

@NobodysNightmare NobodysNightmare commented May 26, 2025

This will be required to use warden for our SCIM endpoints as well, which are implemented in rails controllers. Since Rails controllers do not support mounting rack middlewares partially (the way that e.g. Grape does), the mounting of warden needed to be moved.

This was not super straight-forward, because of load order issues:

  • Requiring a Rails middleware must be done before initialization finished
  • Our warden config was so far done after initialization
  • static_routes were defined in lib, which is automatically reloaded, but auto-reloading code is not allowed during initialization
    • lib_static which is autoloaded_once is fine during init, this is also where the rest of warden authentication is defined

Additionally warden was configured to not handle HTTP 401 responses generated by the upstream app itself. Warden will only be responsible for its own authentication failures and it's still possible to invoke the warden failure app by throwing the :warden symbol, but the application keeps its capability of responding with custom 401 responses.

Ticket

This will enable implementation of https://community.openproject.org/wp/62592

This will be required to use warden for our SCIM endpoints as well,
which are implemented in rails controllers. Since Rails controllers do
not support mounting rack middlewares partially (the way that e.g. Grape does),
the mounting of warden needed to be moved.

This was not super straight-forward, because of load order issues:

* Requiring a Rails middleware must be done before initialization finished
* Our warden config was so far done _after_ initialization
* static_routes were defined in lib, which is automatically reloaded,
  but auto-reloading code is not allowed during initialization
    * lib_static which is autoloaded_once is fine during init,
      this is also where the rest of warden authentication is defined

Additionally warden was configured to not handle HTTP 401 responses generated
by the upstream app itself. Warden will only be responsible for its own authentication
failures and it's still possible to invoke the warden failure app by throwing the :warden
symbol, but the application keeps its capability of responding with custom 401 responses.
Copy link
Member

@ba1ash ba1ash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks reasonable to me.

Copy link
Member

@oliverguenther oliverguenther left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No objections 👍

@NobodysNightmare NobodysNightmare merged commit 6fc2fcf into dev May 27, 2025
14 checks passed
@NobodysNightmare NobodysNightmare deleted the global-warden branch May 27, 2025 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants