first try on technicalUser
MODIFY
docker/config.json
docker/config.json
"userTokenKey": "s3A9js135sdf384hgj384ku38lilckjflskdjf2797boeiBhxQDM1GInRith",
"userTokenLifetimeHours": 12,
"userDemoTokenLifetimeDays": 365,
+ "userTechnicalTokenLifetimeDays": 365,
"socketIO": true,
"socketIOListNotificationIntervalSecs": 5,
"socketIOSingleNotificationIntervalSecs": 1,

MODIFY
src/assets/config-template-https.json
src/assets/config-template-https.json
"userTokenKey": "YourSecretKey",
"userTokenLifetimeHours": 12,
"userDemoTokenLifetimeDays": 365,
+ "userTechnicalTokenLifetimeDays": 365,
"socketIO": false,
"socketIOListNotificationIntervalSecs": 5,
"socketIOSingleNotificationIntervalSecs": 1,

MODIFY
src/assets/server/rest/v1/schemas/user/user-create.json
src/assets/server/rest/v1/schemas/user/user-create.json
},
"role": {
"$ref": "user.json#/definitions/role"
+ },
+ "technical": {
+ "type": "boolean"
}
},
"required": [

MODIFY
src/assets/server/rest/v1/schemas/user/user-update.json
src/assets/server/rest/v1/schemas/user/user-update.json
},
"role": {
"$ref": "user.json#/definitions/role"
+ },
+ "technical": {
+ "type": "boolean"
}
},
"required": [

MODIFY
src/authorization/Authorizations.ts
src/authorization/Authorizations.ts
import { Action, AuthorizationContext, AuthorizationResult, Entity } from '../types/Authorization';
import ChargingStation, { Connector } from '../types/ChargingStation';
+import Tenant, { TenantComponents } from '../types/Tenant';
import User, { UserRole, UserStatus } from '../types/User';
import AuthorizationConfiguration from '../types/configuration/AuthorizationConfiguration';
@@ -28,8 +29,6 @@ import SiteAreaStorage from '../storage/mongodb/SiteAreaStorage';
import SiteStorage from '../storage/mongodb/SiteStorage';
import Tag from '../types/Tag';
import TagStorage from '../storage/mongodb/TagStorage';
-import Tenant, { TenantComponents } from '../types/Tenant';
-
import Transaction from '../types/Transaction';
import TransactionStorage from '../storage/mongodb/TransactionStorage';
import UserStorage from '../storage/mongodb/UserStorage';
@@ -725,6 +724,10 @@ export default class Authorizations {
return user.role === UserRole.DEMO;
}
+ public static isTechnical(user: UserToken | User): boolean {
+ return user.technical === true;
+ }
+
public static async can(loggedUser: UserToken, entity: Entity, action: Action, context?: AuthorizationContext): Promise<AuthorizationResult> {
// Check
const authDefinition = AuthorizationsDefinition.getInstance();

MODIFY
src/authorization/AuthorizationsDefinition.ts
src/authorization/AuthorizationsDefinition.ts
@@ -92,7 +92,7 @@ const AUTHORIZATION_DEFINITION: AuthorizationDefinition = {
resource: Entity.USER, action: Action.READ,
attributes: [
'id', 'name', 'firstName', 'email', 'role', 'status', 'issuer', 'locale', 'plateID',
- 'notificationsActive', 'notifications', 'phone', 'mobile', 'iNumber', 'costCenter', 'address'
+ 'notificationsActive', 'notifications', 'phone', 'mobile', 'iNumber', 'costCenter', 'address', 'technical'
]
},
{

MODIFY
src/server/rest/v1/service/AuthService.ts
src/server/rest/v1/service/AuthService.ts
@@ -755,6 +755,10 @@ export default class AuthService {
token = jwt.sign(payload, jwtOptions.secretOrKey, {
expiresIn: _centralSystemRestConfig.userDemoTokenLifetimeDays * 24 * 3600
});
+ } else if (Authorizations.isTechnical(user)) {
+ token = jwt.sign(payload, jwtOptions.secretOrKey, {
+ expiresIn: _centralSystemRestConfig.userTechnicalTokenLifetimeDays * 24 * 3600
+ });
} else {
token = jwt.sign(payload, jwtOptions.secretOrKey, {
expiresIn: _centralSystemRestConfig.userTokenLifetimeHours * 3600

MODIFY
src/types/User.ts
src/types/User.ts
@@ -41,6 +41,7 @@ export default interface User extends CreatedUpdatedProps, AuthorizationActions
importedData?: {
autoActivateUserAtImport: boolean;
};
+ technical: boolean;
}
export interface UserSite {

MODIFY
src/types/UserToken.ts
src/types/UserToken.ts
@@ -24,4 +24,5 @@ export default interface UserToken {
sitesOwner?: string[];
activeComponents?: string[];
user?: User;
+ technical?: boolean;
}

MODIFY
src/types/configuration/CentralSystemRestServiceConfiguration.ts
src/types/configuration/CentralSystemRestServiceConfiguration.ts
@@ -4,6 +4,7 @@ export default interface CentralSystemRestServiceConfiguration extends CentralSy
userTokenKey: string;
userTokenLifetimeHours: number;
userDemoTokenLifetimeDays: number;
+ userTechnicalTokenLifetimeDays: number;
socketIO?: boolean;
socketIOListNotificationIntervalSecs?: number;
socketIOSingleNotificationIntervalSecs?: number;

first try on technicalUser