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

Add UI to inspect OIDC group links

Jan Sandbrink48ee98b6ef04
diff --git a/app/helpers/groups_helper.rb b/app/helpers/groups_helper.rb
index 0e879b7290b..2a36884936a 100644
--- a/app/helpers/groups_helper.rb
+++ b/app/helpers/groups_helper.rb
@@ -54,6 +54,12 @@ module GroupsHelper
partial: "principals/global_roles",
path: edit_group_path(group, tab: :global_roles),
label: :label_global_roles
+ },
+ {
+ name: "synchronized_groups",
+ partial: "groups/synchronized_groups",
+ path: edit_group_path(group, tab: :synchronized_groups),
+ label: :"groups.edit.synchronized_groups"
}
]
end
diff --git a/app/models/group.rb b/app/models/group.rb
index a55e37f8ee5..d36c1304ed9 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -31,6 +31,19 @@
class Group < Principal
include ::Scopes::Scoped
+ # Register a partial to be rendered on the synchronized groups tab of the groups admin page
+ #
+ # @param title[String] I18n key that will be used as a title for the section
+ # @param partial[String] The partial path as it would be passed to `render partial:` for the partial that renders
+ # a list of synchronized groups to the group
+ def self.add_synchronized_group_partial(title:, partial:, count_callback:)
+ synchronized_group_partials.push(title:, partial:, count_callback:)
+ end
+
+ def self.synchronized_group_partials
+ @synchronized_group_partials ||= []
+ end
+
has_many :group_users,
autosave: true,
dependent: :destroy
diff --git a/app/views/groups/_synchronized_groups.html.erb b/app/views/groups/_synchronized_groups.html.erb
new file mode 100644
index 00000000000..243ca74431c
--- /dev/null
+++ b/app/views/groups/_synchronized_groups.html.erb
@@ -0,0 +1,50 @@
+<%#-- copyright
+OpenProject is an open source project management software.
+Copyright (C) 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.
+
+++#%>
+
+<% visible_partials = Group.synchronized_group_partials.select { |config| config.fetch(:count_callback).call(@group).positive? } %>
+<% if visible_partials.any? %>
+ <% visible_partials.each do |config| %>
+ <%=
+ render(Primer::Beta::Subhead.new(hide_border: true)) do |component|
+ component.with_heading(size: :medium) do
+ I18n.t(config.fetch(:title))
+ end
+ end
+ %>
+ <%= render partial: config.fetch(:partial), locals: { group: @group } %>
+ <% end %>
+<% else %>
+ <%=
+ render(Primer::Beta::Blankslate.new(border: true)) do |blankslate|
+ blankslate.with_heading(tag: :h2) { t(".blankslate.title") }
+ blankslate.with_description { t(".blankslate.description") }
+ blankslate.with_primary_action(tag: :a, href: admin_settings_authentication_path) { t(".blankslate.action") }
+ end
+ %>
+<% end %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index c3ee8304999..c4602dae710 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -404,6 +404,8 @@ en:
wiki_pages: "Wiki"
groups:
+ edit:
+ synchronized_groups: "Synchronized groups"
index:
no_results_title_text: There are currently no groups.
no_results_content_text: Create a new group
@@ -411,6 +413,11 @@ en:
no_results_title_text: There are currently no users part of this group.
memberships:
no_results_title_text: There are currently no projects part of this group.
+ synchronized_groups:
+ blankslate:
+ action: Authentication settings
+ description: When this group is automatically synced with groups in external identity providers like OpenID, they will appear here. You can set this up in your Authentication settings.
+ title: No synchronized groups yet
incoming_mails:
ignore_filenames: >
@@ -1192,7 +1199,6 @@ en:
role:
permissions: "Permissions"
scim_client:
- auth_provider: "Authentication provider"
authentication_method: "Authentication method"
jwt_sub: "Subject claim"
status:
@@ -1690,6 +1696,9 @@ en:
models:
attachment: "File"
attribute_help_text: "Attribute help text"
+ auth_provider:
+ one: "Authentication provider"
+ other: "Authentication providers"
category: "Category"
comment: "Comment"
custom_action: "Custom action"
diff --git a/modules/openid_connect/app/components/openid_connect/group_links/row_component.rb b/modules/openid_connect/app/components/openid_connect/group_links/row_component.rb
new file mode 100644
index 00000000000..28ddcc9ffeb
--- /dev/null
+++ b/modules/openid_connect/app/components/openid_connect/group_links/row_component.rb
@@ -0,0 +1,43 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 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 OpenIDConnect::GroupLinks
+ class RowComponent < OpPrimer::BorderBoxRowComponent
+ delegate :oidc_group_name, to: :model
+
+ def auth_provider
+ model.auth_provider.display_name
+ end
+
+ def created_at
+ helpers.format_date(model.created_at)
+ end
+ end
+end
diff --git a/modules/openid_connect/app/components/openid_connect/group_links/table_component.rb b/modules/openid_connect/app/components/openid_connect/group_links/table_component.rb
new file mode 100644
index 00000000000..e27f4b4abd3
--- /dev/null
+++ b/modules/openid_connect/app/components/openid_connect/group_links/table_component.rb
@@ -0,0 +1,52 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 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 OpenIDConnect::GroupLinks
+ class TableComponent < OpPrimer::BorderBoxTableComponent
+ columns :oidc_group_name, :auth_provider, :created_at
+ mobile_labels :oidc_group_name, :auth_provider, :created_at
+
+ def mobile_title
+ OpenIDConnect::GroupLink.model_name.human(count: 2)
+ end
+
+ def row_class
+ RowComponent
+ end
+
+ def headers
+ [
+ [:oidc_group_name, { caption: OpenIDConnect::GroupLink.human_attribute_name(:oidc_group_name) }],
+ [:auth_provider, { caption: OpenIDConnect::GroupLink.human_attribute_name(:auth_provider) }],
+ [:created_at, { caption: OpenIDConnect::GroupLink.human_attribute_name(:created_at) }]
+ ]
+ end
+ end
+end
diff --git a/modules/openid_connect/app/views/openid_connect/group_links/_table.html.erb b/modules/openid_connect/app/views/openid_connect/group_links/_table.html.erb
new file mode 100644
index 00000000000..f6e1eefe5e6
--- /dev/null
+++ b/modules/openid_connect/app/views/openid_connect/group_links/_table.html.erb
@@ -0,0 +1,30 @@
+<%#-- copyright
+OpenProject is an open source project management software.
+Copyright (C) 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.
+
+++#%>
+
+<%= render(OpenIDConnect::GroupLinks::TableComponent.new(rows: group.oidc_group_links)) %>
diff --git a/modules/openid_connect/config/locales/en.yml b/modules/openid_connect/config/locales/en.yml
index 7087d6a2eb0..922c3fd30f1 100644
--- a/modules/openid_connect/config/locales/en.yml
+++ b/modules/openid_connect/config/locales/en.yml
@@ -7,6 +7,8 @@ en:
Please [log in].
activerecord:
attributes:
+ openid_connect/group_link:
+ oidc_group_name: OpenID group identifier
openid_connect/provider:
name: Name
slug: Unique identifier
@@ -55,6 +57,7 @@ en:
openid_connect:
menu_title: OpenID providers
delete_title: "Delete OpenID Connect provider"
+ group_links_heading: OpenID Connect group links
instructions:
redirect_url: This is the redirect URL that the OpenID Connect provider should use to redirect back to OpenProject after a successful login.
diff --git a/modules/openid_connect/lib/open_project/openid_connect/engine.rb b/modules/openid_connect/lib/open_project/openid_connect/engine.rb
index 1511d674afe..65fe398b771 100644
--- a/modules/openid_connect/lib/open_project/openid_connect/engine.rb
+++ b/modules/openid_connect/lib/open_project/openid_connect/engine.rb
@@ -109,6 +109,12 @@ module OpenProject::OpenIDConnect
end
config.to_prepare do
+ Group.add_synchronized_group_partial(
+ title: "openid_connect.group_links_heading",
+ partial: "openid_connect/group_links/table",
+ count_callback: ->(group) { group.oidc_group_links.count }
+ )
+
::OpenProject::OpenIDConnect::Hooks::Hook
# Load AuthProvider descendants due to STI