From 95cf3871b05cdbebe1c0b7192271a3557226eea1 Mon Sep 17 00:00:00 2001 From: Etienne Noel Date: Fri, 15 Mar 2024 09:33:39 -0700 Subject: [PATCH] - Update. --- .../security/src/managers/permission.manager.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/security/src/managers/permission.manager.ts b/packages/security/src/managers/permission.manager.ts index ad8eaa937..8e0592e7e 100644 --- a/packages/security/src/managers/permission.manager.ts +++ b/packages/security/src/managers/permission.manager.ts @@ -1,7 +1,7 @@ -import {injectable, injectAll, inject} from "tsyringe"; +import {inject, injectable, injectAll} from "tsyringe"; import {VoterInterface} from "../interfaces/voter.interface"; import {VotingStrategyEnum} from "../enums/voting-strategy.enum"; -import {LogHandler, LogHandlerInterface} from "@pristine-ts/logging"; +import {LogHandlerInterface} from "@pristine-ts/logging"; import {VoteEnum} from "../enums/vote.enum"; import {IdentityInterface, ServiceDefinitionTagEnum} from "@pristine-ts/common"; import {SecurityModuleKeyname} from "../security.module.keyname"; @@ -49,7 +49,15 @@ export class PermissionManager { try { const vote = await voter.vote(identity, action, resource); - this.logHandler.debug("PERMISSION MANAGER - [" + voter.constructor.name + "] - Decision: " + vote, {identity, action, resource, voter: voter.constructor.name}, SecurityModuleKeyname ); + + const message = "PERMISSION MANAGER - [" + voter.constructor.name + "] - Decision: " + vote; + + if(vote === VoteEnum.Deny) { // When it's being denied, it usually mean that something is important to be noticed. + this.logHandler.info(message, {identity, action, resource, voter: voter.constructor.name}, SecurityModuleKeyname) + } + else { + this.logHandler.debug("PERMISSION MANAGER - [" + voter.constructor.name + "] - Decision: " + vote, {identity, action, resource, voter: voter.constructor.name}, SecurityModuleKeyname ); + } votes.push(vote); } catch (error) {