feat: add debug logs for grpc communication
This commit is contained in:
parent
9dbcec198d
commit
6391a01b57
4 changed files with 11 additions and 0 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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, {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue