feat: add debug logs for grpc communication

This commit is contained in:
Karol Sójko 2023-11-16 12:10:46 +01:00
parent 9dbcec198d
commit 6391a01b57
No known key found for this signature in database
GPG key ID: C2F813669419D05F
4 changed files with 11 additions and 0 deletions

View file

@ -49,6 +49,8 @@ export abstract class AuthMiddleware extends BaseMiddleware {
return
}
this.logger.debug('[AuthMiddleware] Fetched cross-service token from underlying service')
crossServiceToken = (authResponse.data as { authToken: string }).authToken
crossServiceTokenFetchedFromCache = false
}

View file

@ -37,6 +37,8 @@ export class GRPCServiceProxy implements ServiceProxyInterface {
const metadata = new grpc.Metadata()
metadata.set('x-shared-vault-owner-context', headers.sharedVaultOwnerContext ?? '')
this.logger.debug('[GRPCServiceProxy] Validating session via gRPC')
this.sessionsClient.validate(
request,
metadata,

View file

@ -91,6 +91,7 @@ void container.load().then((container) => {
const sessionsServer = new SessionsServer(
container.get<AuthenticateRequest>(TYPES.Auth_AuthenticateRequest),
container.get<CreateCrossServiceToken>(TYPES.Auth_CreateCrossServiceToken),
container.get<winston.Logger>(TYPES.Auth_Logger),
)
grpcServer.addService(SessionsService, {

View file

@ -6,17 +6,21 @@ import { AuthorizationHeader, ISessionsServer, SessionValidationResponse } from
import { AuthenticateRequest } from '../../Domain/UseCase/AuthenticateRequest'
import { User } from '../../Domain/User/User'
import { CreateCrossServiceToken } from '../../Domain/UseCase/CreateCrossServiceToken/CreateCrossServiceToken'
import { Logger } from 'winston'
export class SessionsServer implements ISessionsServer {
constructor(
private authenticateRequest: AuthenticateRequest,
private createCrossServiceToken: CreateCrossServiceToken,
private logger: Logger,
) {}
async validate(
call: grpc.ServerUnaryCall<AuthorizationHeader, SessionValidationResponse>,
callback: grpc.sendUnaryData<SessionValidationResponse>,
): Promise<void> {
this.logger.debug('[SessionsServer] Validating session via gRPC')
const authenticateRequestResponse = await this.authenticateRequest.execute({
authorizationHeader: call.request.getBearerToken(),
})
@ -69,6 +73,8 @@ export class SessionsServer implements ISessionsServer {
const response = new SessionValidationResponse()
response.setCrossServiceToken(resultOrError.getValue())
this.logger.debug('[SessionsServer] Session validated via gRPC')
callback(null, response)
}
}