From: Jérôme Benoit Date: Fri, 20 Mar 2026 18:49:23 +0000 (+0100) Subject: fix(auth): log actual station OCPP version in RemoteAuthStrategy X-Git-Tag: ocpp-server@v3.2.0~20 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=969112652f4a8dcc8e5d1946a6659202a3f96017;p=e-mobility-charging-stations-simulator.git fix(auth): log actual station OCPP version in RemoteAuthStrategy Deduplicate adapter validation in initialize() to avoid logging the same adapter twice for VERSION_20/VERSION_201 aliases. Add ocppVersion to AuthConfiguration so strategies log the station's configured version instead of internal map keys. --- diff --git a/src/charging-station/ocpp/auth/services/OCPPAuthServiceImpl.ts b/src/charging-station/ocpp/auth/services/OCPPAuthServiceImpl.ts index ac08d8bd..776050a3 100644 --- a/src/charging-station/ocpp/auth/services/OCPPAuthServiceImpl.ts +++ b/src/charging-station/ocpp/auth/services/OCPPAuthServiceImpl.ts @@ -651,6 +651,7 @@ export class OCPPAuthServiceImpl implements OCPPAuthService { localAuthListEnabled: true, localPreAuthorize: false, maxCacheEntries: 1000, + ocppVersion: this.chargingStation.stationInfo?.ocppVersion, offlineAuthorizationEnabled: true, remoteAuthorization: true, unknownIdAuthorization: AuthorizationStatus.INVALID, diff --git a/src/charging-station/ocpp/auth/strategies/RemoteAuthStrategy.ts b/src/charging-station/ocpp/auth/strategies/RemoteAuthStrategy.ts index c60a44d1..82135f70 100644 --- a/src/charging-station/ocpp/auth/strategies/RemoteAuthStrategy.ts +++ b/src/charging-station/ocpp/auth/strategies/RemoteAuthStrategy.ts @@ -266,19 +266,27 @@ export class RemoteAuthStrategy implements AuthStrategy { logger.warn(`${moduleName}: No OCPP adapters provided`) } - // Validate adapter configurations - for (const [version, adapter] of this.adapters) { + const stationVersion = config.ocppVersion ?? 'unknown' + + // Validate adapter configurations (deduplicate by instance to avoid + // validating the same adapter twice for VERSION_20 and VERSION_201) + const validatedAdapters = new Set() + for (const [, adapter] of this.adapters) { + if (validatedAdapters.has(adapter)) { + continue + } + validatedAdapters.add(adapter) try { const isValid = adapter.validateConfiguration(config) if (!isValid) { - logger.warn(`${moduleName}: Invalid configuration for OCPP ${version}`) + logger.warn(`${moduleName}: Invalid configuration for OCPP ${stationVersion}`) } else { - logger.debug(`${moduleName}: OCPP ${version} adapter configured`) + logger.debug(`${moduleName}: OCPP ${stationVersion} adapter configured`) } } catch (error) { const errorMessage = getErrorMessage(error) logger.error( - `${moduleName}: Configuration validation failed for OCPP ${version}: ${errorMessage}` + `${moduleName}: Configuration validation failed for OCPP ${stationVersion}: ${errorMessage}` ) } } diff --git a/src/charging-station/ocpp/auth/types/AuthTypes.ts b/src/charging-station/ocpp/auth/types/AuthTypes.ts index 2f7d7bce..e71823e2 100644 --- a/src/charging-station/ocpp/auth/types/AuthTypes.ts +++ b/src/charging-station/ocpp/auth/types/AuthTypes.ts @@ -137,6 +137,9 @@ export interface AuthConfiguration extends JsonObject { /** Maximum cache entries */ maxCacheEntries?: number + /** OCPP protocol version configured on the charging station */ + ocppVersion?: string + /** Enable offline authorization */ offlineAuthorizationEnabled: boolean