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
[#54558] guard oauth configuration init for incomplete storages
Eric Schubert59a15e07dce2
diff --git a/modules/storages/app/common/storages/peripherals/oauth_configurations/configuration_interface.rb b/modules/storages/app/common/storages/peripherals/oauth_configurations/configuration_interface.rbindex faafbcdf59f..78d22ce075a 100644--- a/modules/storages/app/common/storages/peripherals/oauth_configurations/configuration_interface.rb+++ b/modules/storages/app/common/storages/peripherals/oauth_configurations/configuration_interface.rb@@ -39,7 +39,7 @@ module Storagesdef to_httpx_oauth_config = raise ::Storages::Errors::SubclassResponsibilitydef authorization_uri(state: nil)- basic_rack_oauth_client&.authorization_uri(scope:, state:)+ basic_rack_oauth_client.authorization_uri(scope:, state:)endendenddiff --git a/modules/storages/app/common/storages/peripherals/oauth_configurations/nextcloud_configuration.rb b/modules/storages/app/common/storages/peripherals/oauth_configurations/nextcloud_configuration.rbindex 5b0eb0250c0..191f49cdd47 100644--- a/modules/storages/app/common/storages/peripherals/oauth_configurations/nextcloud_configuration.rb+++ b/modules/storages/app/common/storages/peripherals/oauth_configurations/nextcloud_configuration.rb@@ -39,6 +39,9 @@ module Storages# rubocop:disable Lint/MissingSuperdef initialize(storage)@uri = storage.uri++ raise(ArgumentError, "Storage must have configured OAuth client credentials") if storage.oauth_client.blank?+@oauth_client = storage.oauth_client.freezeend@@ -62,8 +65,6 @@ module Storagesenddef basic_rack_oauth_client- return nil if @oauth_client.nil?-Rack::OAuth2::Client.new(identifier: @oauth_client.client_id,secret: @oauth_client.client_secret,diff --git a/modules/storages/app/common/storages/peripherals/oauth_configurations/one_drive_configuration.rb b/modules/storages/app/common/storages/peripherals/oauth_configurations/one_drive_configuration.rbindex ae650ba6a02..434525a10d5 100644--- a/modules/storages/app/common/storages/peripherals/oauth_configurations/one_drive_configuration.rb+++ b/modules/storages/app/common/storages/peripherals/oauth_configurations/one_drive_configuration.rb@@ -40,7 +40,13 @@ module Storagesdef initialize(storage)@storage = storage@uri = storage.uri- @oauth_client = storage.oauth_client++ raise(ArgumentError, "Storage must have configured OAuth client credentials") if storage.oauth_client.blank?++ @oauth_client = storage.oauth_client.freeze++ raise(ArgumentError, "Storage must have a configured tenant id") if storage.tenant_id.blank?+@oauth_uri = URI("https://login.microsoftonline.com/#{@storage.tenant_id}/oauth2/v2.0").normalizeend@@ -67,8 +73,6 @@ module Storagesenddef basic_rack_oauth_client- return nil if @oauth_client.nil?-Rack::OAuth2::Client.new(identifier: @oauth_client.client_id,redirect_uri: @oauth_client.redirect_uri,diff --git a/modules/storages/lib/api/v3/storages/storage_representer.rb b/modules/storages/lib/api/v3/storages/storage_representer.rbindex 24c95803d08..4dc51c9f8eb 100644--- a/modules/storages/lib/api/v3/storages/storage_representer.rb+++ b/modules/storages/lib/api/v3/storages/storage_representer.rb@@ -163,7 +163,7 @@ module API::V3::Storagesendlink :authorize do- next unless authorization_state == :failed_authorization+ next if hide_authorize_link?{ href: represented.oauth_configuration.authorization_uri, title: "Authorize" }end@@ -213,6 +213,10 @@ module API::V3::Storagescurrent_user.admin? && represented.provider_type_nextcloud?end+ def hide_authorize_link?+ represented.oauth_client.blank? || authorization_state != :failed_authorization+ end+def storage_projects(storage)storage.projects.merge(Project.allowed_to(current_user, :manage_file_links))end