]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
refactor(log): quote and truncate all auth identifiers in log messages
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 31 Mar 2026 22:34:20 +0000 (00:34 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 31 Mar 2026 22:34:20 +0000 (00:34 +0200)
Wrap all idTag/idToken/identifier values in single quotes and apply
truncateId() consistently across OCPP 1.6, 2.0, and auth module log
messages. Removes eslint-disable comments for restrict-template-expressions
where ?? '' fallback eliminates the type issue.

12 files changed:
src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts
src/charging-station/ocpp/1.6/OCPP16ResponseService.ts
src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts
src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts
src/charging-station/ocpp/IdTagAuthorization.ts
src/charging-station/ocpp/auth/adapters/OCPP16AuthAdapter.ts
src/charging-station/ocpp/auth/adapters/OCPP20AuthAdapter.ts
src/charging-station/ocpp/auth/cache/InMemoryAuthCache.ts
src/charging-station/ocpp/auth/services/OCPPAuthServiceImpl.ts
src/charging-station/ocpp/auth/strategies/LocalAuthStrategy.ts
src/charging-station/ocpp/auth/strategies/RemoteAuthStrategy.ts
src/charging-station/ocpp/auth/utils/AuthHelpers.ts

index 02a33d5382675f8e5eeedd2acd7269afa8ec2dfa..eeb7655cdd3f0ea784b4dd49790171958a84855b 100644 (file)
@@ -291,7 +291,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
                     // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
                     chargingStation.stationInfo?.chargingStationId
                     // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
-                  }#${connectorId?.toString()} for idTag '${idTag}'`
+                  }#${connectorId?.toString()} for idTag '${truncateId(idTag)}'`
                 )
               } else {
                 logger.debug(
@@ -299,7 +299,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
                     // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
                     chargingStation.stationInfo?.chargingStationId
                     // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
-                  }#${connectorId?.toString()} for idTag '${idTag}'`
+                  }#${connectorId?.toString()} for idTag '${truncateId(idTag)}'`
                 )
               }
               return undefined
@@ -1297,7 +1297,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
       `${chargingStation.logPrefix()} ${moduleName}.handleRequestRemoteStartTransaction: Remote start transaction ACCEPTED on ${
         // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
         chargingStation.stationInfo?.chargingStationId
-      }#${transactionConnectorId.toString()}, idTag '${idTag}'`
+      }#${transactionConnectorId.toString()}, idTag '${truncateId(idTag)}'`
     )
     return OCPP16Constants.OCPP_RESPONSE_ACCEPTED
   }
@@ -1617,7 +1617,7 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
       `${chargingStation.logPrefix()} ${moduleName}.notifyRemoteStartTransactionRejected: Remote start transaction REJECTED on ${
         // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
         chargingStation.stationInfo?.chargingStationId
-      }#${connectorId.toString()}, idTag '${idTag}', availability '${
+      }#${connectorId.toString()}, idTag '${truncateId(idTag)}', availability '${
         // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
         connectorStatus?.availability
         // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
index 50f37e87630677ae3a77c69a598046472a3cb7c2..9ecc9d299b64819c4d6dadd7faa7908bc97f6c36 100644 (file)
@@ -172,9 +172,9 @@ export class OCPP16ResponseService extends OCPPResponseService {
         if (payload.idTagInfo.status === OCPP16AuthorizationStatus.ACCEPTED) {
           authorizeConnectorStatus.idTagAuthorized = true
           logger.debug(
-            `${chargingStation.logPrefix()} ${moduleName}.handleResponseAuthorize: idTag '${
+            `${chargingStation.logPrefix()} ${moduleName}.handleResponseAuthorize: idTag '${truncateId(
               requestPayload.idTag
-            }' accepted on connector id ${authorizeConnectorId.toString()}`
+            )}' accepted on connector id ${authorizeConnectorId.toString()}`
           )
         } else {
           authorizeConnectorStatus.idTagAuthorized = false
@@ -188,9 +188,9 @@ export class OCPP16ResponseService extends OCPPResponseService {
       }
     } else {
       logger.warn(
-        `${chargingStation.logPrefix()} ${moduleName}.handleResponseAuthorize: idTag '${
+        `${chargingStation.logPrefix()} ${moduleName}.handleResponseAuthorize: idTag '${truncateId(
           requestPayload.idTag
-        }' has no authorize request pending`
+        )}' has no authorize request pending`
       )
     }
     OCPP16ServiceUtils.updateAuthorizationCache(
@@ -278,10 +278,9 @@ export class OCPP16ResponseService extends OCPPResponseService {
       connectorStatus.idTagLocalAuthorized === false
     ) {
       logger.warn(
-        `${chargingStation.logPrefix()} ${moduleName}.handleResponseStartTransaction: Trying to start a transaction with a not local authorized idTag ${
-          // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
-          connectorStatus.localAuthorizeIdTag
-        } on connector id ${connectorId.toString()}`
+        `${chargingStation.logPrefix()} ${moduleName}.handleResponseStartTransaction: Trying to start a transaction with a not local authorized idTag '${truncateId(
+          connectorStatus.localAuthorizeIdTag ?? ''
+        )}' on connector id ${connectorId.toString()}`
       )
       await this.resetConnectorOnStartTransactionError(chargingStation, connectorId)
       return
@@ -294,10 +293,9 @@ export class OCPP16ResponseService extends OCPPResponseService {
       connectorStatus.idTagAuthorized === false
     ) {
       logger.warn(
-        `${chargingStation.logPrefix()} ${moduleName}.handleResponseStartTransaction: Trying to start a transaction with a not authorized idTag ${
-          // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
-          connectorStatus.authorizeIdTag
-        } on connector id ${connectorId.toString()}`
+        `${chargingStation.logPrefix()} ${moduleName}.handleResponseStartTransaction: Trying to start a transaction with a not authorized idTag '${truncateId(
+          connectorStatus.authorizeIdTag ?? ''
+        )}' on connector id ${connectorId.toString()}`
       )
       await this.resetConnectorOnStartTransactionError(chargingStation, connectorId)
       return
@@ -308,11 +306,11 @@ export class OCPP16ResponseService extends OCPPResponseService {
       connectorStatus.authorizeIdTag !== requestPayload.idTag
     ) {
       logger.warn(
-        `${chargingStation.logPrefix()} ${moduleName}.handleResponseStartTransaction: Trying to start a transaction with an idTag ${
+        `${chargingStation.logPrefix()} ${moduleName}.handleResponseStartTransaction: Trying to start a transaction with an idTag '${truncateId(
           requestPayload.idTag
-        } different from the authorize request one ${
-          connectorStatus.authorizeIdTag
-        } on connector id ${connectorId.toString()}`
+        )}' different from the authorize request one '${truncateId(
+          connectorStatus.authorizeIdTag ?? ''
+        )}' on connector id ${connectorId.toString()}`
       )
       await this.resetConnectorOnStartTransactionError(chargingStation, connectorId)
       return
@@ -323,21 +321,20 @@ export class OCPP16ResponseService extends OCPPResponseService {
       connectorStatus.localAuthorizeIdTag !== requestPayload.idTag
     ) {
       logger.warn(
-        `${chargingStation.logPrefix()} ${moduleName}.handleResponseStartTransaction: Trying to start a transaction with an idTag ${
+        `${chargingStation.logPrefix()} ${moduleName}.handleResponseStartTransaction: Trying to start a transaction with an idTag '${truncateId(
           requestPayload.idTag
-        } different from the local authorized one ${
-          connectorStatus.localAuthorizeIdTag
-        } on connector id ${connectorId.toString()}`
+        )}' different from the local authorized one '${truncateId(
+          connectorStatus.localAuthorizeIdTag ?? ''
+        )}' on connector id ${connectorId.toString()}`
       )
       await this.resetConnectorOnStartTransactionError(chargingStation, connectorId)
       return
     }
     if (connectorStatus?.transactionStarted === true) {
       logger.warn(
-        `${chargingStation.logPrefix()} ${moduleName}.handleResponseStartTransaction: Trying to start a transaction on an already used connector id ${connectorId.toString()} by idTag ${
-          // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
-          connectorStatus.transactionIdTag
-        }`
+        `${chargingStation.logPrefix()} ${moduleName}.handleResponseStartTransaction: Trying to start a transaction on an already used connector id ${connectorId.toString()} by idTag '${truncateId(
+          connectorStatus.transactionIdTag ?? ''
+        )}'`
       )
       return
     }
@@ -347,10 +344,9 @@ export class OCPP16ResponseService extends OCPPResponseService {
           for (const [id, status] of evseStatus.connectors) {
             if (id !== connectorId && status.transactionStarted === true) {
               logger.warn(
-                `${chargingStation.logPrefix()} ${moduleName}.handleResponseStartTransaction: Trying to start a transaction on an already used evse id ${evseId.toString()} by connector id ${id.toString()} with idTag ${
-                  // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
-                  status.transactionIdTag
-                }`
+                `${chargingStation.logPrefix()} ${moduleName}.handleResponseStartTransaction: Trying to start a transaction on an already used evse id ${evseId.toString()} by connector id ${id.toString()} with idTag '${truncateId(
+                  status.transactionIdTag ?? ''
+                )}'`
               )
               await this.resetConnectorOnStartTransactionError(chargingStation, connectorId)
               return
@@ -399,9 +395,9 @@ export class OCPP16ResponseService extends OCPPResponseService {
         if (reservation != null) {
           if (reservation.idTag !== requestPayload.idTag) {
             logger.warn(
-              `${chargingStation.logPrefix()} ${moduleName}.handleResponseStartTransaction: Reserved transaction ${payload.transactionId.toString()} started with a different idTag ${truncateId(
+              `${chargingStation.logPrefix()} ${moduleName}.handleResponseStartTransaction: Reserved transaction ${payload.transactionId.toString()} started with a different idTag '${truncateId(
                 requestPayload.idTag
-              )} than the reservation one ${truncateId(reservation.idTag)}`
+              )}' than the reservation one '${truncateId(reservation.idTag)}'`
             )
           }
           if (hasReservationExpired(reservation)) {
index 718e2460df23cce351d6f0132c2cc60284da2ae0..b7840fdb46f361257a5048f4caa9a968e7dfb524 100644 (file)
@@ -620,7 +620,7 @@ export class OCPP16ServiceUtils {
         chargingStationReservation.idTag === idTag)
     ) {
       logger.debug(
-        `${chargingStation.logPrefix()} ${moduleName}.hasReservation: Connector id ${connectorId.toString()} has a valid reservation for idTag ${idTag}: %j`,
+        `${chargingStation.logPrefix()} ${moduleName}.hasReservation: Connector id ${connectorId.toString()} has a valid reservation for idTag '${truncateId(idTag)}': %j`,
         connectorReservation ?? chargingStationReservation
       )
       return true
index 9b0df3f69be27757683904d8146abf33d9f4ade6..58056fa7e2b4c277cb620ab492098efbdbc05e58 100644 (file)
@@ -834,7 +834,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
 
     if (authResult.status !== AuthorizationStatus.ACCEPTED) {
       logger.warn(
-        `${chargingStation.logPrefix()} ${moduleName}.authorizeToken: ${tokenLabel} ${truncateId(tokenValue)} is not authorized`
+        `${chargingStation.logPrefix()} ${moduleName}.authorizeToken: ${tokenLabel} '${truncateId(tokenValue)}' is not authorized`
       )
     }
 
@@ -2294,7 +2294,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
   ): Promise<OCPP20RequestStartTransactionResponse> {
     const { chargingProfile, evseId, groupIdToken, idToken, remoteStartId } = commandPayload
     logger.info(
-      `${chargingStation.logPrefix()} ${moduleName}.handleRequestStartTransaction: Remote start transaction request received on EVSE ${evseId?.toString() ?? 'undefined'} with idToken ${truncateId(idToken.idToken)} and remoteStartId ${remoteStartId.toString()}`
+      `${chargingStation.logPrefix()} ${moduleName}.handleRequestStartTransaction: Remote start transaction request received on EVSE ${evseId?.toString() ?? 'undefined'} with idToken '${truncateId(idToken.idToken)}' and remoteStartId ${remoteStartId.toString()}`
     )
 
     let resolvedEvseId = evseId
@@ -2415,7 +2415,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
         )
       } catch (error) {
         logger.error(
-          `${chargingStation.logPrefix()} ${moduleName}.handleRequestStartTransaction: Authorization error for ${truncateId(idToken.idToken)}:`,
+          `${chargingStation.logPrefix()} ${moduleName}.handleRequestStartTransaction: Authorization error for '${truncateId(idToken.idToken)}':`,
           error
         )
         return {
@@ -2437,7 +2437,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
       return {
         status: RequestStartStopStatusEnumType.Rejected,
         statusInfo: {
-          additionalInfo: `IdToken ${truncateId(idToken.idToken)} is not authorized`,
+          additionalInfo: `IdToken '${truncateId(idToken.idToken)}' is not authorized`,
           reasonCode: ReasonCodeEnumType.InvalidIdToken,
         },
         transactionId: generateUUID(),
@@ -2456,7 +2456,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
         )
       } catch (error) {
         logger.error(
-          `${chargingStation.logPrefix()} ${moduleName}.handleRequestStartTransaction: Group authorization error for ${truncateId(groupIdToken.idToken)}:`,
+          `${chargingStation.logPrefix()} ${moduleName}.handleRequestStartTransaction: Group authorization error for '${truncateId(groupIdToken.idToken)}':`,
           error
         )
         return {
@@ -2472,7 +2472,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
         return {
           status: RequestStartStopStatusEnumType.Rejected,
           statusInfo: {
-            additionalInfo: `GroupIdToken ${truncateId(groupIdToken.idToken)} is not authorized`,
+            additionalInfo: `GroupIdToken '${truncateId(groupIdToken.idToken)}' is not authorized`,
             reasonCode: ReasonCodeEnumType.InvalidIdToken,
           },
           transactionId: generateUUID(),
@@ -2977,7 +2977,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
     }
 
     logger.debug(
-      `${chargingStation.logPrefix()} ${moduleName}.isAuthorizedToStopTransaction: IdToken ${truncateId(presentedIdToken.idToken)} not authorized to stop transaction on connector ${connectorId.toString()}`
+      `${chargingStation.logPrefix()} ${moduleName}.isAuthorizedToStopTransaction: IdToken '${truncateId(presentedIdToken.idToken)}' not authorized to stop transaction on connector ${connectorId.toString()}`
     )
     return false
   }
index 0412fdd4b85b8111a37526211045112f246beecf..8520c4588032878306e040971f55f48e7883ed5c 100644 (file)
@@ -1,6 +1,6 @@
 import type { ChargingStation } from '../../charging-station/index.js'
 
-import { logger } from '../../utils/index.js'
+import { logger, truncateId } from '../../utils/index.js'
 import {
   AuthContext,
   AuthenticationMethod,
@@ -17,7 +17,7 @@ export const isIdTagAuthorized = async (
 ): Promise<boolean> => {
   try {
     logger.debug(
-      `${chargingStation.logPrefix()} Authorizing idTag '${idTag}' on connector ${connectorId.toString()}`
+      `${chargingStation.logPrefix()} Authorizing idTag '${truncateId(idTag)}' on connector ${connectorId.toString()}`
     )
 
     const authService = OCPPAuthServiceFactory.getInstance(chargingStation)
@@ -34,7 +34,7 @@ export const isIdTagAuthorized = async (
     })
 
     logger.debug(
-      `${chargingStation.logPrefix()} Authorization result for idTag '${idTag}': ${authResult.status} using ${authResult.method} method`
+      `${chargingStation.logPrefix()} Authorization result for idTag '${truncateId(idTag)}': ${authResult.status} using ${authResult.method} method`
     )
 
     if (authResult.status === AuthorizationStatus.ACCEPTED) {
index 9ed202d6bfee169282a236d183598baedd52f876..fb90d924c1b2f52ff5349d5d7292d3652840353e 100644 (file)
@@ -56,7 +56,7 @@ export class OCPP16AuthAdapter implements OCPPAuthAdapter<string> {
 
     try {
       logger.debug(
-        `${this.chargingStation.logPrefix()} ${moduleName}.${methodName}: Authorizing identifier ${truncateId(identifier.value)} via OCPP 1.6`
+        `${this.chargingStation.logPrefix()} ${moduleName}.${methodName}: Authorizing identifier '${truncateId(identifier.value)}' via OCPP 1.6`
       )
 
       // Mark connector as authorizing if provided
index ef4ffabce280792b16e51481489f96afb50dc7bf..2e4df2d81a77c3877a8a8764c1636320337c003c 100644 (file)
@@ -65,7 +65,7 @@ export class OCPP20AuthAdapter implements OCPPAuthAdapter<OCPP20IdTokenType> {
 
     try {
       logger.debug(
-        `${this.chargingStation.logPrefix()} ${moduleName}.${methodName}: Authorizing identifier ${truncateId(identifier.value)} via OCPP 2.0 Authorize`
+        `${this.chargingStation.logPrefix()} ${moduleName}.${methodName}: Authorizing identifier '${truncateId(identifier.value)}' via OCPP 2.0 Authorize`
       )
 
       const isRemoteAuth = this.isRemoteAvailable()
index aa6bbf4b8ead531ac916772e5e8da8f957354835..5698c03de41d5ac060d3b7618e361d74c8aad7be 100644 (file)
@@ -171,7 +171,7 @@ export class InMemoryAuthCache implements AuthCache {
     // Check rate limiting first
     if (!this.checkRateLimit(identifier)) {
       this.stats.rateLimitBlocked++
-      logger.warn(`${moduleName}: Rate limit exceeded for identifier: ${truncateId(identifier)}`)
+      logger.warn(`${moduleName}: Rate limit exceeded for identifier: '${truncateId(identifier)}'`)
       return undefined
     }
 
@@ -198,7 +198,7 @@ export class InMemoryAuthCache implements AuthCache {
       }
       this.lruOrder.set(identifier, now)
       logger.debug(
-        `${moduleName}: Expired entry transitioned to EXPIRED for identifier: ${truncateId(identifier)}`
+        `${moduleName}: Expired entry transitioned to EXPIRED for identifier: '${truncateId(identifier)}'`
       )
       return authCacheEntry.result
     }
@@ -216,7 +216,7 @@ export class InMemoryAuthCache implements AuthCache {
       authCacheEntry.expiresAt = now + this.defaultTtl * 1000
     }
 
-    logger.debug(`${moduleName}: Cache hit for identifier: ${truncateId(identifier)}`)
+    logger.debug(`${moduleName}: Cache hit for identifier: '${truncateId(identifier)}'`)
     return authCacheEntry.result
   }
 
@@ -264,7 +264,7 @@ export class InMemoryAuthCache implements AuthCache {
     this.lruOrder.delete(identifier)
 
     if (deleted) {
-      logger.debug(`${moduleName}: Removed entry for identifier: ${truncateId(identifier)}`)
+      logger.debug(`${moduleName}: Removed entry for identifier: '${truncateId(identifier)}'`)
     }
   }
 
@@ -318,7 +318,7 @@ export class InMemoryAuthCache implements AuthCache {
     if (!this.checkRateLimit(identifier)) {
       this.stats.rateLimitBlocked++
       logger.warn(
-        `${moduleName}: Rate limit exceeded, not caching identifier: ${truncateId(identifier)}`
+        `${moduleName}: Rate limit exceeded, not caching identifier: '${truncateId(identifier)}'`
       )
       return
     }
@@ -344,7 +344,7 @@ export class InMemoryAuthCache implements AuthCache {
     this.stats.sets++
 
     logger.debug(
-      `${moduleName}: Cached result for identifier: ${truncateId(identifier)}, ttl=${String(clampedTtl)}s, entries=${String(this.cache.size)}/${String(this.maxEntries)}`
+      `${moduleName}: Cached result for identifier: '${truncateId(identifier)}', ttl=${String(clampedTtl)}s, entries=${String(this.cache.size)}/${String(this.maxEntries)}`
     )
   }
 
@@ -452,7 +452,7 @@ export class InMemoryAuthCache implements AuthCache {
       this.cache.delete(candidateIdentifier)
       this.lruOrder.delete(candidateIdentifier)
       this.stats.evictions++
-      logger.debug(`${moduleName}: Evicted LRU entry: ${truncateId(candidateIdentifier)}`)
+      logger.debug(`${moduleName}: Evicted LRU entry: '${truncateId(candidateIdentifier)}'`)
     }
   }
 }
index ca6ac2177b7d15e59c020613b4ffda36f434531a..bbd3e23c3470caf4b47156e845c2837961a8ae02 100644 (file)
@@ -88,7 +88,7 @@ export class OCPPAuthServiceImpl implements OCPPAuthService {
     this.metrics.totalRequests++
 
     logger.debug(
-      `${this.chargingStation.logPrefix()} ${moduleName}.authenticate: Starting authentication for identifier: ${truncateId(request.identifier.value)}`
+      `${this.chargingStation.logPrefix()} ${moduleName}.authenticate: Starting authentication for identifier: '${truncateId(request.identifier.value)}'`
     )
 
     // Try each strategy in priority order
@@ -372,7 +372,7 @@ export class OCPPAuthServiceImpl implements OCPPAuthService {
     }
     this.authCache.remove(identifier.value)
     logger.info(
-      `${this.chargingStation.logPrefix()} ${moduleName}.invalidateCache: Cache invalidated for identifier: ${truncateId(identifier.value)}`
+      `${this.chargingStation.logPrefix()} ${moduleName}.invalidateCache: Cache invalidated for identifier: '${truncateId(identifier.value)}'`
     )
   }
 
@@ -492,7 +492,7 @@ export class OCPPAuthServiceImpl implements OCPPAuthService {
         const ttlSeconds = Math.floor((expiry.getTime() - Date.now()) / 1000)
         if (ttlSeconds <= 0) {
           logger.debug(
-            `${this.chargingStation.logPrefix()} ${moduleName}.updateCacheEntry: Skipping expired entry for ${truncateId(identifier)}`
+            `${this.chargingStation.logPrefix()} ${moduleName}.updateCacheEntry: Skipping expired entry for '${truncateId(identifier)}'`
           )
           return
         }
@@ -511,7 +511,7 @@ export class OCPPAuthServiceImpl implements OCPPAuthService {
     this.authCache.set(identifier, result, effectiveTtl)
 
     logger.debug(
-      `${this.chargingStation.logPrefix()} ${moduleName}.updateCacheEntry: Updated cache for ${truncateId(identifier)} status=${status}${effectiveTtl != null ? `, ttl=${effectiveTtl.toString()}s` : ''}`
+      `${this.chargingStation.logPrefix()} ${moduleName}.updateCacheEntry: Updated cache for '${truncateId(identifier)}' status=${status}${effectiveTtl != null ? `, ttl=${effectiveTtl.toString()}s` : ''}`
     )
   }
 
index b6f97b8712bf3c950f08f70b2b6b5b68ae43604d..3b9550992733a57a4b7e2eaee42d094761237f78 100644 (file)
@@ -72,7 +72,7 @@ export class LocalAuthStrategy implements AuthStrategy {
 
     try {
       logger.debug(
-        `${moduleName}: Authenticating ${truncateId(request.identifier.value)} for ${request.context}`
+        `${moduleName}: Authenticating '${truncateId(request.identifier.value)}' for ${request.context}`
       )
 
       // 1. Try local authorization list first (highest priority)
@@ -130,7 +130,7 @@ export class LocalAuthStrategy implements AuthStrategy {
       }
 
       logger.debug(
-        `${moduleName}: No local authorization found for ${truncateId(request.identifier.value)}`
+        `${moduleName}: No local authorization found for '${truncateId(request.identifier.value)}'`
       )
       return undefined
     } catch (error) {
@@ -163,7 +163,7 @@ export class LocalAuthStrategy implements AuthStrategy {
 
     try {
       this.authCache.set(identifier, result, ttl)
-      logger.debug(`${moduleName}: Cached result for ${truncateId(identifier)}`)
+      logger.debug(`${moduleName}: Cached result for '${truncateId(identifier)}'`)
     } catch (error) {
       const errorMessage = getErrorMessage(error)
       logger.error(`${moduleName}: Failed to cache result: ${errorMessage}`)
@@ -288,7 +288,7 @@ export class LocalAuthStrategy implements AuthStrategy {
 
     try {
       this.authCache.remove(identifier)
-      logger.debug(`${moduleName}: Invalidated cache for ${truncateId(identifier)}`)
+      logger.debug(`${moduleName}: Invalidated cache for '${truncateId(identifier)}'`)
     } catch (error) {
       const errorMessage = getErrorMessage(error)
       logger.error(`${moduleName}: Failed to invalidate cache: ${errorMessage}`)
@@ -352,7 +352,7 @@ export class LocalAuthStrategy implements AuthStrategy {
         return undefined
       }
 
-      logger.debug(`${moduleName}: Cache hit for ${truncateId(request.identifier.value)}`)
+      logger.debug(`${moduleName}: Cache hit for '${truncateId(request.identifier.value)}'`)
       return cachedResult
     } catch (error) {
       const errorMessage = getErrorMessage(error)
@@ -390,7 +390,7 @@ export class LocalAuthStrategy implements AuthStrategy {
 
       // Check if entry is expired
       if (entry.expiryDate && entry.expiryDate < new Date()) {
-        logger.debug(`${moduleName}: Entry ${truncateId(request.identifier.value)} expired`)
+        logger.debug(`${moduleName}: Entry '${truncateId(request.identifier.value)}' expired`)
         return {
           expiryDate: entry.expiryDate,
           isOffline: false,
@@ -437,7 +437,7 @@ export class LocalAuthStrategy implements AuthStrategy {
     config: AuthConfiguration
   ): AuthorizationResult | undefined {
     logger.debug(
-      `${moduleName}: Applying offline fallback for ${truncateId(request.identifier.value)}`
+      `${moduleName}: Applying offline fallback for '${truncateId(request.identifier.value)}'`
     )
 
     // For transaction stops, always allow (safety requirement)
index acf185a62ea26eca66a8afbf717ee767989cdeea..7cf28b9b77042b4ada69c990d3137505f1774bbe 100644 (file)
@@ -88,7 +88,7 @@ export class RemoteAuthStrategy implements AuthStrategy {
 
     try {
       logger.debug(
-        `${moduleName}: Authenticating ${truncateId(request.identifier.value)} via CSMS for ${request.context}`
+        `${moduleName}: Authenticating '${truncateId(request.identifier.value)}' via CSMS for ${request.context}`
       )
 
       // Get adapter
@@ -119,7 +119,7 @@ export class RemoteAuthStrategy implements AuthStrategy {
           const isInLocalList = await this.localAuthListManager.getEntry(request.identifier.value)
           if (isInLocalList) {
             logger.debug(
-              `${moduleName}: Skipping cache for local list identifier: ${truncateId(request.identifier.value)}`
+              `${moduleName}: Skipping cache for local list identifier: '${truncateId(request.identifier.value)}'`
             )
           } else {
             this.cacheResult(
@@ -147,7 +147,7 @@ export class RemoteAuthStrategy implements AuthStrategy {
       }
 
       logger.debug(
-        `${moduleName}: No remote authorization result for ${truncateId(request.identifier.value)}`
+        `${moduleName}: No remote authorization result for '${truncateId(request.identifier.value)}'`
       )
       return undefined
     } catch (error) {
@@ -379,7 +379,7 @@ export class RemoteAuthStrategy implements AuthStrategy {
       const cacheTtl = ttl ?? result.cacheTtl ?? 300 // Default 5 minutes
       this.authCache.set(identifier, result, cacheTtl)
       logger.debug(
-        `${moduleName}: Cached result for ${truncateId(identifier)} (TTL: ${String(cacheTtl)}s)`
+        `${moduleName}: Cached result for '${truncateId(identifier)}' (TTL: ${String(cacheTtl)}s)`
       )
     } catch (error) {
       const errorMessage = getErrorMessage(error)
index de0a5435faeaf431fcac0afe70f62c3d5545b503..61cede25b075e0c42ab3186bb15a3a49e93aaf29 100644 (file)
@@ -80,7 +80,7 @@ function createRejectedResult (
  * @returns Formatted error string with truncated identifier
  */
 function formatAuthError (error: Error, identifier: Identifier): string {
-  return `Authentication failed for identifier ${truncateId(identifier.value)} (${identifier.type}): ${error.message}`
+  return `Authentication failed for identifier '${truncateId(identifier.value)}' (${identifier.type}): ${error.message}`
 }
 
 /**