Skip to content

Commit 6fc2fcf

Browse files
Merge pull request #19017 from opf/global-warden
Make warden available across entire application
2 parents 25f61a6 + 7c97803 commit 6fc2fcf

File tree

4 files changed

+29
-25
lines changed

4 files changed

+29
-25
lines changed

config/initializers/warden.rb

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
1-
Rails.application.config.after_initialize do
2-
namespace = OpenProject::Authentication::Strategies::Warden
1+
# frozen_string_literal: true
32

4-
strategies = [
5-
[:basic_auth_failure, namespace::BasicAuthFailure, "Basic"],
6-
[:global_basic_auth, namespace::GlobalBasicAuth, "Basic"],
7-
[:user_basic_auth, namespace::UserBasicAuth, "Basic"],
8-
[:oauth, namespace::DoorkeeperOAuth, "Bearer"],
9-
[:anonymous_fallback, namespace::AnonymousFallback, "Basic"],
10-
[:jwt_oidc, namespace::JwtOidc, "Bearer"],
11-
[:session, namespace::Session, "Session"]
12-
]
3+
namespace = OpenProject::Authentication::Strategies::Warden
134

14-
strategies.each do |name, clazz, auth_scheme|
15-
OpenProject::Authentication.add_strategy(name, clazz, auth_scheme)
16-
end
5+
strategies = [
6+
[:basic_auth_failure, namespace::BasicAuthFailure, "Basic"],
7+
[:global_basic_auth, namespace::GlobalBasicAuth, "Basic"],
8+
[:user_basic_auth, namespace::UserBasicAuth, "Basic"],
9+
[:oauth, namespace::DoorkeeperOAuth, "Bearer"],
10+
[:anonymous_fallback, namespace::AnonymousFallback, "Basic"],
11+
[:jwt_oidc, namespace::JwtOidc, "Bearer"],
12+
[:session, namespace::Session, "Session"]
13+
]
1714

18-
OpenProject::Authentication.update_strategies(OpenProject::Authentication::Scope::API_V3, { store: false }) do |_|
19-
%i[global_basic_auth
20-
user_basic_auth
21-
basic_auth_failure
22-
oauth
23-
jwt_oidc
24-
session
25-
anonymous_fallback]
26-
end
15+
strategies.each do |name, clazz, auth_scheme|
16+
OpenProject::Authentication.add_strategy(name, clazz, auth_scheme)
17+
end
18+
19+
OpenProject::Authentication.update_strategies(OpenProject::Authentication::Scope::API_V3, { store: false }) do |_|
20+
%i[global_basic_auth
21+
user_basic_auth
22+
basic_auth_failure
23+
oauth
24+
jwt_oidc
25+
session
26+
anonymous_fallback]
27+
end
28+
29+
Rails.application.configure do |app|
30+
app.config.middleware.use OpenProject::Authentication::Manager, intercept_401: false # rubocop:disable Naming/VariableNumber
2731
end

lib/api/root_api.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ class RootAPI < Grape::API
4444

4545
content_type :json, "application/json; charset=utf-8"
4646

47-
use OpenProject::Authentication::Manager
48-
4947
helpers API::Caching::Helpers
5048
module Helpers
5149
include ::API::Helpers::RaiseQueryErrors

modules/bim/lib/open_project/bim/engine.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,9 @@ class Engine < ::Rails::Engine
215215

216216
config.to_prepare do
217217
Doorkeeper.configuration.scopes.add(:bcf_v2_1)
218+
end
218219

220+
config.before_initialize do
219221
unless defined? OpenProject::Authentication::Scope::BCF_V2_1
220222
OpenProject::Authentication::Scope::BCF_V2_1 = :bcf_v2_1
221223
end

0 commit comments

Comments
 (0)