Skip to content

Commit 0dc9d46

Browse files
authored
Fixes DynamicRBAC Duplicate Initial Roles Error (#754)
* Adds CI Workflow for Examples * Changes wrong docker-compose path * Changes version of DynamicRBAC to milestone-05 (test purpose) * Changes version of DynamicRBAC to b0f9724 (test purpose) * Changes version of DynamicRBAC to 2ddae04 (test purpose) * Changes version of DynamicRBAC to 19b8725 (test purpose) * Changes version of DynamicRBAC to 025c597 (test purpose) * Changes version of DynamicRBAC to 2f374eb (test purpose) * Changes version of DynamicRBAC to e0e13f1 (test purpose) * Changes version of DynamicRBAC to 7cc0cf5 (test purpose) * Changes version of DynamicRBAC to f619d5a (test purpose) * Changes version of DynamicRBAC to bb3ce87 (test purpose) * Changes version of DynamicRBAC to cdd6ad7 (test purpose) * Changes version of DynamicRBAC to a84f97b (test purpose) * Removes Discovery Integration * Changes version back to Snapshot * Changes Discovery Integration * Adds admin rule * Fixes Duplicate Rule Error on Restart * Fixes DynamicRBAC Example
1 parent 538aa69 commit 0dc9d46

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

basyx.common/basyx.authorization.rules.rbac.backend.submodel/src/main/java/org/eclipse/digitaltwin/basyx/authorization/rules/rbac/backend/submodel/SubmodelAuthorizationRbacStorage.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,17 @@ public void addRule(RbacRule rbacRule) {
6565
.map(rule -> ruleAdapter.adapt(rule, createKey(rule))).collect(Collectors.toList());
6666

6767
rbacRulesSMC.stream().forEach(rule -> {
68-
try {
69-
smService.createSubmodelElement(rule);
68+
try{
69+
smService.getSubmodelElement(rule.getIdShort());
70+
LOGGER.warn("Rule with key " + rule.getIdShort() + " already exists. Skipping creation.");
7071
} catch (Exception e) {
71-
LOGGER.error("Exception while creating SubmodelElement for rule: " + rule.getIdShort() + ". Error: " + e.getMessage());
72+
try {
73+
smService.createSubmodelElement(rule);
74+
} catch (Exception e2) {
75+
LOGGER.error("Exception while creating SubmodelElement for rule: " + rule.getIdShort() + ". Error: " + e2.getMessage());
76+
}
7277
}
78+
7379
});
7480
}
7581

examples/BaSyxDynamicRBAC/basyx/aas-env.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
server.port=8081
2-
basyx.backend=InMemory
2+
basyx.backend=MongoDB
3+
spring.data.mongodb.uri = mongodb://mongoAdmin:mongoPassword@mongo:27017/aas-env?authSource=admin
34
basyx.environment=file:aas
45
basyx.cors.allowed-origins=*
56
basyx.cors.allowed-methods=GET,POST,PATCH,DELETE,PUT,OPTIONS,HEAD

examples/BaSyxDynamicRBAC/docker-compose.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ services:
3030
- '8081:8081'
3131
restart: always
3232
depends_on:
33+
keycloak:
34+
condition: service_healthy
3335
aas-registry:
3436
condition: service_healthy
3537
sm-registry:

0 commit comments

Comments
 (0)