mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
correct determination of callback client
This commit is contained in:
parent
1f0cb55d39
commit
ec2454e69e
@ -25,16 +25,16 @@ export class AuthenticationResolver {
|
||||
logger.debug(`Authentication: pubKeyBuf=`, pubKeyBuf)
|
||||
logger.debug(`Authentication: pubKeyBufString=`, pubKeyBuf.toString('hex'))
|
||||
|
||||
// first find with args.publicKey the community, which starts openConnection request
|
||||
const requestedCom = await DbCommunity.findOneBy({
|
||||
// first find with args.publicKey the community 'comA', which starts openConnection request
|
||||
const comA = await DbCommunity.findOneBy({
|
||||
publicKey: pubKeyBuf, // Buffer.from(args.publicKey),
|
||||
})
|
||||
if (!requestedCom) {
|
||||
if (!comA) {
|
||||
throw new LogError(`unknown requesting community with publicKey`, pubKeyBuf.toString('hex'))
|
||||
}
|
||||
logger.debug(`Authentication: found requestedCom:`, requestedCom)
|
||||
logger.debug(`Authentication: found requestedCom:`, comA)
|
||||
// no await to respond immediatly and invoke callback-request asynchron
|
||||
void startOpenConnectionCallback(args, requestedCom, CONFIG.FEDERATION_API)
|
||||
void startOpenConnectionCallback(args, comA, CONFIG.FEDERATION_API)
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@ -12,23 +12,28 @@ import { AuthenticationArgs } from '../model/AuthenticationArgs'
|
||||
|
||||
export async function startOpenConnectionCallback(
|
||||
args: OpenConnectionArgs,
|
||||
requestedCom: DbCommunity,
|
||||
comA: DbCommunity,
|
||||
api: string,
|
||||
): Promise<void> {
|
||||
logger.debug(`Authentication: startOpenConnectionCallback() with:`, args, requestedCom)
|
||||
logger.debug(`Authentication: startOpenConnectionCallback() with:`, args, comA)
|
||||
try {
|
||||
const homeCom = await DbCommunity.findOneByOrFail({ foreign: false })
|
||||
const homeFedCom = await DbFedCommunity.findOneByOrFail({
|
||||
foreign: false,
|
||||
apiVersion: api,
|
||||
})
|
||||
const fedComA = await DbFedCommunity.findOneByOrFail({
|
||||
foreign: true,
|
||||
apiVersion: api,
|
||||
publicKey: comA.publicKey,
|
||||
})
|
||||
const oneTimeCode = randombytes_random()
|
||||
// store oneTimeCode in requestedCom.community_uuid as authenticate-request-identifier
|
||||
requestedCom.communityUuid = oneTimeCode.toString()
|
||||
await DbCommunity.save(requestedCom)
|
||||
logger.debug(`Authentication: stored oneTimeCode in requestedCom:`, requestedCom)
|
||||
comA.communityUuid = oneTimeCode.toString()
|
||||
await DbCommunity.save(comA)
|
||||
logger.debug(`Authentication: stored oneTimeCode in requestedCom:`, comA)
|
||||
|
||||
const client = AuthenticationClientFactory.getInstance(homeFedCom)
|
||||
const client = AuthenticationClientFactory.getInstance(fedComA)
|
||||
// eslint-disable-next-line camelcase
|
||||
if (client instanceof V1_0_AuthenticationClient) {
|
||||
const callbackArgs = new OpenConnectionCallbackArgs()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user