Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Make warden available across entire application

Jan Sandbrink7c978030beb2
diff --git a/config/initializers/warden.rb b/config/initializers/warden.rb
index b2a43c58277..49215af78e2 100644
--- a/config/initializers/warden.rb
+++ b/config/initializers/warden.rb
@@ -1,27 +1,31 @@
-Rails.application.config.after_initialize do
- namespace = OpenProject::Authentication::Strategies::Warden
+# frozen_string_literal: true
- strategies = [
- [:basic_auth_failure, namespace::BasicAuthFailure, "Basic"],
- [:global_basic_auth, namespace::GlobalBasicAuth, "Basic"],
- [:user_basic_auth, namespace::UserBasicAuth, "Basic"],
- [:oauth, namespace::DoorkeeperOAuth, "Bearer"],
- [:anonymous_fallback, namespace::AnonymousFallback, "Basic"],
- [:jwt_oidc, namespace::JwtOidc, "Bearer"],
- [:session, namespace::Session, "Session"]
- ]
+namespace = OpenProject::Authentication::Strategies::Warden
- strategies.each do |name, clazz, auth_scheme|
- OpenProject::Authentication.add_strategy(name, clazz, auth_scheme)
- end
+strategies = [
+ [:basic_auth_failure, namespace::BasicAuthFailure, "Basic"],
+ [:global_basic_auth, namespace::GlobalBasicAuth, "Basic"],
+ [:user_basic_auth, namespace::UserBasicAuth, "Basic"],
+ [:oauth, namespace::DoorkeeperOAuth, "Bearer"],
+ [:anonymous_fallback, namespace::AnonymousFallback, "Basic"],
+ [:jwt_oidc, namespace::JwtOidc, "Bearer"],
+ [:session, namespace::Session, "Session"]
+]
- OpenProject::Authentication.update_strategies(OpenProject::Authentication::Scope::API_V3, { store: false }) do |_|
- %i[global_basic_auth
- user_basic_auth
- basic_auth_failure
- oauth
- jwt_oidc
- session
- anonymous_fallback]
- end
+strategies.each do |name, clazz, auth_scheme|
+ OpenProject::Authentication.add_strategy(name, clazz, auth_scheme)
+end
+
+OpenProject::Authentication.update_strategies(OpenProject::Authentication::Scope::API_V3, { store: false }) do |_|
+ %i[global_basic_auth
+ user_basic_auth
+ basic_auth_failure
+ oauth
+ jwt_oidc
+ session
+ anonymous_fallback]
+end
+
+Rails.application.configure do |app|
+ app.config.middleware.use OpenProject::Authentication::Manager, intercept_401: false # rubocop:disable Naming/VariableNumber
end
diff --git a/lib/api/root_api.rb b/lib/api/root_api.rb
index 01eca460c10..f24ed382a00 100644
--- a/lib/api/root_api.rb
+++ b/lib/api/root_api.rb
@@ -44,8 +44,6 @@ module API
content_type :json, "application/json; charset=utf-8"
- use OpenProject::Authentication::Manager
-
helpers API::Caching::Helpers
module Helpers
include ::API::Helpers::RaiseQueryErrors
diff --git a/lib/open_project/static_routing.rb b/lib_static/open_project/static_routing.rb
similarity index 100%
rename from lib/open_project/static_routing.rb
rename to lib_static/open_project/static_routing.rb
diff --git a/modules/bim/lib/open_project/bim/engine.rb b/modules/bim/lib/open_project/bim/engine.rb
index 53e9e5a3aff..d50855d6212 100644
--- a/modules/bim/lib/open_project/bim/engine.rb
+++ b/modules/bim/lib/open_project/bim/engine.rb
@@ -215,7 +215,9 @@ module OpenProject::Bim
config.to_prepare do
Doorkeeper.configuration.scopes.add(:bcf_v2_1)
+ end
+ config.before_initialize do
unless defined? OpenProject::Authentication::Scope::BCF_V2_1
OpenProject::Authentication::Scope::BCF_V2_1 = :bcf_v2_1
end