From db1319cf54e1b1fd872cbb5f412fce108f68ff79 Mon Sep 17 00:00:00 2001 From: Christian Kurz Date: Fri, 18 Oct 2024 17:15:25 +0200 Subject: [PATCH 1/4] github node id --- backend/src/backend-services/ims-user-finding.service.ts | 1 + backend/src/strategies/github/github.service.ts | 4 +++- .../jira-token-datacenter/jira-token-datacenter.service.ts | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/src/backend-services/ims-user-finding.service.ts b/backend/src/backend-services/ims-user-finding.service.ts index 9014f58f..547702ef 100644 --- a/backend/src/backend-services/ims-user-finding.service.ts +++ b/backend/src/backend-services/ims-user-finding.service.ts @@ -200,6 +200,7 @@ export class ImsUserFindingService { email?: string; }, ): Promise { + console.log(matchingInstance, matchingStrategy, imsUserTemplatedValues, imsUser); const requiredLoginDataData = matchingStrategy.getLoginDataDataForImsUserTemplatedFields({ ...imsUserTemplatedValues, id: imsUser.id, diff --git a/backend/src/strategies/github/github.service.ts b/backend/src/strategies/github/github.service.ts index b24324a7..cb5f6d09 100644 --- a/backend/src/strategies/github/github.service.ts +++ b/backend/src/strategies/github/github.service.ts @@ -117,7 +117,7 @@ export class GithubStrategyService extends StrategyUsingPassport { override async getSyncDataForLoginData( loginData: UserLoginData, - ): Promise<{ token: string | null; [key: string]: any }> { + ): Promise<{ token: string | null;[key: string]: any }> { const syncLogins = ( await this.activeLoginService.findValidForLoginDataSortedByExpiration(loginData, true) ).filter((login) => !!login.data["accessToken"]); @@ -189,11 +189,13 @@ export class GithubStrategyService extends StrategyUsingPassport { const dataUserLoginData = { username, github_id: parseInt(profile.id), + github_node_id: profile.nodeId, email: profile.emails?.[0]?.value, displayName: profile.displayName, }; const loginDataCandidates = await this.loginDataService.findForStrategyWithDataContaining(strategyInstance, { github_id: parseInt(profile.id), + github_node_id: profile.nodeId, }); if (loginDataCandidates.length != 1) { this.loggerGithub.debug("Oauth login didn't find unique login data", loginDataCandidates); diff --git a/backend/src/strategies/jira-token-datacenter/jira-token-datacenter.service.ts b/backend/src/strategies/jira-token-datacenter/jira-token-datacenter.service.ts index 1147a0b9..6e7106d7 100644 --- a/backend/src/strategies/jira-token-datacenter/jira-token-datacenter.service.ts +++ b/backend/src/strategies/jira-token-datacenter/jira-token-datacenter.service.ts @@ -134,6 +134,9 @@ export class JiraTokenDatacenterStrategyService extends Strategy { ); if (!response.ok) { +console.log(response.status); +console.log(await response.text()); +console.log(combineURL("rest/api/2/myself", strategyInstance.instanceConfig["imsTemplatedFieldsFilter"]["root-url"])) return null; } From 7d6617dcabf1c3a6bcc95d49199a1a3f1d1c677c Mon Sep 17 00:00:00 2001 From: Christian Kurz Date: Fri, 18 Oct 2024 17:21:32 +0200 Subject: [PATCH 2/4] add github_node_id to the other occurences of github_id --- backend/src/strategies/github/github.service.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/backend/src/strategies/github/github.service.ts b/backend/src/strategies/github/github.service.ts index cb5f6d09..f891d5b5 100644 --- a/backend/src/strategies/github/github.service.ts +++ b/backend/src/strategies/github/github.service.ts @@ -127,6 +127,7 @@ export class GithubStrategyService extends StrategyUsingPassport { override getImsUserTemplatedValuesForLoginData(loginData: UserLoginData): object { return { github_id: loginData.data["github_id"], + github_node_id: loginData.data["github_node_id"], username: loginData.data["username"], displayName: loginData.data["displayName"], email: loginData.data["email"], @@ -136,6 +137,7 @@ export class GithubStrategyService extends StrategyUsingPassport { override getLoginDataDataForImsUserTemplatedFields(imsUser: object): object | Promise { return { github_id: imsUser["github_id"], + github_node_id: imsUser["github_node_id"], }; } From a9c971f982ed18cffd210fc0ea816c864656e53b Mon Sep 17 00:00:00 2001 From: nk-coding Date: Fri, 18 Oct 2024 17:28:34 +0200 Subject: [PATCH 3/4] add github_node_id to github token service --- .../src/strategies/github-token/github-token.service.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/backend/src/strategies/github-token/github-token.service.ts b/backend/src/strategies/github-token/github-token.service.ts index e3b0b0c7..7f6307e4 100644 --- a/backend/src/strategies/github-token/github-token.service.ts +++ b/backend/src/strategies/github-token/github-token.service.ts @@ -93,6 +93,7 @@ export class GithubTokenStrategyService extends Strategy { override getImsUserTemplatedValuesForLoginData(loginData: UserLoginData): object { return { github_id: loginData.data["github_id"], + github_node_id: loginData.data["github_node_id"], username: loginData.data["username"], displayName: loginData.data["displayName"], email: loginData.data["email"], @@ -102,6 +103,7 @@ export class GithubTokenStrategyService extends Strategy { override getLoginDataDataForImsUserTemplatedFields(imsUser: object): object | Promise { return { github_id: imsUser["github_id"], + github_node_id: imsUser["github_node_id"], }; } @@ -119,7 +121,8 @@ export class GithubTokenStrategyService extends Strategy { token: string, strategyInstance: StrategyInstance, ): Promise<{ - github_id: string; + github_id: number; + github_node_id: string; username: string; displayName: string; email: string; @@ -129,6 +132,7 @@ export class GithubTokenStrategyService extends Strategy { { viewer { id + databaseId login name email @@ -152,7 +156,8 @@ export class GithubTokenStrategyService extends Strategy { const userData = data.data.viewer; return { - github_id: userData.id, + github_id: userData.databaseId, + github_node_id: userData.id, username: userData.login, displayName: userData.name, email: userData.email, From 6226fb50dcd6e2a30ae13a6a856b6cc9faedb1e1 Mon Sep 17 00:00:00 2001 From: nk-coding Date: Sun, 20 Oct 2024 15:37:22 +0200 Subject: [PATCH 4/4] remove debug console log --- backend/src/backend-services/ims-user-finding.service.ts | 1 - .../jira-token-datacenter/jira-token-datacenter.service.ts | 3 --- 2 files changed, 4 deletions(-) diff --git a/backend/src/backend-services/ims-user-finding.service.ts b/backend/src/backend-services/ims-user-finding.service.ts index 547702ef..9014f58f 100644 --- a/backend/src/backend-services/ims-user-finding.service.ts +++ b/backend/src/backend-services/ims-user-finding.service.ts @@ -200,7 +200,6 @@ export class ImsUserFindingService { email?: string; }, ): Promise { - console.log(matchingInstance, matchingStrategy, imsUserTemplatedValues, imsUser); const requiredLoginDataData = matchingStrategy.getLoginDataDataForImsUserTemplatedFields({ ...imsUserTemplatedValues, id: imsUser.id, diff --git a/backend/src/strategies/jira-token-datacenter/jira-token-datacenter.service.ts b/backend/src/strategies/jira-token-datacenter/jira-token-datacenter.service.ts index 6e7106d7..1147a0b9 100644 --- a/backend/src/strategies/jira-token-datacenter/jira-token-datacenter.service.ts +++ b/backend/src/strategies/jira-token-datacenter/jira-token-datacenter.service.ts @@ -134,9 +134,6 @@ export class JiraTokenDatacenterStrategyService extends Strategy { ); if (!response.ok) { -console.log(response.status); -console.log(await response.text()); -console.log(combineURL("rest/api/2/myself", strategyInstance.instanceConfig["imsTemplatedFieldsFilter"]["root-url"])) return null; }