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
Need to pass controller to sevice for OIDC callback
Oliver Güntherf1e25499cde5
diff --git a/app/controllers/concerns/accounts/omniauth_login.rb b/app/controllers/concerns/accounts/omniauth_login.rbindex ee960c6ff35..48dea07fbb4 100644--- a/app/controllers/concerns/accounts/omniauth_login.rb+++ b/app/controllers/concerns/accounts/omniauth_login.rb@@ -85,7 +85,7 @@ module Accounts::OmniauthLogindef handle_omniauth_authentication(auth_hash, user_params: nil)call = ::Authentication::OmniauthService- .new(strategy: request.env['omniauth.strategy'], auth_hash: auth_hash, session: session)+ .new(strategy: request.env['omniauth.strategy'], auth_hash: auth_hash, controller: self).call(user_params)if call.success?diff --git a/app/services/authentication/omniauth_service.rb b/app/services/authentication/omniauth_service.rbindex cab53c9a047..2255ba6a120 100644--- a/app/services/authentication/omniauth_service.rb+++ b/app/services/authentication/omniauth_service.rb@@ -34,16 +34,18 @@ module Authenticationattr_accessor :auth_hash,:strategy,- :session,+ :controller,:contract,:user_attributes,:identity_url,:user- def initialize(strategy:, auth_hash:, session:)+ delegate :session, to: :controller++ def initialize(strategy:, auth_hash:, controller:)self.strategy = strategyself.auth_hash = auth_hash- self.session = session+ self.controller = controllerself.contract = ::Authentication::OmniauthAuthHashContract.new(auth_hash)enddiff --git a/modules/openid_connect/lib/open_project/openid_connect/engine.rb b/modules/openid_connect/lib/open_project/openid_connect/engine.rbindex ea707a35673..eccabce0581 100644--- a/modules/openid_connect/lib/open_project/openid_connect/engine.rb+++ b/modules/openid_connect/lib/open_project/openid_connect/engine.rb@@ -67,7 +67,8 @@ module OpenProject::OpenIDConnectaccess_token = auth_hash.fetch(:credentials, {})[:token]# put it into a cookieif context && access_token- context.send(:cookies)[:_open_project_session_access_token] = {+ controller = context.controller+ controller.send(:cookies)[:_open_project_session_access_token] = {value: access_token,secure: secure_cookie}diff --git a/spec/services/authentication/omniauth_service_spec.rb b/spec/services/authentication/omniauth_service_spec.rbindex dffcade7e25..4fe33b58951 100644--- a/spec/services/authentication/omniauth_service_spec.rb+++ b/spec/services/authentication/omniauth_service_spec.rb@@ -41,9 +41,10 @@ describe Authentication::OmniauthService do})end- let(:session) { [] }+ let(:controller) { double('Controller', session: session_stub) }+ let(:session_stub) { [] }- let(:instance) { described_class.new(strategy: strategy, auth_hash: auth_hash, session: session) }+ let(:instance) { described_class.new(strategy: strategy, auth_hash: auth_hash, controller: controller) }let(:user_attributes) { instance.send :build_omniauth_hash_to_user_attributes }describe '#contract' do