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
[#43193] Remove OAuth cookie after successful authorization against Nextcloud
Andreas Pfohl7db29b0de9a4
diff --git a/app/controllers/oauth_clients_controller.rb b/app/controllers/oauth_clients_controller.rbindex 77755db8948..205c97dfb68 100644--- a/app/controllers/oauth_clients_controller.rb+++ b/app/controllers/oauth_clients_controller.rb@@ -29,11 +29,14 @@# This controller handles OAuth2 Authorization Code Grant redirects from a Authorization Server to# "callback" endpoint.class OAuthClientsController < ApplicationController+ before_action :set_oauth_statebefore_action :find_oauth_clientbefore_action :set_redirect_uribefore_action :set_codebefore_action :set_connection_manager+ after_action :clear_oauth_state_cookie+# Provide the OAuth2 "callback" endpoint.# The Authorization Server redirects# here after successful authentication and authorization.@@ -65,6 +68,14 @@ class OAuthClientsController < ApplicationControllerprivate+ def set_oauth_state+ @oauth_state = params[:state]+ end++ def clear_oauth_state_cookie+ cookies.delete("oauth_state_#{@oauth_state}") unless @oauth_state.nil?+ end+def set_oauth_errors(service_result)flash[:error] = ["#{t(:'oauth_client.errors.oauth_authorization_code_grant_had_errors')}:"]service_result.errors.each do |error|@@ -94,7 +105,7 @@ class OAuthClientsController < ApplicationController# redirect_uri is used by OpenProject to redirect to# after receiving an OAuth2 access token. So it should not be blank.service_result = ::OAuthClients::RedirectUriFromStateService- .new(state: params[:state], cookies:)+ .new(state: @oauth_state, cookies:).callif service_result.success?@@ -153,7 +164,7 @@ class OAuthClientsController < ApplicationControllerdef get_redirect_uri::OAuthClients::RedirectUriFromStateService- .new(state: params[:state], cookies:)+ .new(state: @oauth_state, cookies:).call.resultend