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
Cert parsing
Oliver Güntherff57c6add8b3
diff --git a/modules/auth_saml/app/contracts/saml/providers/base_contract.rb b/modules/auth_saml/app/contracts/saml/providers/base_contract.rbindex 9d097ec4f4b..2e1f0bc71c9 100644--- a/modules/auth_saml/app/contracts/saml/providers/base_contract.rb+++ b/modules/auth_saml/app/contracts/saml/providers/base_contract.rb@@ -51,10 +51,24 @@ module Samlurl: { schemes: %w[http https] },if: -> { model.idp_slo_service_url_changed? }+ attribute :idp_cert+ validates_presence_of :idp_cert,+ if: -> { model.idp_cert_changed? }+ validate :idp_cert_is_valid,+ if: -> { model.idp_cert_changed? }+%i[mapping_mail mapping_login mapping_firstname mapping_lastname].each do |attr|attribute attrvalidates_presence_of attrend++ def idp_cert_is_valid+ return if model.idp_cert.blank?++ OpenSSL::X509::Certificate.load(model.idp_cert)+ rescue OpenSSL::X509::CertificateError => e+ errors.add :idp_cert, :invalid_certificate, additional_message: e.message+ endendendenddiff --git a/modules/auth_saml/app/forms/saml/providers/configuration_form.rb b/modules/auth_saml/app/forms/saml/providers/configuration_form.rbindex 448028c4f92..da39f5cb98b 100644--- a/modules/auth_saml/app/forms/saml/providers/configuration_form.rb+++ b/modules/auth_saml/app/forms/saml/providers/configuration_form.rb@@ -56,7 +56,7 @@ module Samlrows: 10,label: I18n.t("activemodel.attributes.saml/provider.idp_cert"),caption: I18n.t("saml.instructions.idp_cert"),- required: false,+ required: true,input_width: :large)f.select_list(diff --git a/modules/auth_saml/app/services/saml/update_metadata_service.rb b/modules/auth_saml/app/services/saml/update_metadata_service.rbindex 8e8779d5ca7..a4416d11791 100644--- a/modules/auth_saml/app/services/saml/update_metadata_service.rb+++ b/modules/auth_saml/app/services/saml/update_metadata_service.rb@@ -37,7 +37,6 @@ module Samldef callupdated_metadata- updated_metadatarescue StandardError => eOpenProject.logger.error(e)ServiceResult.failure(message: I18n.t("saml.metadata_parser.error", error: e.class.name))@@ -51,7 +50,7 @@ module Samlelsif provider.metadata_xml.present?parse_xmlelse- {}+ ServiceResult.success(result: {})endenddiff --git a/modules/auth_saml/config/locales/en.yml b/modules/auth_saml/config/locales/en.ymlindex c94f7741fb0..a82e01b4b01 100644--- a/modules/auth_saml/config/locales/en.yml+++ b/modules/auth_saml/config/locales/en.yml@@ -19,6 +19,14 @@ en:sp_certificate: Certificate used by OpenProject for SAML requestssp_private_key: Corresponding private key for OpenProject SAML requestsformat: "Format"+ activerecord:+ errors:+ models:+ saml/provider:+ attributes:+ idp_cert:+ invalid_certificate: "The certificate for the identity provider is invalid: %{additional_message}"+ format: "%{message}"saml:menu_title: SAML providersinfo: