correct determination of fedComB client to invoke authenticate

This commit is contained in:
Claus-Peter Huebner 2023-10-25 22:19:48 +02:00
parent d73d20e00a
commit c7cb094590
2 changed files with 11 additions and 11 deletions

View File

@ -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
}

View File

@ -56,18 +56,18 @@ export async function startOpenConnectionCallback(
export async function startAuthentication(
oneTimeCode: string,
callbackFedCom: DbFedCommunity,
fedComB: DbFedCommunity,
): Promise<void> {
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