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
Migrate SAML entries with an empty contract, ignoring errors
Oliver Günther3532d8e1d806
diff --git a/modules/auth_saml/app/services/saml/sync_service.rb b/modules/auth_saml/app/services/saml/sync_service.rbindex ed7217fb8d6..e6af871783b 100644--- a/modules/auth_saml/app/services/saml/sync_service.rb+++ b/modules/auth_saml/app/services/saml/sync_service.rb@@ -30,11 +30,12 @@ module Saml### Synchronize a configuration from ENV or legacy settings to a SAML provider recordclass SyncService- attr_reader :name, :configuration+ attr_reader :name, :configuration, :contract_class- def initialize(name, configuration)+ def initialize(name, configuration, contract_class: nil)@name = name@configuration = configuration+ @contract_class = contract_classenddef call@@ -52,7 +53,7 @@ module Samldef create(name, params)::Saml::Providers::CreateService- .new(user: User.system)+ .new(user: User.system, contract_class:).call(params).on_success { |call| call.message = "Successfully saved SAML provider #{name}." }.on_failure { |call| call.message = "Failed to create SAML provider: #{call.message}" }@@ -60,7 +61,7 @@ module Samldef update(name, provider, params)::Saml::Providers::UpdateService- .new(model: provider, user: User.system)+ .new(model: provider, user: User.system, contract_class:).call(params).on_success { |call| call.message = "Successfully updated SAML provider #{name}." }.on_failure { |call| call.message = "Failed to update SAML provider: #{call.message}" }diff --git a/modules/auth_saml/db/migrate/20240821121856_migrate_saml_settings_to_providers.rb b/modules/auth_saml/db/migrate/20240821121856_migrate_saml_settings_to_providers.rbindex 0510f6c8cba..6fa104cad07 100644--- a/modules/auth_saml/db/migrate/20240821121856_migrate_saml_settings_to_providers.rb+++ b/modules/auth_saml/db/migrate/20240821121856_migrate_saml_settings_to_providers.rb@@ -20,7 +20,7 @@ class MigrateSamlSettingsToProviders < ActiveRecord::Migration[7.1]def migrate_provider!(name, options)puts "Trying to migrate SAML provider #{name} from previous settings format..."- call = ::Saml::SyncService.new(name, options).call+ call = ::Saml::SyncService.new(name, options, contract_class: EmptyContract).callif call.successputs <<~SUCCESS