mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
next try with publicKey-hex-string treatment
This commit is contained in:
parent
8d8d5275de
commit
b232579915
@ -6,7 +6,6 @@ import { CONFIG } from '@/config'
|
||||
// eslint-disable-next-line camelcase
|
||||
import { AuthenticationClient as V1_0_AuthenticationClient } from '@/federation/client/1_0/AuthenticationClient'
|
||||
import { backendLogger as logger } from '@/server/logger'
|
||||
import { stringToHex } from '@/util/utilities'
|
||||
|
||||
import { OpenConnectionArgs } from './client/1_0/model/OpenConnectionArgs'
|
||||
import { AuthenticationClientFactory } from './client/AuthenticationClientFactory'
|
||||
@ -21,7 +20,7 @@ export async function startCommunityAuthentication(
|
||||
})
|
||||
const foreignCom = await DbCommunity.findOneByOrFail({ publicKey: foreignFedCom.publicKey })
|
||||
logger.debug(
|
||||
'Authentication: started for foreignFedCom:',
|
||||
'Authentication: started with foreignFedCom:',
|
||||
foreignFedCom.endPoint,
|
||||
foreignFedCom.publicKey.toString('hex'),
|
||||
)
|
||||
@ -38,14 +37,14 @@ export async function startCommunityAuthentication(
|
||||
// eslint-disable-next-line camelcase
|
||||
if (client instanceof V1_0_AuthenticationClient) {
|
||||
const args = new OpenConnectionArgs()
|
||||
args.publicKey = homeCom.publicKey.toString()
|
||||
args.publicKey = homeCom.publicKey.toString('hex')
|
||||
// TODO encrypt url with foreignCom.publicKey and sign it with homeCom.privateKey
|
||||
args.url = homeFedCom.endPoint.endsWith('/')
|
||||
? homeFedCom.endPoint
|
||||
: homeFedCom.endPoint + '/' + homeFedCom.apiVersion
|
||||
logger.debug(
|
||||
'Authentication: before client.openConnection() args:',
|
||||
args.publicKey,
|
||||
homeCom.publicKey.toString('hex'),
|
||||
args.url,
|
||||
)
|
||||
if (await client.openConnection(args)) {
|
||||
|
||||
@ -2,7 +2,6 @@ import { FederatedCommunity as DbFederatedCommunity } from '@entity/FederatedCom
|
||||
import { GraphQLClient } from 'graphql-request'
|
||||
|
||||
import { backendLogger as logger } from '@/server/logger'
|
||||
import { stringToHex } from '@/util/utilities'
|
||||
|
||||
import { OpenConnectionArgs } from './model/OpenConnectionArgs'
|
||||
import { openConnection } from './query/openConnection'
|
||||
@ -30,7 +29,7 @@ export class AuthenticationClient {
|
||||
logger.debug(
|
||||
`Authentication: openConnection at ${this.endpoint} for args:`,
|
||||
args.url,
|
||||
stringToHex(args.publicKey),
|
||||
args.publicKey,
|
||||
)
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
|
||||
@ -15,10 +15,3 @@ export const decimalSeparatorByLanguage = (a: Decimal, language: string): string
|
||||
|
||||
export const fullName = (firstName: string, lastName: string): string =>
|
||||
[firstName, lastName].filter(Boolean).join(' ')
|
||||
|
||||
export function stringToHex(str: string): string {
|
||||
return str
|
||||
.split('')
|
||||
.map((char) => char.charCodeAt(0).toString(16).padStart(2, '0'))
|
||||
.join('')
|
||||
}
|
||||
|
||||
@ -9,7 +9,6 @@ import { startAuthentication, startOpenConnectionCallback } from '../util/authen
|
||||
import { OpenConnectionCallbackArgs } from '../model/OpenConnectionCallbackArgs'
|
||||
import { CONFIG } from '@/config'
|
||||
import { AuthenticationArgs } from '../model/AuthenticationArgs'
|
||||
import { stringToHex } from '@/util/utilities'
|
||||
|
||||
@Resolver()
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
@ -19,19 +18,21 @@ export class AuthenticationResolver {
|
||||
@Arg('data')
|
||||
args: OpenConnectionArgs,
|
||||
): Promise<boolean> {
|
||||
const pubKeyBuf = Buffer.from(args.publicKey, 'hex')
|
||||
logger.debug(
|
||||
`Authentication: openConnection() via apiVersion=1_0 ...`,
|
||||
args,
|
||||
args.url,
|
||||
stringToHex(args.publicKey),
|
||||
args.publicKey,
|
||||
pubKeyBuf.toString('hex'),
|
||||
)
|
||||
|
||||
// first find with args.publicKey the community, which starts openConnection request
|
||||
const requestedCom = await DbCommunity.findOneBy({
|
||||
publicKey: Buffer.from(args.publicKey),
|
||||
publicKey: pubKeyBuf, // Buffer.from(args.publicKey),
|
||||
})
|
||||
if (!requestedCom) {
|
||||
throw new LogError(`unknown requesting community with publicKey`, stringToHex(args.publicKey))
|
||||
throw new LogError(`unknown requesting community with publicKey`, pubKeyBuf.toString('hex'))
|
||||
}
|
||||
logger.debug(`Authentication: found requestedCom:`, requestedCom)
|
||||
// no await to respond immediatly and invoke callback-request asynchron
|
||||
|
||||
@ -1,6 +0,0 @@
|
||||
export function stringToHex(str: string): string {
|
||||
return str
|
||||
.split('')
|
||||
.map((char) => char.charCodeAt(0).toString(16).padStart(2, '0'))
|
||||
.join('')
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user