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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[#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.rbindex 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 Storagesnamespace("models") doregister(:managed_folder_identifier, ManagedFolderIdentifier::Nextcloud)end++ namespace("authentication") do+ register(:userless, StorageInteraction::AuthenticationStrategies::NextcloudStrategies::UserLess)+ register(:userbound, StorageInteraction::AuthenticationStrategies::NextcloudStrategies::UserBound)+ endendendenddiff --git a/modules/storages/app/common/storages/peripherals/one_drive_registry.rb b/modules/storages/app/common/storages/peripherals/one_drive_registry.rbindex 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 Storagesnamespace("models") doregister(:managed_folder_identifier, ManagedFolderIdentifier::OneDrive)end++ namespace("authentication") do+ register(:userless, StorageInteraction::AuthenticationStrategies::OneDriveStrategies::UserLess)+ register(:userbound, StorageInteraction::AuthenticationStrategies::OneDriveStrategies::UserBound)+ endendendenddiff --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.rbnew file mode 100644index 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+enddiff --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.rbsimilarity index 100%rename from modules/storages/app/common/storages/peripherals/storage_interaction/authentication_strategies/o_auth_client_credentials.rbrename to modules/storages/app/common/storages/peripherals/storage_interaction/authentication_strategies/oauth_client_credentials.rbdiff --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.rbsimilarity index 100%rename from modules/storages/app/common/storages/peripherals/storage_interaction/authentication_strategies/o_auth_configuration.rbrename to modules/storages/app/common/storages/peripherals/storage_interaction/authentication_strategies/oauth_configuration.rbdiff --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.rbsimilarity index 100%rename from modules/storages/app/common/storages/peripherals/storage_interaction/authentication_strategies/o_auth_user_token.rbrename to modules/storages/app/common/storages/peripherals/storage_interaction/authentication_strategies/oauth_user_token.rbdiff --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.rbnew file mode 100644index 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+enddiff --git a/modules/storages/lib/api/v3/storage_files/storage_files_api.rb b/modules/storages/lib/api/v3/storage_files/storage_files_api.rbindex 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::StorageFilesenddef 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)endend