Updated auth def
MODIFY
src/authorization/AuthorizationsDefinition.ts
src/authorization/AuthorizationsDefinition.ts
@@ -245,8 +245,8 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
resource: Entity.SITE_AREA,
action: [
Action.CREATE, Action.UPDATE, Action.DELETE, Action.ASSIGN_ASSETS_TO_SITE_AREA,
- Action.UNASSIGN_ASSETS_TO_SITE_AREA, Action.ASSIGN_CHARGING_STATIONS_TO_SITE_AREA,
- Action.UNASSIGN_CHARGING_STATIONS_TO_SITE_AREA, Action.EXPORT_OCPP_PARAMS, Action.GENERATE_QR,
+ Action.UNASSIGN_ASSETS_FROM_SITE_AREA, Action.ASSIGN_CHARGING_STATIONS_TO_SITE_AREA,
+ Action.UNASSIGN_CHARGING_STATIONS_FROM_SITE_AREA, Action.EXPORT_OCPP_PARAMS, Action.GENERATE_QR,
Action.READ_ASSETS_FROM_SITE_AREA
],
condition: {
@@ -433,7 +433,22 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
basic: {
grants: [
{
- resource: Entity.USER, action: [Action.READ, Action.UPDATE],
+ resource: Entity.USER, action: Action.READ,
+ condition: {
+ Fn: 'custom:dynamicAuthorizations',
+ args: {
+ asserts: [],
+ filters: ['OwnUser']
+ }
+ },
+ attributes: [
+ 'id', 'name', 'firstName', 'email', 'role', 'issuer', 'locale',
+ 'notificationsActive', 'notifications', 'phone', 'mobile',
+ 'iNumber', 'costCenter', 'address'
+ ]
+ },
+ {
+ resource: Entity.USER, action: Action.UPDATE,
condition: {
Fn: 'custom:dynamicAuthorizations',
args: {
@@ -487,7 +502,7 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
],
},
{
- resource: Entity.CAR, action: Action.CREATE,
+ resource: Entity.CAR, action: [Action.CREATE, Action.UPDATE],
condition: {
Fn: 'custom:dynamicAuthorizations',
args: {
@@ -524,16 +539,6 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
}
}
},
- {
- resource: Entity.CAR, action: Action.UPDATE,
- condition: {
- Fn: 'custom:dynamicAuthorizations',
- args: {
- asserts: ['-PoolCar', 'OwnUser'],
- filters: ['OwnUser']
- }
- }
- },
{
resource: Entity.COMPANY, action: Action.LIST,
condition: {
@@ -644,7 +649,7 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
'createdOn', 'chargeBoxSerialNumber', 'chargePointSerialNumber', 'powerLimitUnit'
]
},
- { resource: Entity.CHARGING_STATION, action: [Action.READ] },
+ { resource: Entity.CHARGING_STATION, action: Action.READ },
{
resource: Entity.CHARGING_STATION,
action: [Action.REMOTE_START_TRANSACTION, Action.AUTHORIZE, Action.START_TRANSACTION],
@@ -664,6 +669,17 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
]
}
},
+ {
+ resource: Entity.CHARGING_STATION,
+ action: [Action.REMOTE_STOP_TRANSACTION, Action.STOP_TRANSACTION],
+ condition: {
+ Fn: 'custom:dynamicAuthorizations',
+ args: {
+ asserts: [],
+ filters: ['AssignedSites', 'LocalIssuer']
+ }
+ },
+ },
{
resource: Entity.TAG, action: Action.LIST,
condition: {
@@ -693,7 +709,7 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
],
},
{
- resource: Entity.TAG, action: Action.UNASSIGN,
+ resource: Entity.TAG, action: [Action.UNASSIGN, Action.UPDATE_BY_VISUAL_ID],
condition: {
Fn: 'custom:dynamicAuthorizations',
args: {
@@ -702,26 +718,6 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
}
}
},
- {
- resource: Entity.TAG, action: Action.UNASSIGN,
- condition: {
- Fn: 'custom:dynamicAuthorizations',
- args: {
- asserts: ['OwnUser'],
- filters: ['OwnUser'],
- }
- }
- },
- {
- resource: Entity.TAG, action: Action.UPDATE_BY_VISUAL_ID,
- condition: {
- Fn: 'custom:dynamicAuthorizations',
- args: {
- asserts: ['OwnUser'],
- filters: ['OwnUser'],
- }
- }
- },
{
resource: Entity.TAG, action: Action.ASSIGN,
attributes: [
@@ -729,17 +725,6 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
'user.name', 'user.firstName', 'user.email', 'createdOn', 'lastChangedOn'
]
},
- {
- resource: Entity.CHARGING_STATION,
- action: [Action.REMOTE_STOP_TRANSACTION, Action.STOP_TRANSACTION],
- condition: {
- Fn: 'custom:dynamicAuthorizations',
- args: {
- asserts: [],
- filters: ['AssignedSites', 'LocalIssuer']
- }
- },
- },
{ resource: Entity.TRANSACTION, action: [Action.LIST, Action.EXPORT] },
{
resource: Entity.TRANSACTION, action: [Action.READ, Action.UPDATE],
@@ -911,16 +896,6 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
}
}
},
- {
- resource: Entity.TAG, action: [Action.UNASSIGN],
- condition: {
- Fn: 'custom:dynamicAuthorizations',
- args: {
- asserts: [],
- filters: ['ExcludeAction']
- }
- }
- },
{
resource: Entity.USER, action: Action.LIST,
condition: {
@@ -1029,7 +1004,7 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
{
resource: Entity.SITE_AREA,
action: [
- Action.UPDATE, Action.DELETE, Action.UNASSIGN_ASSETS_TO_SITE_AREA, Action.UNASSIGN_CHARGING_STATIONS_TO_SITE_AREA
+ Action.UPDATE, Action.DELETE, Action.UNASSIGN_ASSETS_FROM_SITE_AREA, Action.UNASSIGN_CHARGING_STATIONS_FROM_SITE_AREA
],
condition: {
Fn: 'custom:dynamicAuthorizations',
@@ -1307,7 +1282,7 @@ export const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
}
}
},
- { resource: Entity.PRICING_DEFINITION, action: [Action.LIST],
+ { resource: Entity.PRICING_DEFINITION, action: Action.LIST,
attributes: ['id', 'entityID', 'entityType', 'name', 'description', 'entityName',
'staticRestrictions.validFrom', 'staticRestrictions.validTo', 'staticRestrictions.connectorType', 'staticRestrictions.connectorPowerkW',
'restrictions.daysOfWeek', 'restrictions.timeFrom', 'restrictions.timeTo',

MODIFY
src/server/rest/v1/service/AuthorizationService.ts
src/server/rest/v1/service/AuthorizationService.ts
@@ -504,13 +504,13 @@ export default class AuthorizationService {
siteArea.canAssignAssets = await AuthorizationService.canPerformAuthorizationAction(
tenant, userToken, Entity.SITE_AREA, Action.ASSIGN_ASSETS_TO_SITE_AREA, authorizationFilter, { SiteAreaID: siteArea.id, SiteID: siteArea.siteID }, siteArea);
siteArea.canUnassignAssets = await AuthorizationService.canPerformAuthorizationAction(
- tenant, userToken, Entity.SITE_AREA, Action.UNASSIGN_ASSETS_TO_SITE_AREA, authorizationFilter, { SiteAreaID: siteArea.id, SiteID: siteArea.siteID }, siteArea);
+ tenant, userToken, Entity.SITE_AREA, Action.UNASSIGN_ASSETS_FROM_SITE_AREA, authorizationFilter, { SiteAreaID: siteArea.id, SiteID: siteArea.siteID }, siteArea);
siteArea.canReadAssets = await AuthorizationService.canPerformAuthorizationAction(
tenant, userToken, Entity.SITE_AREA, Action.READ_ASSETS_FROM_SITE_AREA, authorizationFilter, { SiteAreaID: siteArea.id, SiteID: siteArea.siteID }, siteArea);
siteArea.canAssignChargingStations = await AuthorizationService.canPerformAuthorizationAction(
tenant, userToken, Entity.SITE_AREA, Action.ASSIGN_CHARGING_STATIONS_TO_SITE_AREA, authorizationFilter, { SiteAreaID: siteArea.id, SiteID: siteArea.siteID }, siteArea);
siteArea.canUnassignChargingStations = await AuthorizationService.canPerformAuthorizationAction(
- tenant, userToken, Entity.SITE_AREA, Action.UNASSIGN_CHARGING_STATIONS_TO_SITE_AREA, authorizationFilter, { SiteAreaID: siteArea.id, SiteID: siteArea.siteID }, siteArea);
+ tenant, userToken, Entity.SITE_AREA, Action.UNASSIGN_CHARGING_STATIONS_FROM_SITE_AREA, authorizationFilter, { SiteAreaID: siteArea.id, SiteID: siteArea.siteID }, siteArea);
siteArea.canReadChargingStations = await AuthorizationService.canPerformAuthorizationAction(
tenant, userToken, Entity.SITE_AREA, Action.READ_CHARGING_STATIONS_FROM_SITE_AREA, authorizationFilter, { SiteAreaID: siteArea.id, SiteID: siteArea.siteID }, siteArea);
siteArea.canExportOCPPParams = await AuthorizationService.canPerformAuthorizationAction(

MODIFY
src/server/rest/v1/service/SiteAreaService.ts
src/server/rest/v1/service/SiteAreaService.ts
@@ -35,7 +35,7 @@ export default class SiteAreaService {
// Filter request
const filteredRequest = SiteAreaValidator.getInstance().validateSiteAreaAssignAssetsReq(req.body);
// Check and Get Site Area
- const authAction = action === ServerAction.ADD_ASSET_TO_SITE_AREA ? Action.ASSIGN_ASSETS_TO_SITE_AREA : Action.UNASSIGN_ASSETS_TO_SITE_AREA;
+ const authAction = action === ServerAction.ADD_ASSET_TO_SITE_AREA ? Action.ASSIGN_ASSETS_TO_SITE_AREA : Action.UNASSIGN_ASSETS_FROM_SITE_AREA;
const siteArea = await UtilsService.checkAndGetSiteAreaAuthorization(
req.tenant, req.user, filteredRequest.siteAreaID, authAction, action);
// Check and Get Assets
@@ -66,7 +66,7 @@ export default class SiteAreaService {
// Filter request
const filteredRequest = SiteAreaValidator.getInstance().validateSiteAreaAssignChargingStationsReq(req.body);
// Check and Get Site Area
- const authAction = action === ServerAction.ADD_CHARGING_STATIONS_TO_SITE_AREA ? Action.ASSIGN_CHARGING_STATIONS_TO_SITE_AREA : Action.UNASSIGN_CHARGING_STATIONS_TO_SITE_AREA;
+ const authAction = action === ServerAction.ADD_CHARGING_STATIONS_TO_SITE_AREA ? Action.ASSIGN_CHARGING_STATIONS_TO_SITE_AREA : Action.UNASSIGN_CHARGING_STATIONS_FROM_SITE_AREA;
const siteArea = await UtilsService.checkAndGetSiteAreaAuthorization(
req.tenant, req.user, filteredRequest.siteAreaID, authAction, action, null, { withSite: true });
// Check and Get Charging Stations

MODIFY
src/types/Authorization.ts
src/types/Authorization.ts
@@ -146,12 +146,12 @@ export enum Action {
DOWNLOAD = 'Download',
IMPORT = 'Import',
ASSIGN_USERS_TO_SITE = 'AssignUsers',
- UNASSIGN_USERS_TO_SITE = 'UnassignUsers',
+ UNASSIGN_USERS_FROM_SITE = 'UnassignUsers',
ASSIGN_ASSETS_TO_SITE_AREA = 'AssignAssets',
- UNASSIGN_ASSETS_TO_SITE_AREA = 'UnassignAssets',
+ UNASSIGN_ASSETS_FROM_SITE_AREA = 'UnassignAssets',
READ_ASSETS_FROM_SITE_AREA = 'ReadAssets',
ASSIGN_CHARGING_STATIONS_TO_SITE_AREA = 'AssignChargingStations',
- UNASSIGN_CHARGING_STATIONS_TO_SITE_AREA = 'UnassignChargingStations',
+ UNASSIGN_CHARGING_STATIONS_FROM_SITE_AREA = 'UnassignChargingStations',
READ_CHARGING_STATIONS_FROM_SITE_AREA = 'ReadChargingStationsFromSiteArea',
EXPORT_OCPP_PARAMS = 'ExportOCPPParams',
GENERATE_QR = 'GenerateQrCode',

Updated auth def