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

Allow passing basic groups configuration from ENV

Oliver Günther41669d594b81
diff --git a/modules/openid_connect/app/services/openid_connect/configuration_mapper.rb b/modules/openid_connect/app/services/openid_connect/configuration_mapper.rb
index 554754d9950..8c2e88fb8cc 100644
--- a/modules/openid_connect/app/services/openid_connect/configuration_mapper.rb
+++ b/modules/openid_connect/app/services/openid_connect/configuration_mapper.rb
@@ -65,7 +65,9 @@ module OpenIDConnect
"mapping_email" => options.dig("attribute_map", "email"),
"mapping_first_name" => options.dig("attribute_map", "first_name"),
"mapping_last_name" => options.dig("attribute_map", "last_name"),
- "mapping_admin" => options.dig("attribute_map", "admin")
+ "mapping_admin" => options.dig("attribute_map", "admin"),
+ "sync_groups" => options["sync_groups"] == "true",
+ "groups_claim" => options["groups_claim"]
}.compact
end
diff --git a/modules/openid_connect/spec/services/openid_connect/configuration_mapper_spec.rb b/modules/openid_connect/spec/services/openid_connect/configuration_mapper_spec.rb
index c308beceff4..74b3b44f41c 100644
--- a/modules/openid_connect/spec/services/openid_connect/configuration_mapper_spec.rb
+++ b/modules/openid_connect/spec/services/openid_connect/configuration_mapper_spec.rb
@@ -175,6 +175,44 @@ RSpec.describe OpenIDConnect::ConfigurationMapper, type: :model do
end
end
+ describe "sync_groups" do
+ subject { result["sync_groups"] }
+
+ context "when 'false'" do
+ let(:configuration) { { sync_groups: "false" } }
+
+ it { is_expected.to be_falsey }
+ end
+
+ context "when 'true'" do
+ let(:configuration) { { sync_groups: "true" } }
+
+ it { is_expected.to be_truthy }
+ end
+
+ context "when not provided" do
+ let(:configuration) { {} }
+
+ it { is_expected.to be_falsey }
+ end
+ end
+
+ describe "groups_claim" do
+ subject { result["groups_claim"] }
+
+ context "when provided" do
+ let(:configuration) { { groups_claim: "foobar" } }
+
+ it { is_expected.to eq("foobar") }
+ end
+
+ context "when not provided" do
+ let(:configuration) { {} }
+
+ it { is_expected.to be_blank }
+ end
+ end
+
%w[authorization_endpoint token_endpoint userinfo_endpoint end_session_endpoint jwks_uri].each do |key|
describe "setting #{key}" do
subject { result }