Remove assert logs when not authorized
* Remove assert logs when not authorized
* fix handleExportChargingStationsOCPPParams
we require site and siteArea in excel
MODIFY
src/server/rest/v1/service/AuthorizationService.ts
src/server/rest/v1/service/AuthorizationService.ts
@@ -1206,8 +1206,8 @@ export default class AuthorizationService {
}
}
- private static async processDynamicAsserts(tenant: Tenant, userToken: UserToken, authAction: Action, authEntity: Entity,
- authorizationFilters: AuthorizationFilter, authorizationContext: AuthorizationContext, entityData?: EntityData): Promise<void> {
+ private static processDynamicAsserts(tenant: Tenant, userToken: UserToken, authAction: Action, authEntity: Entity,
+ authorizationFilters: AuthorizationFilter, authorizationContext: AuthorizationContext, entityData?: EntityData): void {
if (entityData && !Utils.isEmptyArray(authorizationContext.asserts)) {
// First array is an AND between assertions
for (let assertsToProcess of authorizationContext.asserts) {
@@ -1237,15 +1237,6 @@ export default class AuthorizationService {
if (dynamicAssert.isNegateAssert()) {
authorizationFilters.authorized = !authorizationFilters.authorized;
}
- if (!authorizationFilters.authorized) {
- await Logging.logError({
- tenantID: tenant.id,
- user: userToken,
- module: MODULE_NAME, method: 'processDynamicAsserts',
- message: `Dynamic Authorization '${assertToProcess}' did not allow to perform '${authAction}' on '${authEntity}'`,
- action: ServerAction.AUTHORIZATIONS
- });
- }
authorized = authorized || authorizationFilters.authorized;
}
// Assign
@@ -1283,7 +1274,7 @@ export default class AuthorizationService {
// Keep the Meta Data
authorizationFilters.metadata = authResult.context.metadata;
// Process Dynamic Assertions
- await AuthorizationService.processDynamicAsserts(tenant, userToken, authAction, authEntity,
+ AuthorizationService.processDynamicAsserts(tenant, userToken, authAction, authEntity,
authorizationFilters, authorizationContext, entityData);
}
// Filter projected fields
@@ -1326,7 +1317,7 @@ export default class AuthorizationService {
// Keep the Meta Data
authorizations.metadata = authResult.context.metadata;
// Process Dynamic Assertions
- await AuthorizationService.processDynamicAsserts(tenant, userToken, authAction, authEntity,
+ AuthorizationService.processDynamicAsserts(tenant, userToken, authAction, authEntity,
authorizations, authorizationContext, entityData);
if (!authorizations.authorized) {
throw new AppAuthError({

MODIFY
src/server/rest/v1/service/ChargingStationService.ts
src/server/rest/v1/service/ChargingStationService.ts
@@ -434,7 +434,7 @@ export default class ChargingStationService {
const filteredRequest = ChargingStationValidatorRest.getInstance().validateChargingStationsGetReq(req.query);
// Check and get charging stations: site and siteArea are mandatory
const chargingStations = await ChargingStationService.getChargingStations(req, filteredRequest, Action.EXPORT,
- { withSite: filteredRequest.WithSite, withSiteArea: filteredRequest.WithSiteArea });
+ { withSite: true, withSiteArea: true });
// Set the attachment name
res.attachment('exported-ocpp-params.csv');
let writeHeader = true;

Remove assert logs when not authorized (#3700)

* Remove assert logs when not authorized

* fix handleExportChargingStationsOCPPParams

- we require site and siteArea in excel