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
Ensure to select auth strategy via storage registry
Jan Sandbrinkf71f0dd930e2
diff --git a/modules/storages/app/controllers/storages/project_storages_controller.rb b/modules/storages/app/controllers/storages/project_storages_controller.rbindex 70e53c650c3..9ea8acaef94 100644--- a/modules/storages/app/controllers/storages/project_storages_controller.rb+++ b/modules/storages/app/controllers/storages/project_storages_controller.rb@@ -71,9 +71,7 @@ class Storages::ProjectStoragesController < ApplicationControllerprivatedef auth_strategy- Storages::Peripherals::StorageInteraction::AuthenticationStrategies::OAuthUserToken- .strategy- .with_user(current_user)+ Storages::Peripherals::Registry.resolve("#{@storage}.authentication.user_bound").call(user: current_user, storage: @storage)enddef user_can_read_project_folderdiff --git a/modules/storages/app/models/storages/project_storage.rb b/modules/storages/app/models/storages/project_storage.rbindex 6d33c1b2942..f57f43fe9e8 100644--- a/modules/storages/app/models/storages/project_storage.rb+++ b/modules/storages/app/models/storages/project_storage.rb@@ -82,9 +82,7 @@ module Storagesenddef open(user)- auth_strategy = Peripherals::StorageInteraction::AuthenticationStrategies::OAuthUserToken- .strategy- .with_user(user)+ auth_strategy = Peripherals::Registry.resolve("#{storage}.authentication.user_bound").call(user:, storage:)if project_folder_not_accessible?(user)Peripherals::Registrydiff --git a/modules/storages/lib/api/v3/file_links/file_links_download_api.rb b/modules/storages/lib/api/v3/file_links/file_links_download_api.rbindex a269302ed78..788fbddd9f1 100644--- a/modules/storages/lib/api/v3/file_links/file_links_download_api.rb+++ b/modules/storages/lib/api/v3/file_links/file_links_download_api.rb@@ -34,16 +34,15 @@ class API::V3::FileLinks::FileLinksDownloadAPI < API::OpenProjectAPIhelpers dodef auth_strategy- Storages::Peripherals::StorageInteraction::AuthenticationStrategies::OAuthUserToken- .strategy- .with_user(User.current)+ storage = @file_link.storage+ Storages::Peripherals::Registry.resolve("#{storage}.authentication.user_bound").call(user: User.current, storage:)endendresources :download doget doStorages::Peripherals::Registry- .resolve("#{@file_link.storage.short_provider_type}.queries.download_link")+ .resolve("#{@file_link.storage}.queries.download_link").call(storage: @file_link.storage, auth_strategy:, file_link: @file_link).match(on_success: ->(url) dodiff --git a/modules/storages/lib/api/v3/file_links/file_links_open_api.rb b/modules/storages/lib/api/v3/file_links/file_links_open_api.rbindex 1980073a9ae..e7ab0bc4a86 100644--- a/modules/storages/lib/api/v3/file_links/file_links_open_api.rb+++ b/modules/storages/lib/api/v3/file_links/file_links_open_api.rb@@ -31,14 +31,17 @@ class API::V3::FileLinks::FileLinksOpenAPI < API::OpenProjectAPIusing Storages::Peripherals::ServiceResultRefinements+ helpers do+ def auth_strategy+ storage = @file_link.storage+ Storages::Peripherals::Registry.resolve("#{storage}.authentication.user_bound").call(user: current_user, storage:)+ end+ end+resources :open doget do- auth_strategy = Storages::Peripherals::StorageInteraction::AuthenticationStrategies::OAuthUserToken- .strategy- .with_user(current_user)-Storages::Peripherals::Registry- .resolve("#{@file_link.storage.short_provider_type}.queries.open_file_link")+ .resolve("#{@file_link.storage}.queries.open_file_link").call(storage: @file_link.storage,auth_strategy:,diff --git a/modules/storages/lib/api/v3/storages/storage_open_api.rb b/modules/storages/lib/api/v3/storages/storage_open_api.rbindex 937c33ba601..588f09bfe92 100644--- a/modules/storages/lib/api/v3/storages/storage_open_api.rb+++ b/modules/storages/lib/api/v3/storages/storage_open_api.rb@@ -33,12 +33,14 @@ class API::V3::Storages::StorageOpenAPI < API::OpenProjectAPIusing Storages::Peripherals::ServiceResultRefinements+ helpers do+ def auth_strategy+ Storages::Peripherals::Registry.resolve("#{@storage}.authentication.user_bound").call(user: current_user, storage: @storage)+ end+ end+resources :open doget do- auth_strategy = Storages::Peripherals::StorageInteraction::AuthenticationStrategies::OAuthUserToken- .strategy- .with_user(current_user)-Storages::Peripherals::Registry.resolve("#{@storage}.queries.open_storage").call(storage: @storage, auth_strategy:)