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

Enabled logging into Azure for OneDrive from FilesTab

Andreas Pfohlebb13e7bf5dd
diff --git a/app/controllers/oauth_clients_controller.rb b/app/controllers/oauth_clients_controller.rb
index b7be42bcc58..5cccd073967 100644
--- a/app/controllers/oauth_clients_controller.rb
+++ b/app/controllers/oauth_clients_controller.rb
@@ -151,7 +151,7 @@ class OAuthClientsController < ApplicationController
def redirect_user_or_admin(redirect_uri = nil)
# This needs to be modified as soon as we support more integration types.
- if User.current.admin && redirect_uri && nextcloud?
+ if User.current.admin && redirect_uri && (nextcloud? || one_drive?)
yield
elsif redirect_uri
flash[:error] = [t(:'oauth_client.errors.oauth_issue_contact_admin')]
@@ -165,6 +165,10 @@ class OAuthClientsController < ApplicationController
@oauth_client&.integration&.provider_type == ::Storages::Storage::PROVIDER_TYPE_NEXTCLOUD
end
+ def one_drive?
+ @oauth_client&.integration&.provider_type == ::Storages::Storage::PROVIDER_TYPE_ONE_DRIVE
+ end
+
def get_redirect_uri
::OAuthClients::RedirectUriFromStateService
.new(state: @oauth_state, cookies:)
diff --git a/modules/storages/lib/api/v3/storages/storage_representer.rb b/modules/storages/lib/api/v3/storages/storage_representer.rb
index 486a19a6c94..111b8608868 100644
--- a/modules/storages/lib/api/v3/storages/storage_representer.rb
+++ b/modules/storages/lib/api/v3/storages/storage_representer.rb
@@ -178,12 +178,14 @@ module API::V3::Storages
end
associated_resource :oauth_application,
- skip_render: ->(*) { !current_user.admin? },
+ skip_render: ->(*) { !current_user.admin? || !represented.provider_type_nextcloud? },
getter: ->(*) {
+ next unless current_user.admin? && represented.provider_type_nextcloud?
+
::API::V3::OAuth::OAuthApplicationsRepresenter.create(represented.oauth_application, current_user:)
},
link: ->(*) {
- next unless current_user.admin?
+ next unless current_user.admin? && represented.provider_type_nextcloud?
{
href: api_v3_paths.oauth_application(represented.oauth_application.id),
diff --git a/modules/storages/lib/open_project/storages/append_storages_hosts_to_csp_hook.rb b/modules/storages/lib/open_project/storages/append_storages_hosts_to_csp_hook.rb
index 4e31a311e0c..9df8f5eebe2 100644
--- a/modules/storages/lib/open_project/storages/append_storages_hosts_to_csp_hook.rb
+++ b/modules/storages/lib/open_project/storages/append_storages_hosts_to_csp_hook.rb
@@ -46,9 +46,9 @@ class ::OpenProject::Storages::AppendStoragesHostsToCspHook < OpenProject::Hook:
controller = context[:controller]
active_nextcloud_storages_hosts = ::Storages::NextcloudStorage
- .where(id: ::Storages::ProjectStorage.select(:storage_id))
- .pluck(:host)
- .map(&method(:remove_uri_path))
+ .where(id: ::Storages::ProjectStorage.select(:storage_id))
+ .pluck(:host)
+ .map(&method(:remove_uri_path))
if active_nextcloud_storages_hosts.present?
controller.append_content_security_policy_directives(
@@ -60,9 +60,10 @@ class ::OpenProject::Storages::AppendStoragesHostsToCspHook < OpenProject::Hook:
project_id: Project.allowed_to(User.current, :manage_file_links)
).select(:storage_id)
storages_hosts = ::Storages::Storage
- .where(id: storage_ids)
- .pluck(:host)
- .map(&method(:remove_uri_path))
+ .where(id: storage_ids)
+ .where.not(host: nil)
+ .pluck(:host)
+ .map(&method(:remove_uri_path))
if storages_hosts.present?
# secure_headers gem provides this helper method to append to the current content security policy