Tweak backend to drive UI
Remove fields for basic user
Fix can list user auth
Modify auth definition & add flags
MODIFY
src/authorization/AuthorizationsDefinition.ts
src/authorization/AuthorizationsDefinition.ts
@@ -1416,10 +1416,7 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
'stop.roundedPrice', 'stop.price', 'stop.priceUnit', 'stop.inactivityStatus', 'stop.stateOfCharge', 'stop.timestamp', 'stop.totalConsumptionWh',
'stop.totalDurationSecs', 'stop.totalInactivitySecs', 'stop.extraInactivitySecs', 'stop.meterStop', 'stop.tagID','stop.tag.visualID', 'stop.reason',
'billingData.stop.invoiceNumber',
- 'tagID', 'tag.visualID', 'tag.description',
- 'site.name', 'siteArea.name', 'company.name',
- 'carID',
- 'carCatalogID', 'carCatalog.vehicleMake', 'carCatalog.vehicleModel', 'carCatalog.vehicleModelVersion',
+ 'site.name', 'siteArea.name', 'company.name'
]
},
{
@@ -1474,7 +1471,8 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
attributes: [
'id', 'chargeBoxID', 'timestamp', 'issuer', 'stateOfCharge', 'timezone', 'connectorId', 'status', 'meterStart', 'siteAreaID', 'siteID', 'companyID',
'currentTotalDurationSecs', 'currentTotalInactivitySecs', 'currentInstantWatts', 'currentTotalConsumptionWh', 'currentStateOfCharge',
- 'currentCumulatedPrice', 'currentInactivityStatus', 'roundedPrice', 'price', 'priceUnit', 'tagID', 'tag.visualID', 'tag.description', 'site.name', 'siteArea.name', 'company.name'
+ 'currentCumulatedPrice', 'currentInactivityStatus', 'roundedPrice', 'price', 'priceUnit',
+ 'site.name', 'siteArea.name', 'company.name'
]
},
{
@@ -1999,7 +1997,7 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
]
},
{
- resource: Entity.TRANSACTION, action: [Action.EXPORT, Action.UPDATE, Action.REMOTE_STOP_TRANSACTION],
+ resource: Entity.TRANSACTION, action: [Action.EXPORT, Action.UPDATE],
condition: {
Fn: 'custom:dynamicAuthorizations',
args: {

MODIFY
src/server/rest/v1/service/AuthorizationService.ts
src/server/rest/v1/service/AuthorizationService.ts
@@ -1161,7 +1161,7 @@ export default class AuthorizationService {
transactions: TransactionDataResult, authorizationFilter: AuthorizationFilter): Promise<void> {
// Add Meta Data
transactions.metadata = authorizationFilter.metadata;
- transactions.canListUsers = await AuthorizationService.canPerformAuthorizationAction(tenant, userToken, Entity.TRANSACTION, Action.LIST, authorizationFilter);
+ transactions.canListUsers = await AuthorizationService.canPerformAuthorizationAction(tenant, userToken, Entity.USER, Action.LIST, authorizationFilter);
transactions.canListSites = await AuthorizationService.canPerformAuthorizationAction(tenant, userToken, Entity.SITE, Action.LIST, authorizationFilter);
transactions.canListSiteAreas = await AuthorizationService.canPerformAuthorizationAction(tenant, userToken, Entity.SITE_AREA, Action.LIST, authorizationFilter);
transactions.canListChargingStations = await AuthorizationService.canPerformAuthorizationAction(tenant, userToken, Entity.CHARGING_STATION, Action.LIST, authorizationFilter);
@@ -1197,6 +1197,12 @@ export default class AuthorizationService {
transaction.canExportOcpiCdr = await AuthorizationService.canPerformAuthorizationAction(
tenant, userToken, Entity.TRANSACTION, Action.EXPORT_OCPI_CDR,
authorizationFilter, { TransactionID: transaction.id, ...dynamicAuthorizationFilter }, transaction);
+ transaction.canListLogs = await this.canPerformAuthorizationAction(tenant, userToken, Entity.LOGGING, Action.LIST,
+ authorizationFilter, { TransactionID: transaction.id, ...dynamicAuthorizationFilter }, transaction);
+ transaction.canListLogs = await this.canPerformAuthorizationAction(tenant, userToken, Entity.LOGGING, Action.LIST,
+ authorizationFilter, { TransactionID: transaction.id, ...dynamicAuthorizationFilter }, transaction);
+ transaction.canReadChargingStation = await this.canPerformAuthorizationAction(tenant, userToken, Entity.CHARGING_STATION, Action.READ,
+ authorizationFilter, { TransactionID: transaction.id, ...dynamicAuthorizationFilter }, transaction);
// Additional auth check for refund
transaction.canRefundTransaction = await AuthorizationService.canPerformAuthorizationAction(
tenant, userToken, Entity.TRANSACTION, Action.REFUND_TRANSACTION,
@@ -1223,7 +1229,7 @@ export default class AuthorizationService {
transactions: TransactionInErrorDataResult, authorizationFilter: AuthorizationFilter): Promise<void> {
// Add Meta Data
transactions.metadata = authorizationFilter.metadata;
- transactions.canListUsers = await AuthorizationService.canPerformAuthorizationAction(tenant, userToken, Entity.TRANSACTION, Action.LIST, authorizationFilter);
+ transactions.canListUsers = await AuthorizationService.canPerformAuthorizationAction(tenant, userToken, Entity.USER, Action.LIST, authorizationFilter);
// Add Authorizations
for (const transaction of transactions.result) {
await AuthorizationService.addTransactionInErrorAuthorizations(tenant, userToken, transaction, authorizationFilter);

MODIFY
src/types/Authorization.ts
src/types/Authorization.ts
@@ -327,6 +327,8 @@ export interface TransactionAuthorizationActions extends AuthorizationActions {
canRemoteStopTransaction?: boolean;
canGetChargingStationTransactions?: boolean;
canExportOcpiCdr?: boolean;
+ canListLogs?: boolean;
+ canReadChargingStation?: boolean;
}
export enum DynamicAuthorizationFilterName {

Tweak backend to drive UI

- Remove fields for basic user
- Fix can list user auth
- Modify auth definition & add flags