Update auth definition
Remove actions for basic and demo
Update projected fields & filters: push/export CDR
Add flags to drive UI
MODIFY
src/authorization/AuthorizationsDefinition.ts
src/authorization/AuthorizationsDefinition.ts
@@ -594,7 +594,7 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
Fn: 'custom:dynamicAuthorizations',
args: {
asserts: [],
- filters: ['AssignedSites']
+ filters: []
}
},
attributes: [
@@ -1415,6 +1415,8 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
'currentCumulatedPrice', 'currentInactivityStatus', 'roundedPrice', 'price', 'priceUnit', 'ocpi', 'ocpiWithCdr',
'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',
+ 'carCatalog.vehicleMake', 'carCatalog.vehicleModel', 'carCatalog.vehicleModelVersion',
+ 'car.licensePlate',
'billingData.stop.invoiceNumber',
'site.name', 'siteArea.name', 'company.name'
]
@@ -1472,7 +1474,9 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
'id', 'chargeBoxID', 'timestamp', 'issuer', 'stateOfCharge', 'timezone', 'connectorId', 'status', 'meterStart', 'siteAreaID', 'siteID', 'companyID',
'currentTotalDurationSecs', 'currentTotalInactivitySecs', 'currentInstantWatts', 'currentTotalConsumptionWh', 'currentStateOfCharge',
'currentCumulatedPrice', 'currentInactivityStatus', 'roundedPrice', 'price', 'priceUnit',
- 'site.name', 'siteArea.name', 'company.name'
+ 'carCatalog.vehicleMake', 'carCatalog.vehicleModel', 'carCatalog.vehicleModelVersion',
+ 'site.name', 'siteArea.name', 'company.name',
+ 'car.licensePlate',
]
},
{
@@ -1490,6 +1494,9 @@ 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', 'billingData.stop.invoiceNumber',
'tagID', 'stop.tagID', 'stop.reason',
+ 'carCatalog.vehicleMake', 'carCatalog.vehicleModel', 'carCatalog.vehicleModelVersion',
+ 'car.licensePlate',
+
]
},
{
@@ -1504,9 +1511,11 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
attributes: [
'id', 'chargeBoxID', 'timestamp', 'issuer', 'stateOfCharge', 'timezone', 'connectorId', 'meterStart', 'siteAreaID', 'siteID', 'companyID',
'stop.roundedPrice', 'stop.price', 'stop.priceUnit', 'stop.inactivityStatus', 'stop.stateOfCharge', 'stop.timestamp', 'stop.totalConsumptionWh',
- 'stop.totalDurationSecs', 'stop.totalInactivitySecs', 'stop.extraInactivitySecs', 'stop.meterStop',
+ 'stop.totalDurationSecs', 'stop.totalInactivitySecs', 'stop.extraInactivitySecs', 'stop.meterStop', 'stop.tagID', 'stop.tag.visualID', 'stop.reason',
'site.name', 'siteArea.name', 'company.name',
- 'billingData.stop.invoiceNumber', 'stop.reason', 'ocpi', 'ocpiWithCdr', 'tagID', 'tag.visualID', 'tag.description', 'stop.tagID', 'stop.tag.visualID'
+ 'carCatalog.vehicleMake', 'carCatalog.vehicleModel', 'carCatalog.vehicleModelVersion',
+ 'car.licensePlate',
+ 'billingData.stop.invoiceNumber', 'ocpi', 'ocpiWithCdr',
]
},
{
@@ -1537,19 +1546,6 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
'stop.totalDurationSecs', 'stop.totalInactivitySecs', 'stop.extraInactivitySecs', 'site.name', 'siteArea.name', 'company.name',
'billingData.stop.invoiceNumber', 'stop.reason', 'ocpi', 'ocpiWithCdr', 'tagID', 'stop.tagID', 'tag.description', 'stop.tag.description', 'tag.visualID', 'stop.tag.visualID' ]
},
- {
- resource: Entity.TRANSACTION, action: Action.EXPORT_OCPI_CDR,
- condition: {
- Fn: 'custom:dynamicAuthorizations',
- args: {
- asserts: [],
- filters: ['AssignedSites']
- }
- },
- attributes: [
- 'id', 'ocpiData'
- ]
- },
{
resource: Entity.TRANSACTION, action: Action.GET_ADVENIR_CONSUMPTION,
condition: {
@@ -1573,16 +1569,6 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
}
}
},
- {
- resource: Entity.TRANSACTION, action: Action.PUSH_TRANSACTION_CDR,
- condition: {
- Fn: 'custom:dynamicAuthorizations',
- args: {
- asserts: [],
- filters: ['OwnUser', 'LocalIssuer']
- }
- }
- },
{
resource: Entity.TRANSACTION,
action: [Action.VIEW_USER_DATA],
@@ -1983,19 +1969,6 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
'stop.totalDurationSecs', 'stop.totalInactivitySecs', 'stop.extraInactivitySecs', 'site.name', 'siteArea.name', 'company.name',
'billingData.stop.invoiceNumber', 'stop.reason', 'ocpi', 'ocpiWithCdr', 'tagID', 'stop.tagID', 'tag.description', 'stop.tag.description', 'tag.visualID', 'stop.tag.visualID' ]
},
- {
- resource: Entity.TRANSACTION, action: Action.EXPORT_OCPI_CDR,
- condition: {
- Fn: 'custom:dynamicAuthorizations',
- args: {
- asserts: [],
- filters: ['AssignedSites']
- }
- },
- attributes: [
- 'id', 'ocpiData'
- ]
- },
{
resource: Entity.TRANSACTION, action: [Action.EXPORT, Action.UPDATE],
condition: {
@@ -2006,16 +1979,6 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
}
}
},
- {
- resource: Entity.TRANSACTION, action: Action.PUSH_TRANSACTION_CDR,
- condition: {
- Fn: 'custom:dynamicAuthorizations',
- args: {
- asserts: [],
- filters: ['AssignedSites', 'LocalIssuer']
- }
- }
- },
{
resource: Entity.TRANSACTION,
action: [Action.VIEW_USER_DATA],
@@ -2660,7 +2623,7 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
Fn: 'custom:dynamicAuthorizations',
args: {
asserts: [],
- filters: ['AssignedSites']
+ filters: []
}
},
attributes: [
@@ -3128,19 +3091,6 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
'stop.totalDurationSecs', 'stop.totalInactivitySecs', 'stop.extraInactivitySecs', 'site.name', 'siteArea.name', 'company.name',
'billingData.stop.invoiceNumber', 'stop.reason', 'ocpi', 'ocpiWithCdr', 'tagID', 'stop.tagID', 'tag.description', 'stop.tag.description', 'tag.visualID', 'stop.tag.visualID' ]
},
- {
- resource: Entity.TRANSACTION, action: Action.EXPORT_OCPI_CDR,
- condition: {
- Fn: 'custom:dynamicAuthorizations',
- args: {
- asserts: [],
- filters: ['AssignedSites']
- }
- },
- attributes: [
- 'id', 'ocpiData'
- ]
- },
{
resource: Entity.TRANSACTION, action: Action.GET_ADVENIR_CONSUMPTION,
condition: {
@@ -3164,16 +3114,6 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
}
}
},
- {
- resource: Entity.TRANSACTION, action: Action.PUSH_TRANSACTION_CDR,
- condition: {
- Fn: 'custom:dynamicAuthorizations',
- args: {
- asserts: [],
- filters: ['SitesOwner', 'LocalIssuer']
- }
- }
- },
{
resource: Entity.TRANSACTION,
action: [Action.VIEW_USER_DATA],

MODIFY
src/server/rest/v1/service/AuthorizationService.ts
src/server/rest/v1/service/AuthorizationService.ts
@@ -1166,6 +1166,8 @@ export default class AuthorizationService {
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);
transactions.canListTags = await AuthorizationService.canPerformAuthorizationAction(tenant, userToken, Entity.TAG, Action.LIST, authorizationFilter);
+ transactions.canExport = await AuthorizationService.canPerformAuthorizationAction(tenant, userToken, Entity.TRANSACTION, Action.EXPORT, authorizationFilter);
+ transactions.canDelete = await AuthorizationService.canPerformAuthorizationAction(tenant, userToken, Entity.TRANSACTION, Action.DELETE, authorizationFilter);
// Add Authorizations
for (const transaction of transactions.result) {
await AuthorizationService.addTransactionAuthorizations(tenant, userToken, transaction, authorizationFilter);
@@ -1185,18 +1187,12 @@ export default class AuthorizationService {
transaction.canSynchronizeRefundedTransaction = await AuthorizationService.canPerformAuthorizationAction(
tenant, userToken, Entity.TRANSACTION, Action.SYNCHRONIZE_REFUNDED_TRANSACTION,
authorizationFilter, { TransactionID: transaction.id, ...dynamicAuthorizationFilter }, transaction);
- transaction.canPushTransactionCDR = await AuthorizationService.canPerformAuthorizationAction(
- tenant, userToken, Entity.TRANSACTION, Action.PUSH_TRANSACTION_CDR,
- authorizationFilter, { TransactionID: transaction.id, ...dynamicAuthorizationFilter }, transaction);
transaction.canGetAdvenirConsumption = await AuthorizationService.canPerformAuthorizationAction(
tenant, userToken, Entity.TRANSACTION, Action.GET_ADVENIR_CONSUMPTION,
authorizationFilter, { TransactionID: transaction.id, ...dynamicAuthorizationFilter }, transaction);
transaction.canRemoteStopTransaction = await AuthorizationService.canPerformAuthorizationAction(
tenant, userToken, Entity.TRANSACTION, Action.REMOTE_STOP_TRANSACTION,
authorizationFilter, { TransactionID: transaction.id, ...dynamicAuthorizationFilter }, transaction);
- 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,
@@ -1210,6 +1206,19 @@ export default class AuthorizationService {
&& transaction.refundData
&& !!transaction.refundData.refundId
&& transaction.refundData.status !== RefundStatus.CANCELLED;
+ // Additional check for PushTransactionCDR
+ transaction.canPushTransactionCDR = transaction.ocpi
+ && !transaction.ocpiWithCdr
+ && await AuthorizationService.canPerformAuthorizationAction(
+ tenant, userToken, Entity.TRANSACTION, Action.PUSH_TRANSACTION_CDR,
+ authorizationFilter, { TransactionID: transaction.id, ...dynamicAuthorizationFilter }, transaction);
+ // Additional check for ExportOcpiCdr
+ transaction.canExportOcpiCdr = transaction.ocpi
+ && transaction.ocpiWithCdr
+ && await AuthorizationService.canPerformAuthorizationAction(
+ tenant, userToken, Entity.TRANSACTION, Action.EXPORT_OCPI_CDR,
+ authorizationFilter, { TransactionID: transaction.id, ...dynamicAuthorizationFilter }, transaction);
+
// Check and remove sensible data
const sensibleUserData = { UserData: true, TagData: true, CarCatalogData: true, CarData: true, BillingData: true };

MODIFY
src/types/DataResult.ts
src/types/DataResult.ts
@@ -88,6 +88,8 @@ export interface TransactionDataResult extends DataResult<Transaction> {
canListSiteAreas?: boolean;
canListChargingStations?: boolean;
canListTags?: boolean;
+ canExport?: boolean;
+ canDelete?: boolean;
}
export interface TransactionInErrorDataResult extends DataResult<TransactionInError> {

Update auth definition

- Remove actions for basic and demo
- Update projected fields & filters: push/export CDR
- Add flags to drive UI