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

Signatures

Oliver Güntherda7096a96055
diff --git a/modules/auth_saml/app/constants/saml/defaults.rb b/modules/auth_saml/app/constants/saml/defaults.rb
index f66dcadc793..493129d5652 100644
--- a/modules/auth_saml/app/constants/saml/defaults.rb
+++ b/modules/auth_saml/app/constants/saml/defaults.rb
@@ -32,6 +32,20 @@ module Saml
module Defaults
NAME_IDENTIFIER_FORMAT = "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
+ SIGNATURE_METHODS = {
+ "RSA SHA-1" => XMLSecurity::Document::RSA_SHA1,
+ "RSA SHA-256" => XMLSecurity::Document::RSA_SHA256,
+ "RSA SHA-384" => XMLSecurity::Document::RSA_SHA384,
+ "RSA SHA-512" => XMLSecurity::Document::RSA_SHA512
+ }.freeze
+
+ DIGEST_METHODS = {
+ "SHA-1" => XMLSecurity::Document::SHA1,
+ "SHA-256" => XMLSecurity::Document::SHA256,
+ "SHA-384" => XMLSecurity::Document::SHA384,
+ "SHA-512" => XMLSecurity::Document::SHA512
+ }.freeze
+
NAME_IDENTIFIER_FORMATS = %w[
urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress
urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified
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 b3c6edd4180..5ac5ab61f7b 100644
--- a/modules/auth_saml/app/contracts/saml/providers/base_contract.rb
+++ b/modules/auth_saml/app/contracts/saml/providers/base_contract.rb
@@ -100,6 +100,8 @@ module Saml
cert = valid_certificate
key = valid_sp_key
+ return unless errors.empty?
+
unless cert.public_key.public_to_pem == key.public_key.public_to_pem
errors.add :private_key, :unmatched_private_key
end
diff --git a/modules/auth_saml/app/forms/saml/providers/encryption_form.rb b/modules/auth_saml/app/forms/saml/providers/encryption_form.rb
index 88c0a2a5adf..d86698612c1 100644
--- a/modules/auth_saml/app/forms/saml/providers/encryption_form.rb
+++ b/modules/auth_saml/app/forms/saml/providers/encryption_form.rb
@@ -64,6 +64,26 @@ module Saml
required: false,
input_width: :large
)
+ f.select_list(
+ name: :digest_method,
+ label: I18n.t("activemodel.attributes.saml/provider.digest_method"),
+ input_width: :large,
+ caption: I18n.t("saml.instructions.digest_method", default_option: "SHA-1")
+ ) do |list|
+ Saml::Defaults::DIGEST_METHODS.each do |label, value|
+ list.option(label:, value:)
+ end
+ end
+ f.select_list(
+ name: :signature_method,
+ label: I18n.t("activemodel.attributes.saml/provider.signature_method"),
+ input_width: :large,
+ caption: I18n.t("saml.instructions.signature_method", default_option: "RSA SHA-1")
+ ) do |list|
+ Saml::Defaults::SIGNATURE_METHODS.each do |label, value|
+ list.option(label:, value:)
+ end
+ end
end
end
end
diff --git a/modules/auth_saml/app/models/saml/provider.rb b/modules/auth_saml/app/models/saml/provider.rb
index 0a2f74f0c89..2d64c587c7a 100644
--- a/modules/auth_saml/app/models/saml/provider.rb
+++ b/modules/auth_saml/app/models/saml/provider.rb
@@ -77,7 +77,7 @@ module Saml
assertion_consumer_service_url:,
check_idp_cert_expiration: true,
check_sp_cert_expiration: true,
- metadata_signed: true
+ metadata_signed: certificate.present? && private_key.present?
)
.symbolize_keys
end
diff --git a/modules/auth_saml/config/locales/en.yml b/modules/auth_saml/config/locales/en.yml
index 72816050ff1..88742931aa3 100644
--- a/modules/auth_saml/config/locales/en.yml
+++ b/modules/auth_saml/config/locales/en.yml
@@ -18,22 +18,16 @@ en:
want_assertions_encrypted: Require encrypted responses
certificate: Certificate used by OpenProject for SAML requests
private_key: Corresponding private key for OpenProject SAML requests
+ signature_method: Signature algorithm
+ digest_method: Digest algorithm
format: "Format"
activerecord:
errors:
models:
saml/provider:
- attributes:
- idp_cert:
- invalid_certificate: "The certificate provided for the identity provider is invalid: %{additional_message}"
- format: "%{message}"
- certificate:
- invalid_certificate: "The certificate is invalid: %{additional_message}"
- format: "%{message}"
- private_key:
- invalid_private_key: "The provided private key is invalid: %{additional_message}"
- unmatched_private_key: "The provided private key does not belong to the given certificate"
- format: "%{message}"
+ invalid_certificate: "is not a valid PEM-formatted certificate: %{additional_message}"
+ invalid_private_key: "is not a valid PEM-formatted private key: %{additional_message}"
+ unmatched_private_key: "does not belong to the given certificate"
saml:
menu_title: SAML providers
info:
@@ -146,3 +140,7 @@ en:
Enter the X509 PEM-formatted certificate used by OpenProject for signing SAML requests.
private_key: >
Enter the X509 PEM-formatted private key for the above certificate. This needs to be an RSA private key.
+ signature_method: >
+ Select the signature algorithm to use for the SAML request signature performed by OpenProject (Default: %{default_option}).
+ digest_method: >
+ Select the digest algorithm to use for the SAML request signature performed by OpenProject (Default: %{default_option}).