From c7cb0945900bea79a1ab8fae785b6f9f1fdea938 Mon Sep 17 00:00:00 2001 From: Claus-Peter Huebner Date: Wed, 25 Oct 2023 22:19:48 +0200 Subject: [PATCH] correct determination of fedComB client to invoke authenticate --- .../api/1_0/resolver/AuthenticationResolver.ts | 10 +++++----- .../graphql/api/1_0/util/authenticateCommunity.ts | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/federation/src/graphql/api/1_0/resolver/AuthenticationResolver.ts b/federation/src/graphql/api/1_0/resolver/AuthenticationResolver.ts index e526200d7..b580f0a73 100644 --- a/federation/src/graphql/api/1_0/resolver/AuthenticationResolver.ts +++ b/federation/src/graphql/api/1_0/resolver/AuthenticationResolver.ts @@ -47,14 +47,14 @@ export class AuthenticationResolver { // TODO decrypt args.url with homeCom.privateKey and verify signing with callbackFedCom.publicKey const endPoint = args.url.slice(0, args.url.lastIndexOf('/') + 1) const apiVersion = args.url.slice(args.url.lastIndexOf('/') + 1, args.url.length) - logger.debug(`Authentication: search fedCom per:`, endPoint, apiVersion) - const callbackFedCom = await DbFedCommunity.findOneBy({ endPoint, apiVersion }) - if (!callbackFedCom) { + logger.debug(`Authentication: search fedComB per:`, endPoint, apiVersion) + const fedComB = await DbFedCommunity.findOneBy({ endPoint, apiVersion }) + if (!fedComB) { throw new LogError(`unknown callback community with url`, args.url) } - logger.debug(`Authentication: found fedCom and start authentication:`, callbackFedCom) + logger.debug(`Authentication: found fedComB and start authentication:`, fedComB) // no await to respond immediatly and invoke authenticate-request asynchron - void startAuthentication(args.oneTimeCode, callbackFedCom) + void startAuthentication(args.oneTimeCode, fedComB) return true } diff --git a/federation/src/graphql/api/1_0/util/authenticateCommunity.ts b/federation/src/graphql/api/1_0/util/authenticateCommunity.ts index 83a9d7987..737590f20 100644 --- a/federation/src/graphql/api/1_0/util/authenticateCommunity.ts +++ b/federation/src/graphql/api/1_0/util/authenticateCommunity.ts @@ -56,18 +56,18 @@ export async function startOpenConnectionCallback( export async function startAuthentication( oneTimeCode: string, - callbackFedCom: DbFedCommunity, + fedComB: DbFedCommunity, ): Promise { - logger.debug(`Authentication: startAuthentication()...`, oneTimeCode, callbackFedCom) + logger.debug(`Authentication: startAuthentication()...`, oneTimeCode, fedComB) try { const homeCom = await DbCommunity.findOneByOrFail({ foreign: false }) const homeFedCom = await DbFedCommunity.findOneByOrFail({ foreign: false, - apiVersion: callbackFedCom.apiVersion, + apiVersion: fedComB.apiVersion, }) // TODO encrypt homeCom.uuid with homeCom.privateKey and sign it with callbackFedCom.publicKey - const client = AuthenticationClientFactory.getInstance(homeFedCom) + const client = AuthenticationClientFactory.getInstance(fedComB) // eslint-disable-next-line camelcase if (client instanceof V1_0_AuthenticationClient) { const authenticationArgs = new AuthenticationArgs() @@ -83,11 +83,11 @@ export async function startAuthentication( logger.debug( `Authentication: received communityUUid for callbackFedCom:`, fedComUuid, - callbackFedCom, + fedComB, ) const callbackCom = await DbCommunity.findOneByOrFail({ foreign: true, - publicKey: callbackFedCom.publicKey, + publicKey: fedComB.publicKey, }) // TODO decrypt fedComUuid with callbackFedCom.publicKey callbackCom.communityUuid = fedComUuid