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

[#61178] Fix a few remote_identity related issues.

Pavel Balashou90f64cda7900
diff --git a/db/migrate/20250220123358_add_polymorphic_auth_source_and_integration_to_remote_identities.rb b/db/migrate/20250220123358_add_polymorphic_auth_source_and_integration_to_remote_identities.rb
index 5aaf92b226f..b8327af1467 100644
--- a/db/migrate/20250220123358_add_polymorphic_auth_source_and_integration_to_remote_identities.rb
+++ b/db/migrate/20250220123358_add_polymorphic_auth_source_and_integration_to_remote_identities.rb
@@ -34,7 +34,8 @@ class AddPolymorphicAuthSourceAndIntegrationToRemoteIdentities < ActiveRecord::M
rename_column :remote_identities, :oauth_client_id, :auth_source_id
add_column :remote_identities, :auth_source_type, :string
- remove_index :remote_identities, :auth_source_id, if_exists: true
+ remove_index :remote_identities, :auth_source_id
+ remove_index :remote_identities, %i[user_id auth_source_id]
add_index :remote_identities, %i[auth_source_type auth_source_id]
add_column :remote_identities, :integration_type, :string
@@ -65,6 +66,7 @@ class AddPolymorphicAuthSourceAndIntegrationToRemoteIdentities < ActiveRecord::M
rename_column :remote_identities, :auth_source_id, :oauth_client_id
add_foreign_key :remote_identities, :oauth_clients
add_index :remote_identities, :oauth_client_id
+ add_index :remote_identities, %i[user_id oauth_client_id], unique: true
remove_column :remote_identities, :auth_source_type
remove_column :remote_identities, :integration_id
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/util.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/util.rb
index 42dcbbe621d..af207745372 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/util.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/util.rb
@@ -66,6 +66,7 @@ module Storages
response.xml.xpath("//s:message").text
end
+ # rubocop:disable Metrics/AbcSize
def origin_user_id(caller:, storage:, auth_strategy:)
case auth_strategy.key
when :basic_auth
@@ -95,6 +96,7 @@ module Storages
"Cannot execute query without user context.")
end
end
+ # rubocop:enable Metrics/AbcSize
def error_data_from_response(caller:, response:)
payload = if response.respond_to?(:content_type)
diff --git a/modules/storages/app/services/storages/one_drive_managed_folder_sync_service.rb b/modules/storages/app/services/storages/one_drive_managed_folder_sync_service.rb
index c18b78362fa..4388d8f5eda 100644
--- a/modules/storages/app/services/storages/one_drive_managed_folder_sync_service.rb
+++ b/modules/storages/app/services/storages/one_drive_managed_folder_sync_service.rb
@@ -223,11 +223,11 @@ module Storages
end
def client_remote_identities_scope
- RemoteIdentity.includes(:user).where(integration: @storage, auth_source: @storage.oauth_client)
+ RemoteIdentity.includes(:user).where(integration: @storage)
end
def admin_remote_identities_scope
- RemoteIdentity.includes(:user).where(integration: @storage, auth_source: @storage.oauth_client, user: User.admin.active)
+ RemoteIdentity.includes(:user).where(integration: @storage, user: User.admin.active)
end
def root_folder = Peripherals::ParentFolder.new("/")