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

Move attributes to base contract

Oliver Güntherb6e2450c706d
diff --git a/modules/auth_saml/app/components/saml/providers/sections/mapping_form_component.html.erb b/modules/auth_saml/app/components/saml/providers/sections/mapping_form_component.html.erb
index b2a6258a191..6717765444a 100644
--- a/modules/auth_saml/app/components/saml/providers/sections/mapping_form_component.html.erb
+++ b/modules/auth_saml/app/components/saml/providers/sections/mapping_form_component.html.erb
@@ -1,7 +1,7 @@
<%=
primer_form_with(
model: provider,
- url: saml_provider_path(provider, state: :configuration),
+ url: saml_provider_path(provider, state: :mapping),
method: :put
) do |form|
flex_layout do |flex|
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 617876207b3..9d097ec4f4b 100644
--- a/modules/auth_saml/app/contracts/saml/providers/base_contract.rb
+++ b/modules/auth_saml/app/contracts/saml/providers/base_contract.rb
@@ -36,6 +36,25 @@ module Saml
attribute :display_name
attribute :options
+ attribute :metadata_url
+ validates :metadata_url,
+ url: { allow_blank: true, allow_nil: true, schemes: %w[http https] },
+ if: -> { model.metadata_url_changed? }
+
+ attribute :idp_sso_service_url
+ validates :idp_sso_service_url,
+ url: { schemes: %w[http https] },
+ if: -> { model.idp_sso_service_url_changed? }
+
+ attribute :idp_slo_service_url
+ validates :idp_slo_service_url,
+ url: { schemes: %w[http https] },
+ if: -> { model.idp_slo_service_url_changed? }
+
+ %i[mapping_mail mapping_login mapping_firstname mapping_lastname].each do |attr|
+ attribute attr
+ validates_presence_of attr
+ end
end
end
end
diff --git a/modules/auth_saml/app/contracts/saml/providers/update_contract.rb b/modules/auth_saml/app/contracts/saml/providers/update_contract.rb
index 8d32027998b..44a17f81fea 100644
--- a/modules/auth_saml/app/contracts/saml/providers/update_contract.rb
+++ b/modules/auth_saml/app/contracts/saml/providers/update_contract.rb
@@ -29,25 +29,6 @@
module Saml
module Providers
class UpdateContract < BaseContract
- attribute :metadata_url
- validates :metadata_url,
- url: { allow_blank: true, allow_nil: true, schemes: %w[http https] },
- if: -> { model.metadata_url_changed? }
-
- attribute :idp_sso_service_url
- validates :idp_sso_service_url,
- url: { schemes: %w[http https] },
- if: -> { model.idp_sso_service_url_changed? }
-
- attribute :idp_slo_service_url
- validates :idp_slo_service_url,
- url: { schemes: %w[http https] },
- if: -> { model.idp_slo_service_url_changed? }
-
- %i[mapping_mail mapping_login mapping_firstname mapping_lastname].each do |attr|
- attribute attr
- validates_presence_of attr
- end
end
end
end
diff --git a/modules/auth_saml/app/controllers/saml/providers_controller.rb b/modules/auth_saml/app/controllers/saml/providers_controller.rb
index dbeeaf9a95e..575cec37668 100644
--- a/modules/auth_saml/app/controllers/saml/providers_controller.rb
+++ b/modules/auth_saml/app/controllers/saml/providers_controller.rb
@@ -155,7 +155,8 @@ module Saml
params
.require(:saml_provider)
.permit(:display_name, :sp_entity_id, :idp_sso_service_url, :idp_slo_service_url, :idp_cert,
- :name_identifier_format, :limit_self_registration)
+ :name_identifier_format, :limit_self_registration,
+ :mapping_login, :mapping_mail, :mapping_firstname, :mapping_lastname, :mapping_uid)
end
def find_provider