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

Use not configured for metadata

Oliver Günther68422d4e6075
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 557d5041956..075ba237f51 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -2392,6 +2392,7 @@ en:
label_no_parent_page: "No parent page"
label_nothing_display: "Nothing to display"
label_nobody: "nobody"
+ label_not_configured: "Not configured"
label_not_found: "not found"
label_none: "none"
label_none_parentheses: "(none)"
diff --git a/frontend/src/stimulus/controllers/dynamic/admin/saml.controller.ts b/frontend/src/stimulus/controllers/dynamic/admin/saml.controller.ts
deleted file mode 100644
index 4286e476515..00000000000
--- a/frontend/src/stimulus/controllers/dynamic/admin/saml.controller.ts
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * -- copyright
- * OpenProject is an open source project management software.
- * Copyright (C) 2023 the OpenProject GmbH
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License version 3.
- *
- * OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
- * Copyright (C) 2006-2013 Jean-Philippe Lang
- * Copyright (C) 2010-2013 the ChiliProject Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * See COPYRIGHT and LICENSE files for more details.
- * ++
- */
-
-import { Controller } from '@hotwired/stimulus';
-
-export default class CustomFieldsController extends Controller {
- static targets = [
- 'format',
- 'dragContainer',
-
- 'customOptionDefaults',
- 'customOptionRow',
-
- 'allowNonOpenVersions',
- 'defaultBool',
- 'defaultLongText',
- 'defaultText',
- 'length',
- 'multiSelect',
- 'possibleValues',
- 'regexp',
- 'searchable',
- 'textOrientation',
- ];
-
- static values = {
- formatConfig: Array,
- };
-
- declare readonly formatConfigValue:[string, string, string[]][];
-
- declare readonly formatTarget:HTMLInputElement;
- declare readonly dragContainerTarget:HTMLElement;
- declare readonly hasDragContainerTarget:boolean;
-
- declare readonly customOptionDefaultsTargets:HTMLInputElement[];
- declare readonly customOptionRowTargets:HTMLTableRowElement[];
-
- declare readonly allowNonOpenVersionsTargets:HTMLElement[];
- declare readonly defaultBoolTargets:HTMLElement[];
- declare readonly defaultLongTextTargets:HTMLElement[];
- declare readonly defaultTextTargets:HTMLElement[];
- declare readonly lengthTargets:HTMLElement[];
- declare readonly multiSelectTargets:HTMLElement[];
- declare readonly possibleValuesTargets:HTMLElement[];
- declare readonly regexpTargets:HTMLElement[];
- declare readonly searchableTargets:HTMLInputElement[];
- declare readonly textOrientationTargets:HTMLElement[];
-
- connect() {
- if (this.hasDragContainerTarget) {
- this.setupDragAndDrop();
- }
-
- this.formatChanged();
- }
-
- formatChanged() {
- this.toggleFormat(this.formatTarget.value);
- }
-
- moveRowUp(event:{ target:HTMLElement }) {
- const row = event.target.closest('tr') as HTMLTableRowElement;
- const idx = this.customOptionRowTargets.indexOf(row);
- if (idx > 0) {
- this.customOptionRowTargets[idx - 1].before(row);
- }
-
- return false;
- }
-
- moveRowDown(event:{ target:HTMLElement }) {
- const row = event.target.closest('tr') as HTMLTableRowElement;
- const idx = this.customOptionRowTargets.indexOf(row);
- if (idx < this.customOptionRowTargets.length - 1) {
- this.customOptionRowTargets[idx + 1].after(row);
- }
-
- return false;
- }
-
- moveRowToTheTop(event:{ target:HTMLElement }) {
- const row = event.target.closest('tr') as HTMLTableRowElement;
- const first = this.customOptionRowTargets[0];
-
- if (first && first !== row) {
- first.before(row);
- }
-
- return false;
- }
-
- moveRowToTheBottom(event:{ target:HTMLElement }) {
- const row = event.target.closest('tr') as HTMLTableRowElement;
- const last = this.customOptionRowTargets[this.customOptionRowTargets.length - 1];
-
- if (last && last !== row) {
- last.after(row);
- }
-
- return false;
- }
-
- removeOption(event:MouseEvent) {
- const self = event.target as HTMLAnchorElement;
- if (self.href === '#' || self.href.endsWith('/0')) {
- const row = self.closest('tr');
-
- if (row && this.customOptionRowTargets.length > 1) {
- row.remove();
- }
-
- event.preventDefault();
- event.stopImmediatePropagation();
- }
- return true; // send off deletion
- }
-
- addOption() {
- const count = this.customOptionRowTargets.length;
- const last = this.customOptionRowTargets[count - 1];
- const dup = last.cloneNode(true) as HTMLElement;
-
- const input = dup.querySelector('.custom-option-value input') as HTMLInputElement;
-
- input.setAttribute('name', `custom_field[custom_options_attributes][${count}][value]`);
- input.setAttribute('id', `custom_field_custom_options_attributes_${count}_value`);
- input.value = '';
-
- dup
- .querySelector('.custom-option-id')
- ?.remove();
-
- const defaultValueCheckbox = dup.querySelector('input[type="checkbox"]') as HTMLInputElement;
- const defaultValueHidden = dup.querySelector('input[type="hidden"]') as HTMLInputElement;
-
- defaultValueHidden.setAttribute('name', `custom_field[custom_options_attributes][${count}][default_value]`);
- defaultValueHidden.removeAttribute('id');
- defaultValueCheckbox.setAttribute('name', `custom_field[custom_options_attributes][${count}][default_value]`);
- defaultValueCheckbox.setAttribute('id', `custom_field_custom_options_attributes_${count}_default_value`);
- defaultValueCheckbox.checked = false;
-
- last.insertAdjacentElement('afterend', dup);
-
- return false;
- }
-
- uncheckOtherDefaults(event:{ target:HTMLElement }) {
- const cb = event.target as HTMLInputElement;
-
- if (cb.checked) {
- const multi = this.multiSelectTargets[0] as HTMLInputElement|undefined;
-
- if (multi?.checked === false) {
- this.customOptionDefaultsTargets.forEach((el) => (el.checked = false));
- cb.checked = true;
- }
- }
- }
-
- checkOnlyOne(event:{ target:HTMLElement }) {
- const cb = event.target as HTMLInputElement;
-
- if (!cb.checked) {
- this.customOptionDefaultsTargets
- .filter((el) => el.checked)
- .slice(1)
- .forEach((el) => (el.checked = false));
- }
- }
-
- private setupDragAndDrop() {
- // Make custom fields draggable
- // eslint-disable-next-line no-undef
- const drake = dragula([this.dragContainerTarget], {
- isContainer: () => false,
- moves: (el, source, handle:HTMLElement) => handle.classList.contains('dragula-handle'),
- accepts: () => true,
- invalid: () => false,
- direction: 'vertical',
- copy: false,
- copySortSource: false,
- revertOnSpill: true,
- removeOnSpill: false,
- mirrorContainer: this.dragContainerTarget,
- ignoreInputTextSelection: true,
- });
-
- // Setup autoscroll
- void window.OpenProject.getPluginContext().then((pluginContext) => {
- // eslint-disable-next-line no-new
- new pluginContext.classes.DomAutoscrollService(
- [
- document.getElementById('content-body') as HTMLElement,
- ],
- {
- margin: 25,
- maxSpeed: 10,
- scrollWhenOutside: true,
- autoScroll: () => drake.dragging,
- },
- );
- });
- }
-
- private setActive(elements:HTMLElement[], active:boolean) {
- elements.forEach((element) => {
- element.hidden = !active;
- element
- .querySelectorAll<HTMLInputElement>('input, textarea')
- .forEach((input) => {
- input.disabled = !active;
- });
- });
- }
-
- private toggleFormat(format:string) {
- this.formatConfigValue.forEach(([targetsName, operator, formats]) => {
- const active = operator === 'only' ? formats.includes(format) : !formats.includes(format);
- const targets = this[`${targetsName}Targets` as keyof typeof this] as HTMLElement[];
- if (targets) {
- this.setActive(targets, active);
- }
- });
- }
-}
diff --git a/modules/auth_saml/app/components/saml/providers/sections/configuration_component.html.erb b/modules/auth_saml/app/components/saml/providers/sections/configuration_component.html.erb
index 2ccdef7b008..a7f66752e9e 100644
--- a/modules/auth_saml/app/components/saml/providers/sections/configuration_component.html.erb
+++ b/modules/auth_saml/app/components/saml/providers/sections/configuration_component.html.erb
@@ -1,32 +1,34 @@
<%=
grid_layout('op-saml-view-row', tag: :div, align_items: :center) do |grid|
grid.with_area(:title, mr: 3) do
- concat render(Primer::Beta::Text.new(font_weight: :bold)) { t("saml.providers.section_headers.configuration") }
+ concat render(Primer::Beta::Text.new(font_weight: :bold)) { t("saml.providers.label_configuration_details") }
if provider.configured?
concat render(Primer::Beta::Label.new(scheme: :success, ml: 1)) { t(:label_completed) }
- else
+ elsif provider.persisted?
concat render(Primer::Beta::Label.new(scheme: :attention, ml: 1)) { t(:label_incomplete) }
end
end
grid.with_area(:description) do
render(Primer::Beta::Text.new(tag: :p, font_size: :small, color: :subtle)) do
- t("saml.providers.section_texts.configuration")
+ t("saml.providers.section_texts.label_configuration_details")
end
end
- grid.with_area(:action) do
- flex_layout(justify_content: :flex_end) do |icons_container|
- icons_container.with_column do
- render(
- Primer::Beta::IconButton.new(
- icon: :pencil,
- tag: :a,
- scheme: :invisible,
- href: edit_saml_provider_path(provider, edit_state: :configuration),
- aria: { label: I18n.t(:label_edit) }
+ if provider.persisted?
+ grid.with_area(:action) do
+ flex_layout(justify_content: :flex_end) do |icons_container|
+ icons_container.with_column do
+ render(
+ Primer::Beta::IconButton.new(
+ icon: :pencil,
+ tag: :a,
+ scheme: :invisible,
+ href: edit_saml_provider_path(provider, edit_state: :configuration),
+ aria: { label: I18n.t(:label_edit) }
+ )
)
- )
+ end
end
end
end
diff --git a/modules/auth_saml/app/components/saml/providers/sections/configuration_form_component.html.erb b/modules/auth_saml/app/components/saml/providers/sections/configuration_form_component.html.erb
index 09b26b4060e..e31e20b07a2 100644
--- a/modules/auth_saml/app/components/saml/providers/sections/configuration_form_component.html.erb
+++ b/modules/auth_saml/app/components/saml/providers/sections/configuration_form_component.html.erb
@@ -1,11 +1,8 @@
<%=
primer_form_with(
model: provider,
- url: import_metadata_saml_provider_path(provider),
- data: {
- controller: "show-when-checked"
- },
- method: :post,
+ url: saml_provider_path(provider, state: :configuration),
+ method: :put
) do |form|
flex_layout do |flex|
flex.with_row do
@@ -15,21 +12,12 @@
end
flex.with_row do
- render(Saml::Providers::MetadataCheckboxForm.new(form, provider:))
- end
-
- flex.with_row(mt: 2, hidden: !provider.has_metadata?, data: { 'show-when-checked-target': "effect" }) do
- render(Saml::Providers::MetadataUrlForm.new(form))
- end
-
- flex.with_row(mt: 2, hidden: !provider.has_metadata?, data: { 'show-when-checked-target': "effect" }) do
- render(Saml::Providers::MetadataXmlForm.new(form))
+ render(Saml::Providers::ConfigurationForm.new(form, provider:))
end
flex.with_row(mt: 4) do
render(Saml::Providers::SubmitOrCancelForm.new(form,
- provider:,
- state: :metadata))
+ provider:))
end
end
end
diff --git a/modules/auth_saml/app/components/saml/providers/sections/metadata_component.html.erb b/modules/auth_saml/app/components/saml/providers/sections/metadata_component.html.erb
index 48b387774e1..61ac7fb6f06 100644
--- a/modules/auth_saml/app/components/saml/providers/sections/metadata_component.html.erb
+++ b/modules/auth_saml/app/components/saml/providers/sections/metadata_component.html.erb
@@ -4,8 +4,8 @@
concat render(Primer::Beta::Text.new(font_weight: :bold)) { t("saml.providers.label_metadata") }
if provider.has_metadata?
concat render(Primer::Beta::Label.new(scheme: :success, ml: 1)) { t(:label_completed) }
- else
- concat render(Primer::Beta::Label.new(scheme: :secondary, ml: 1)) { t(:label_incomplete) }
+ elsif provider.persisted?
+ concat render(Primer::Beta::Label.new(scheme: :secondary, ml: 1)) { t(:label_not_configured) }
end
end
@@ -15,18 +15,20 @@
end
end
- grid.with_area(:action) do
- flex_layout(justify_content: :flex_end) do |icons_container|
- icons_container.with_column do
- render(
- Primer::Beta::IconButton.new(
- icon: :pencil,
- tag: :a,
- scheme: :invisible,
- href: edit_saml_provider_path(provider, edit_state: :metadata),
- aria: { label: I18n.t(:label_edit) }
+ if provider.persisted?
+ grid.with_area(:action) do
+ flex_layout(justify_content: :flex_end) do |icons_container|
+ icons_container.with_column do
+ render(
+ Primer::Beta::IconButton.new(
+ icon: :pencil,
+ tag: :a,
+ scheme: :invisible,
+ href: edit_saml_provider_path(provider, edit_state: :metadata),
+ aria: { label: I18n.t(:label_edit) }
+ )
)
- )
+ end
end
end
end
diff --git a/modules/auth_saml/app/components/saml/providers/view_component.html.erb b/modules/auth_saml/app/components/saml/providers/view_component.html.erb
index 32e51ae50ee..ac1ee941d60 100644
--- a/modules/auth_saml/app/components/saml/providers/view_component.html.erb
+++ b/modules/auth_saml/app/components/saml/providers/view_component.html.erb
@@ -24,6 +24,10 @@
end
end
+ component.with_row(scheme: :neutral, color: :muted) do
+ render(Primer::Beta::Text.new(font_weight: :semibold)) { I18n.t('saml.providers.section_headers.configuration') }
+ end
+
component.with_row(scheme: :default) do
if edit_state == :configuration
render(Saml::Providers::Sections::ConfigurationFormComponent.new(provider))
diff --git a/modules/auth_saml/app/constants/saml/defaults.rb b/modules/auth_saml/app/constants/saml/defaults.rb
index c6e930816af..b6bd3eb35ff 100644
--- a/modules/auth_saml/app/constants/saml/defaults.rb
+++ b/modules/auth_saml/app/constants/saml/defaults.rb
@@ -30,15 +30,23 @@
module Saml
module Defaults
- NAME_IDENTIFIER_FORMAT = 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress'.freeze
+ NAME_IDENTIFIER_FORMAT = "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
+
+ NAME_IDENTIFIER_FORMATS = [
+ "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress",
+ "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified",
+ "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent",
+ "urn:oasis:names:tc:SAML:2.0:nameid-format:transient"
+ ]
+
MAIL_MAPPING = %w[mail email Email emailAddress emailaddress
- urn:oid:0.9.2342.19200300.100.1.3 http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress].freeze
+ urn:oid:0.9.2342.19200300.100.1.3 http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress].freeze
FIRSTNAME_MAPPING = %w[givenName givenname given_name given_name
- urn:oid:2.5.4.42 http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname].freeze
+ urn:oid:2.5.4.42 http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname].freeze
LASTNAME_MAPPING = %w[surname sur_name sn
- urn:oid:2.5.4.4 http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname].freeze
+ urn:oid:2.5.4.4 http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname].freeze
REQUESTED_ATTRIBUTES = [
{
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 17ade1f291f..b86e86c0b2a 100644
--- a/modules/auth_saml/app/contracts/saml/providers/update_contract.rb
+++ b/modules/auth_saml/app/contracts/saml/providers/update_contract.rb
@@ -31,7 +31,18 @@ module Saml
class UpdateContract < BaseContract
attribute :metadata_url
validates :metadata_url,
- url: { allow_blank: true, allow_nil: true, schemes: %w[http https] }
+ 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? }
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 7cde74aade1..dbeeaf9a95e 100644
--- a/modules/auth_saml/app/controllers/saml/providers_controller.rb
+++ b/modules/auth_saml/app/controllers/saml/providers_controller.rb
@@ -36,7 +36,7 @@ module Saml
if call.success?
flash[:notice] = I18n.t(:notice_successful_create)
- redirect_to saml_provider_path(call.result)
+ redirect_to edit_saml_provider_path(call.result, edit_state: :metadata)
else
@provider = call.result
render action: :new
@@ -44,13 +44,16 @@ module Saml
end
def update
- @provider = ::Saml::Provider.initialize_with(
- update_params.merge("name" => params[:id])
- )
- if @provider.save
+ call = Saml::Providers::UpdateService
+ .new(model: @provider, user: User.current)
+ .call(update_params)
+
+ if call.success?
flash[:notice] = I18n.t(:notice_successful_update)
- success_redirect
+ redirect_to saml_provider_path(call.result)
else
+ @provider = call.result
+ @edit_state = params[:state].to_sym
render action: :edit
end
end
@@ -58,6 +61,7 @@ module Saml
def destroy
call = ::Saml::Providers::DeleteService
.new(model: @provider, user: User.current)
+ .call
if call.success?
flash[:notice] = I18n.t(:notice_successful_delete)
@@ -121,9 +125,10 @@ module Saml
end
def apply_metadata(params)
+ new_options = @provider.options.merge(params.compact_blank)
call = Saml::Providers::UpdateService
.new(model: @provider, user: User.current)
- .call({ options: params})
+ .call({ options: new_options })
if call.success?
flash[:notice] = I18n.t("saml.metadata_parser.success")
@@ -147,7 +152,10 @@ module Saml
end
def update_params
- params.require(:saml_provider).permit(:display_name, :identifier, :secret, :limit_self_registration)
+ 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)
end
def find_provider
diff --git a/modules/auth_saml/app/forms/saml/providers/configuration_form.rb b/modules/auth_saml/app/forms/saml/providers/configuration_form.rb
new file mode 100644
index 00000000000..eeac93067e3
--- /dev/null
+++ b/modules/auth_saml/app/forms/saml/providers/configuration_form.rb
@@ -0,0 +1,87 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2024 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+module Saml
+ module Providers
+ class ConfigurationForm < ApplicationForm
+ form do |f|
+ f.text_field(
+ name: :sp_entity_id,
+ label: I18n.t("activemodel.attributes.saml/provider.sp_entity_id"),
+ caption: I18n.t("saml.instructions.sp_entity_id"),
+ required: true,
+ input_width: :large
+ )
+ f.text_field(
+ name: :idp_sso_service_url,
+ label: I18n.t("activemodel.attributes.saml/provider.idp_sso_service_url"),
+ caption: I18n.t("saml.instructions.idp_sso_service_url"),
+ required: true,
+ input_width: :large
+ )
+ f.text_field(
+ name: :idp_slo_service_url,
+ label: I18n.t("activemodel.attributes.saml/provider.idp_slo_service_url"),
+ caption: I18n.t("saml.instructions.idp_slo_service_url"),
+ required: false,
+ input_width: :large
+ )
+ f.text_area(
+ name: :idp_cert,
+ rows: 10,
+ label: I18n.t("activemodel.attributes.saml/provider.idp_cert"),
+ caption: I18n.t("saml.instructions.idp_cert"),
+ required: false,
+ input_width: :large
+ )
+ f.select_list(
+ name: "name_identifier_format",
+ label: I18n.t("activemodel.attributes.saml/provider.name_identifier_format"),
+ input_width: :large,
+ caption: I18n.t("saml.instructions.name_identifier_format")
+ ) do |list|
+ Saml::Defaults::NAME_IDENTIFIER_FORMATS.each do |format|
+ list.option(label: format, value: format)
+ end
+ end
+ f.check_box(
+ name: :limit_self_registration,
+ label: I18n.t("activemodel.attributes.saml/provider.limit_self_registration"),
+ caption: I18n.t("saml.instructions.limit_self_registration"),
+ required: false,
+ input_width: :large
+ )
+ end
+
+ def initialize(provider:)
+ super()
+ @provider = provider
+ 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 5681a963e5e..82c629915f3 100644
--- a/modules/auth_saml/app/models/saml/provider.rb
+++ b/modules/auth_saml/app/models/saml/provider.rb
@@ -26,9 +26,10 @@ module Saml
attr_accessor :readonly
validates_presence_of :display_name
+ validates_uniqueness_of :display_name
def slug
- "saml-#{id}"
+ options.fetch(:name) { "saml-#{id}" }
end
def limit_self_registration?
@@ -40,11 +41,11 @@ module Saml
end
def configured?
- idp_sso_service_url.present? && certificate_configured?
+ sp_entity_id.present? && idp_sso_service_url.present? && certificate_configured?
end
def certificate_configured?
- idp_cert.present? || idp_cert_fingerprint.present?
+ idp_cert.present?
end
def to_h
diff --git a/modules/auth_saml/app/services/saml/providers/set_attributes_service.rb b/modules/auth_saml/app/services/saml/providers/set_attributes_service.rb
index 3ecb58d06df..d6703bee347 100644
--- a/modules/auth_saml/app/services/saml/providers/set_attributes_service.rb
+++ b/modules/auth_saml/app/services/saml/providers/set_attributes_service.rb
@@ -29,8 +29,6 @@
module Saml
module Providers
class SetAttributesService < BaseServices::SetAttributes
- include Attachments::SetReplacements
-
private
def set_default_attributes(*)
diff --git a/modules/auth_saml/app/services/saml/update_metadata_service.rb b/modules/auth_saml/app/services/saml/update_metadata_service.rb
index 6168077faac..525294ae09d 100644
--- a/modules/auth_saml/app/services/saml/update_metadata_service.rb
+++ b/modules/auth_saml/app/services/saml/update_metadata_service.rb
@@ -38,8 +38,9 @@ module Saml
def call
ServiceResult.success(result: updated_metadata)
rescue StandardError => e
+ binding.pry
OpenProject.logger.error(e)
- ServiceResult.failure(message: I18n.t('saml.metadata_parser.error', error: e.class.name))
+ ServiceResult.failure(message: I18n.t("saml.metadata_parser.error", error: e.class.name))
end
private
@@ -59,9 +60,9 @@ module Saml
end
def parse_url
- parser.parse_remote_to_hash(metadata_url)
+ parser_instance.parse_remote_to_hash(provider.metadata_url)
rescue OneLogin::RubySaml::HttpError => e
- ServiceResult.failure(message: I18n.t('saml.metadata_parser.error', error: e.message))
+ ServiceResult.failure(message: I18n.t("saml.metadata_parser.error", error: e.message))
end
def parser_instance
diff --git a/modules/auth_saml/app/views/saml/providers/edit.html.erb b/modules/auth_saml/app/views/saml/providers/edit.html.erb
index 5859fc6f240..edaa869215e 100644
--- a/modules/auth_saml/app/views/saml/providers/edit.html.erb
+++ b/modules/auth_saml/app/views/saml/providers/edit.html.erb
@@ -1,15 +1,13 @@
<% page_title = t('saml.providers.label_edit', name: @provider.display_name) %>
-<% local_assigns[:additional_breadcrumb] = @provider.display_name %>
<% html_title(t(:label_administration), page_title) -%>
-<% content_controller "admin--saml", dynamic: true %>
<%= render(Primer::OpenProject::PageHeader.new) do |header| %>
- <% header.with_title { page_title } %>
+ <% header.with_title { I18n.t(:label_edit_x, x: @provider.display_name) } %>
<% header.with_breadcrumbs([{ href: admin_index_path, text: t("label_administration") },
{ href: saml_providers_path, text: t('saml.providers.plural') },
- page_title]) %>
+ I18n.t(:label_edit_x, x: @provider.display_name)]) %>
<% header.with_description do %>
<%= link_translate(
diff --git a/modules/auth_saml/config/locales/en.yml b/modules/auth_saml/config/locales/en.yml
index 558918bfc5f..5c57046d79a 100644
--- a/modules/auth_saml/config/locales/en.yml
+++ b/modules/auth_saml/config/locales/en.yml
@@ -2,14 +2,17 @@ en:
activemodel:
attributes:
saml/provider:
- name: Identifier
- display_name: Display name
+ display_name: Name
identifier: Identifier
secret: Secret
scope: Scope
limit_self_registration: Limit self registration
sp_entity_id: Service entity ID
metadata_url: Identity provider metadata URL
+ name_identifier_format: Name identifier format
+ idp_sso_service_url: Identity provider login endpoint
+ idp_slo_service_url: Identity provider logout endpoint
+ idp_cert: Public certificate of identity provider
saml:
menu_title: SAML providers
info:
@@ -25,6 +28,7 @@ en:
label_empty_description: "Add a provider to see them here."
label_automatic_configuration: Automatic configuration
label_metadata: Metadata
+ label_configuration_details: "Identity provider endpoints and certificates"
label_add_new: New SAML identity provider
label_edit: Edit SAML identity provider %{name}
no_results_table: No SAML identity providers have been defined yet.
@@ -63,3 +67,14 @@ en:
Alternatively, enter the SAML metadata XML from your identity provider.
limit_self_registration: >
If enabled users can only register using this provider if the self registration setting allows for it.
+ sp_entity_id: >
+ The entity ID of the service provider. This is the unique client identifier of the OpenProject instance.
+ idp_sso_service_url: >
+ The URL of the identity provider login endpoint.
+ idp_slo_service_url: >
+ The URL of the identity provider login endpoint.
+ idp_cert: >
+ Enter the X509 PEM-formatted public certificate of the identity provider.
+ You can enter multiple certificates by separating them with a newline.
+ name_identifier_format: >
+ Set the name identifier format to be used for the SAML assertion.