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

[#54032] added adapter for user related auth strategy picking

Eric Schubert3c1d27d1d2d1
diff --git a/modules/storages/app/common/storages/peripherals/nextcloud_registry.rb b/modules/storages/app/common/storages/peripherals/nextcloud_registry.rb
index 8e750cbb8be..b932a17a60b 100644
--- a/modules/storages/app/common/storages/peripherals/nextcloud_registry.rb
+++ b/modules/storages/app/common/storages/peripherals/nextcloud_registry.rb
@@ -64,6 +64,11 @@ module Storages
namespace("models") do
register(:managed_folder_identifier, ManagedFolderIdentifier::Nextcloud)
end
+
+ namespace("authentication") do
+ register(:userless, StorageInteraction::AuthenticationStrategies::NextcloudStrategies::UserLess)
+ register(:userbound, StorageInteraction::AuthenticationStrategies::NextcloudStrategies::UserBound)
+ end
end
end
end
diff --git a/modules/storages/app/common/storages/peripherals/one_drive_registry.rb b/modules/storages/app/common/storages/peripherals/one_drive_registry.rb
index fbf64bf41cf..525ee02279b 100644
--- a/modules/storages/app/common/storages/peripherals/one_drive_registry.rb
+++ b/modules/storages/app/common/storages/peripherals/one_drive_registry.rb
@@ -58,6 +58,11 @@ module Storages
namespace("models") do
register(:managed_folder_identifier, ManagedFolderIdentifier::OneDrive)
end
+
+ namespace("authentication") do
+ register(:userless, StorageInteraction::AuthenticationStrategies::OneDriveStrategies::UserLess)
+ register(:userbound, StorageInteraction::AuthenticationStrategies::OneDriveStrategies::UserBound)
+ end
end
end
end
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/authentication_strategies/nextcloud_strategies.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/authentication_strategies/nextcloud_strategies.rb
new file mode 100644
index 00000000000..7c59ad34f1e
--- /dev/null
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/authentication_strategies/nextcloud_strategies.rb
@@ -0,0 +1,49 @@
+# frozen_string_literal:true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2024 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+module Storages
+ module Peripherals
+ module StorageInteraction
+ module AuthenticationStrategies
+ module NextcloudStrategies
+ UserLess = -> do
+ ::Storages::Peripherals::StorageInteraction::AuthenticationStrategies::BasicAuth.strategy
+ end
+
+ UserBound = ->(user:) do
+ ::Storages::Peripherals::StorageInteraction::AuthenticationStrategies::OAuthUserToken
+ .strategy
+ .with_user(user)
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/authentication_strategies/o_auth_client_credentials.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/authentication_strategies/oauth_client_credentials.rb
similarity index 100%
rename from modules/storages/app/common/storages/peripherals/storage_interaction/authentication_strategies/o_auth_client_credentials.rb
rename to modules/storages/app/common/storages/peripherals/storage_interaction/authentication_strategies/oauth_client_credentials.rb
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/authentication_strategies/o_auth_configuration.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/authentication_strategies/oauth_configuration.rb
similarity index 100%
rename from modules/storages/app/common/storages/peripherals/storage_interaction/authentication_strategies/o_auth_configuration.rb
rename to modules/storages/app/common/storages/peripherals/storage_interaction/authentication_strategies/oauth_configuration.rb
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/authentication_strategies/o_auth_user_token.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/authentication_strategies/oauth_user_token.rb
similarity index 100%
rename from modules/storages/app/common/storages/peripherals/storage_interaction/authentication_strategies/o_auth_user_token.rb
rename to modules/storages/app/common/storages/peripherals/storage_interaction/authentication_strategies/oauth_user_token.rb
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/authentication_strategies/one_drive_strategies.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/authentication_strategies/one_drive_strategies.rb
new file mode 100644
index 00000000000..2bdb369cfee
--- /dev/null
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/authentication_strategies/one_drive_strategies.rb
@@ -0,0 +1,49 @@
+# frozen_string_literal:true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2024 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+module Storages
+ module Peripherals
+ module StorageInteraction
+ module AuthenticationStrategies
+ module OneDriveStrategies
+ UserLess = -> do
+ ::Storages::Peripherals::StorageInteraction::AuthenticationStrategies::OAuthClientCredentials.strategy
+ end
+
+ UserBound = ->(user:) do
+ ::Storages::Peripherals::StorageInteraction::AuthenticationStrategies::OAuthUserToken
+ .strategy
+ .with_user(user)
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/modules/storages/lib/api/v3/storage_files/storage_files_api.rb b/modules/storages/lib/api/v3/storage_files/storage_files_api.rb
index 3378e5e9f08..e4c78e8f684 100644
--- a/modules/storages/lib/api/v3/storage_files/storage_files_api.rb
+++ b/modules/storages/lib/api/v3/storage_files/storage_files_api.rb
@@ -61,9 +61,9 @@ module API::V3::StorageFiles
end
def auth_strategy
- Storages::Peripherals::StorageInteraction::AuthenticationStrategies::OAuthUserToken
- .strategy
- .with_user(current_user)
+ Storages::Peripherals::Registry
+ .resolve("#{@storage.short_provider_type}.authorization.userbound")
+ .call(user: current_user)
end
end