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

Ensure empty uid_attribute is not output

Oliver Güntherec6f8a71cada
diff --git a/modules/auth_saml/app/models/saml/provider/hash_builder.rb b/modules/auth_saml/app/models/saml/provider/hash_builder.rb
index 926bdcee4ee..d6bfc89f6b5 100644
--- a/modules/auth_saml/app/models/saml/provider/hash_builder.rb
+++ b/modules/auth_saml/app/models/saml/provider/hash_builder.rb
@@ -74,7 +74,7 @@ module Saml
private_key:,
attribute_statements: formatted_attribute_statements,
request_attributes: formatted_request_attributes,
- uid_attribute: mapping_uid
+ uid_attribute: mapping_uid.presence
}
.merge(idp_cert_options_hash)
.merge(security: security_options_hash)
diff --git a/modules/auth_saml/spec/models/saml/provider_spec.rb b/modules/auth_saml/spec/models/saml/provider_spec.rb
index c2fee27da4d..171a0854e98 100644
--- a/modules/auth_saml/spec/models/saml/provider_spec.rb
+++ b/modules/auth_saml/spec/models/saml/provider_spec.rb
@@ -293,4 +293,18 @@ RSpec.describe Saml::Provider do
expect(Setting.omniauth_direct_login_provider).to be_blank
end
end
+
+ describe "#to_h" do
+ let(:provider) { create(:saml_provider) }
+
+ context "when uid_mapping is an empty string" do
+ before do
+ provider.mapping_uid = ""
+ end
+
+ it "does not output it (Regression #58592)" do
+ expect(provider.to_h).not_to include(:uid_attribute)
+ end
+ end
+ end
end