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
Move attribute mapping to oidc gem
Oliver Günthere7a1faa21c31
diff --git a/Gemfile.lock b/Gemfile.lockindex 7334ccfbc24..5f7107e62a8 100644--- a/Gemfile.lock+++ b/Gemfile.lock@@ -9,8 +9,8 @@ GITGITremote: https://github.com/opf/omniauth-openid-connect.git- revision: 720ba915863bccb6a352d8eefc0864066107f71d- ref: 720ba915863bccb6a352d8eefc0864066107f71d+ revision: fe07349f0c6c9373510c1efc5bca871b6cbe5c5a+ ref: fe07349f0c6c9373510c1efc5bca871b6cbe5c5aspecs:omniauth-openid-connect (0.4.0)addressable (~> 2.5)diff --git a/Gemfile.modules b/Gemfile.modulesindex 1be5fec62d2..b8c2a908d3d 100644--- a/Gemfile.modules+++ b/Gemfile.modules@@ -14,7 +14,7 @@ gem 'omniauth-openid_connect-providers',gem 'omniauth-openid-connect',git: 'https://github.com/opf/omniauth-openid-connect.git',- ref: '720ba915863bccb6a352d8eefc0864066107f71d'+ ref: 'fe07349f0c6c9373510c1efc5bca871b6cbe5c5a'group :opf_plugins do# included so that engines can reference OpenProject::Versiondiff --git a/modules/openid_connect/lib/open_project/openid_connect/engine.rb b/modules/openid_connect/lib/open_project/openid_connect/engine.rbindex d4e407c68f5..5708989263d 100644--- a/modules/openid_connect/lib/open_project/openid_connect/engine.rb+++ b/modules/openid_connect/lib/open_project/openid_connect/engine.rb@@ -57,8 +57,8 @@ module OpenProject::OpenIDConnect# Allow username mapping from 'preferred_username' claimh[:openproject_attribute_map] = Proc.new do |auth|{}.tap do |additional|- preferred_username = auth.dig('extra', 'raw_info', 'preferred_username')- additional[:login] = preferred_username if preferred_username.present?+ mapped_login = auth.dig(:info, :login) || auth.dig('extra', 'raw_info', 'preferred_username')+ additional[:login] = mapped_login if mapped_login.present?endenddiff --git a/modules/openid_connect/spec/requests/openid_connect_spec.rb b/modules/openid_connect/spec/requests/openid_connect_spec.rbindex dccc65c0aac..e89080fcfb6 100644--- a/modules/openid_connect/spec/requests/openid_connect_spec.rb+++ b/modules/openid_connect/spec/requests/openid_connect_spec.rb@@ -131,7 +131,7 @@ describe 'OpenID Connect',endend- context 'with a preferred_username claim' do+ context 'with a preferred_username claim and mapping' dolet(:user_info) do{sub: '87117114115116',@@ -151,6 +151,39 @@ describe 'OpenID Connect',expect(user).to be_presentendend++ context 'with a custom claim and mapping' do+ let(:user_info) do+ {+ sub: '87117114115116',+ name: 'Hans Wurst',+ email: '[email protected]',+ given_name: 'Hans',+ family_name: 'Wurst',+ foobar: 'a.truly.random.value'+ }+ end++ before do+ allow(Setting).to receive(:plugin_openproject_openid_connect).and_return(+ 'providers' => {+ 'heroku' => {+ 'attribute_map' => { login: :foobar },+ 'identifier' => 'does not',+ 'secret' => 'matter'+ }+ }+ )+ end++ it 'maps to the login' do+ click_on_signin+ redirect_from_provider++ user = User.find_by(login: 'a.truly.random.value')+ expect(user).to be_present+ end+ endendcontext 'provider configuration through the settings' do