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

make sure limit_self_registration is included in saml provider hash

Markus Kahlf42fbc735a29
diff --git a/modules/auth_saml/app/contracts/saml/providers/base_contract.rb b/modules/auth_saml/app/contracts/saml/providers/base_contract.rb
index 3e2a24ac82f..2375f66cfb1 100644
--- a/modules/auth_saml/app/contracts/saml/providers/base_contract.rb
+++ b/modules/auth_saml/app/contracts/saml/providers/base_contract.rb
@@ -64,6 +64,8 @@ module Saml
attribute :authn_requests_signed
validate :valid_certificate_key_pair
+ attribute :limit_self_registration
+
%i[mapping_mail mapping_login mapping_firstname mapping_lastname].each do |attr|
attribute attr
validates_presence_of attr, if: -> { model.public_send(:"#{attr}_changed?") }
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 d6bfc89f6b5..5cbf13df8d5 100644
--- a/modules/auth_saml/app/models/saml/provider/hash_builder.rb
+++ b/modules/auth_saml/app/models/saml/provider/hash_builder.rb
@@ -72,6 +72,7 @@ module Saml
name_identifier_format:,
certificate:,
private_key:,
+ limit_self_registration:,
attribute_statements: formatted_attribute_statements,
request_attributes: formatted_request_attributes,
uid_attribute: mapping_uid.presence
diff --git a/modules/auth_saml/spec/factories/saml_provider_factory.rb b/modules/auth_saml/spec/factories/saml_provider_factory.rb
index a53c2c6857c..1862fd4adca 100644
--- a/modules/auth_saml/spec/factories/saml_provider_factory.rb
+++ b/modules/auth_saml/spec/factories/saml_provider_factory.rb
@@ -43,6 +43,8 @@ FactoryBot.define do
idp_sso_service_url { "https://example.com/sso" }
idp_slo_service_url { "https://example.com/slo" }
+ limit_self_registration { true }
+
mapping_login { Saml::Defaults::MAIL_MAPPING }
mapping_mail { Saml::Defaults::MAIL_MAPPING }
mapping_firstname { Saml::Defaults::FIRSTNAME_MAPPING }
diff --git a/modules/auth_saml/spec/lib/open_project/auth_saml_spec.rb b/modules/auth_saml/spec/lib/open_project/auth_saml_spec.rb
index 263cd698e03..baf4378b02e 100644
--- a/modules/auth_saml/spec/lib/open_project/auth_saml_spec.rb
+++ b/modules/auth_saml/spec/lib/open_project/auth_saml_spec.rb
@@ -15,6 +15,7 @@ RSpec.describe OpenProject::AuthSaml do
expect(subject[:assertion_consumer_service_url]).to eq "http://#{Setting.host_name}/auth/my-saml/callback"
expect(subject[:idp_sso_service_url]).to eq "https://example.com/sso"
expect(subject[:idp_slo_service_url]).to eq "https://example.com/slo"
+ expect(subject[:limit_self_registration]).to be true
attributes = subject[:attribute_statements]
expect(attributes[:email]).to eq Saml::Defaults::MAIL_MAPPING.split("\n")
diff --git a/modules/auth_saml/spec/requests/saml_provider_callback_spec.rb b/modules/auth_saml/spec/requests/saml_provider_callback_spec.rb
index 4069e63b822..eabbb252d35 100644
--- a/modules/auth_saml/spec/requests/saml_provider_callback_spec.rb
+++ b/modules/auth_saml/spec/requests/saml_provider_callback_spec.rb
@@ -42,7 +42,8 @@ RSpec.describe "SAML provider callback",
digest_method: "http://www.w3.org/2001/04/xmlenc#sha256",
sp_entity_id: "https://foobar.org",
idp_cert:,
- idp_cert_fingerprint:)
+ idp_cert_fingerprint:,
+ limit_self_registration: false)
end
let(:idp_cert) { nil }