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
[#50871] added storage id to oauth state cookie
Eric Schubertd17a8a7f57d0
diff --git a/app/controllers/oauth_clients_controller.rb b/app/controllers/oauth_clients_controller.rbindex 5cccd073967..bcf67502fb4 100644--- a/app/controllers/oauth_clients_controller.rb+++ b/app/controllers/oauth_clients_controller.rb@@ -133,7 +133,11 @@ class OAuthClientsController < ApplicationControllerenddef find_oauth_client- @oauth_client = OAuthClient.find_by(client_id: params[:oauth_client_id])+ # FIXME: This is a hack, fetching additional information of the storage to identify the oauth client.+ # This must be fixed in #50872.+ state_cookie = MultiJson.load(cookies["oauth_state_#{@oauth_state}"], symbolize_keys: true)+ @oauth_client = OAuthClient.find_by(client_id: params[:oauth_client_id],+ integration_id: state_cookie[:storageId])if @oauth_client.nil?# oauth_client can be nil if OAuthClient was not found.# This happens during admin setup if the user forgot to update the return_uridiff --git a/app/services/oauth_clients/redirect_uri_from_state_service.rb b/app/services/oauth_clients/redirect_uri_from_state_service.rbindex 19f420ee218..ebfa198b7d2 100644--- a/app/services/oauth_clients/redirect_uri_from_state_service.rb+++ b/app/services/oauth_clients/redirect_uri_from_state_service.rb@@ -51,7 +51,8 @@ module OAuthClientsdef oauth_state_cookiereturn nil if @state.blank?- @cookies["oauth_state_#{@state}"]+ state_cookie = MultiJson.load(@cookies["oauth_state_#{@state}"], symbolize_keys: true)+ state_cookie[:href]endendenddiff --git a/frontend/src/app/shared/components/storages/storage-information/storage-information.service.ts b/frontend/src/app/shared/components/storages/storage-information/storage-information.service.tsindex bd7b3b335e2..7563d9b7033 100644--- a/frontend/src/app/shared/components/storages/storage-information/storage-information.service.ts+++ b/frontend/src/app/shared/components/storages/storage-information/storage-information.service.ts@@ -97,6 +97,7 @@ export class StorageInformationService {this.text.authorizationFailureHeader(storageType),this.text.authorizationFailureContent(storageType),{+ storageId: storage.id,storageType: storage._links.type.href,authorizationLink: storage._links.authorize,},diff --git a/frontend/src/app/shared/components/storages/storage-login-button/storage-login-button.component.ts b/frontend/src/app/shared/components/storages/storage-login-button/storage-login-button.component.tsindex c9535a4f211..3eea6cf7b41 100644--- a/frontend/src/app/shared/components/storages/storage-login-button/storage-login-button.component.ts+++ b/frontend/src/app/shared/components/storages/storage-login-button/storage-login-button.component.ts@@ -73,9 +73,11 @@ export class StorageLoginButtonComponent implements OnInit {}private setAuthorizationCallbackCookie(nonce:string):void {- this.cookieService.set(`oauth_state_${nonce}`, window.location.href, {- path: '/',- });+ this.cookieService.set(+ `oauth_state_${nonce}`,+ JSON.stringify({ href: window.location.href, storageId: this.input.storageId }),+ { path: '/' },+ );}private static authorizationFailureActionUrl(baseUrl:string, nonce:string):string {diff --git a/frontend/src/app/shared/components/storages/storage-login-button/storage-login-input.ts b/frontend/src/app/shared/components/storages/storage-login-button/storage-login-input.tsindex 4863a9731ae..5ba038b4429 100644--- a/frontend/src/app/shared/components/storages/storage-login-button/storage-login-input.ts+++ b/frontend/src/app/shared/components/storages/storage-login-button/storage-login-input.ts@@ -26,9 +26,12 @@// See COPYRIGHT and LICENSE files for more details.//+++import { ID } from '@datorama/akita';+import { IHalResourceLink } from 'core-app/core/state/hal-resource';export interface IStorageLoginInput {+ storageId:ID;storageType:string;authorizationLink:IHalResourceLink;}diff --git a/modules/storages/app/helpers/storage_login_helper.rb b/modules/storages/app/helpers/storage_login_helper.rbindex 36e46aeab73..c4f946dd0c1 100644--- a/modules/storages/app/helpers/storage_login_helper.rb+++ b/modules/storages/app/helpers/storage_login_helper.rb@@ -36,6 +36,7 @@ module StorageLoginHelper.new(user: current_user, configuration: storage.oauth_configuration){+ storageId: storage.id,storageType: API::V3::Storages::STORAGE_TYPE_URN_MAP[storage.provider_type],authorizationLink: {href: connection_manager.get_authorization_uri