Skip to content

Commit e0da717

Browse files
author
Rob Tjalma
authored
Merge pull request #62 from com-pas/add_validator_client
Add SCL Validator to Docker Compose
2 parents c160c07 + 60fca9a commit e0da717

File tree

7 files changed

+133
-3
lines changed

7 files changed

+133
-3
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,8 @@ target
88
# IDE specific
99
.idea
1010
*.iml
11+
12+
# Data Directories for Docker Compose
13+
# Ignore all files, except the README.md
14+
compas/data/**/*.*
15+
!compas/data/**/README.md

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,21 @@ docker-compose -f compas/docker-compose-postgresql.yml down -v
6969

7070
The option '-v' also removes the volumes created, so all data is lost with this option.
7171

72+
## Docker Compose (Common)
73+
74+
### Custom files
75+
76+
The SCL Validator Service can be extended with custom OCL and NSDOC Files. These can be placed in specific directories,
77+
see [OCL Files](compas/data/ocl/README.md) and [NSDOC Files](compas/data/nsdoc/README.md).
78+
7279
### Known issue with Docker Compose
7380

7481
Using the current configuration with Keycloak and OpenResty (lua-resty-session) sometimes gives an error
7582
"**state from argument does not match state restored from session**".
7683
This mostly happens after using logout or the session is expired. The login page is shown, but after login this error is shown.
7784
Just open the url [http://localhost/](http://localhost/) again and OpenSCD is shown again, also being logged in.
7885

79-
## Keycloak Demo Configuration
86+
### Keycloak Demo Configuration
8087
For demo purposes, a [demo Keycloak configuration](compas/keycloak/keycloak_compas_realm.json) is created which can be imported when
8188
running a Keycloak instance.
8289

compas/data/nsdoc/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!--
2+
SPDX-FileCopyrightText: 2021 Alliander N.V.
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
-->
6+
7+
This directory can be used to add NSDOC Files to be served by the SCL Validator Service for the frontend application.
8+
9+
For instance
10+
```
11+
compas/data
12+
└── nsdoc
13+
├── Official-File73.nsdoc
14+
└── README.md
15+
```

compas/data/ocl/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!--
2+
SPDX-FileCopyrightText: 2021 Alliander N.V.
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
-->
6+
7+
This directory can be used to add custom OCL Files to the validation process.
8+
9+
You can use subdirectories like `SemanticConstraints` as RiseClipse is doing.
10+
And there is a special filter that when you create a directory `FileSpecifics`.
11+
In this directory you can create for instance a directory `CID` to put constraints specific for an SCL File Type.
12+
Known types are `SSD`, `IID`, `ICD`, `SCD`, `CID`, `SED`, `ISD`, `STD`.
13+
14+
For instance,
15+
16+
```
17+
compas/data
18+
└── ocl
19+
├── FileSpecifics
20+
│ └── CID
21+
│ └── Busbar.ocl
22+
├── README.md
23+
└── SemanticConstraints
24+
└── Busbar.ocl
25+
```

compas/docker-compose-basex.yml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,37 @@ services:
108108
depends_on:
109109
- keycloak
110110

111+
scl-validator:
112+
labels:
113+
compas: true
114+
image: "lfenergy/compas-scl-validator:0.1.0"
115+
ports:
116+
- "9093:8080"
117+
environment:
118+
- JWT_VERIFY_KEY=http://keycloak:8080/auth/realms/compas/protocol/openid-connect/certs
119+
- JWT_VERIFY_ISSUER=http://${COMPAS_HOSTNAME}/auth/realms/compas
120+
- JWT_VERIFY_CLIENT_ID=scl-validator
121+
- JWT_GROUPS_PATH=resource_access/scl-validator/roles
122+
- USERINFO_WHO_CLAIMNAME=name
123+
deploy:
124+
restart_policy:
125+
condition: on-failure
126+
max_attempts: 3
127+
healthcheck:
128+
test: ["CMD", "curl", "-f", "http://localhost:8080/compas-scl-validator/q/health/ready"]
129+
interval: 15s
130+
timeout: 10s
131+
retries: 5
132+
volumes:
133+
- ./data/ocl:/data/ocl
134+
- ./data/nsdoc:/data/nsdoc
135+
depends_on:
136+
- keycloak
137+
111138
open-scd:
112139
labels:
113140
compas: true
114-
image: "lfenergy/compas-open-scd:v0.12.0.0"
141+
image: "lfenergy/compas-open-scd:v0.12.0.1"
115142
healthcheck:
116143
test: ["CMD", "curl", "-f", "http://localhost/"]
117144
interval: 30s

compas/docker-compose-postgresql.yml

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,37 @@ services:
115115
depends_on:
116116
- keycloak
117117

118+
scl-validator:
119+
labels:
120+
compas: true
121+
image: "lfenergy/compas-scl-validator:0.1.0"
122+
ports:
123+
- "9093:8080"
124+
environment:
125+
- JWT_VERIFY_KEY=http://keycloak:8080/auth/realms/compas/protocol/openid-connect/certs
126+
- JWT_VERIFY_ISSUER=http://${COMPAS_HOSTNAME}/auth/realms/compas
127+
- JWT_VERIFY_CLIENT_ID=scl-validator
128+
- JWT_GROUPS_PATH=resource_access/scl-validator/roles
129+
- USERINFO_WHO_CLAIMNAME=name
130+
deploy:
131+
restart_policy:
132+
condition: on-failure
133+
max_attempts: 3
134+
healthcheck:
135+
test: ["CMD", "curl", "-f", "http://localhost:8080/compas-scl-validator/q/health/ready"]
136+
interval: 15s
137+
timeout: 10s
138+
retries: 5
139+
volumes:
140+
- ./data/ocl:/data/ocl
141+
- ./data/nsdoc:/data/nsdoc
142+
depends_on:
143+
- keycloak
144+
118145
open-scd:
119146
labels:
120147
compas: true
121-
image: "lfenergy/compas-open-scd:v0.12.0.0"
148+
image: "lfenergy/compas-open-scd:v0.12.0.1"
122149
healthcheck:
123150
test: ["CMD", "curl", "-f", "http://localhost/"]
124151
interval: 30s
@@ -127,6 +154,8 @@ services:
127154
depends_on:
128155
- scl-data-service
129156
- cim-mapping
157+
- scl-auto-alignment
158+
- scl-validator
130159

131160
reverse-proxy:
132161
labels:
@@ -146,6 +175,8 @@ services:
146175
- keycloak
147176
- scl-data-service
148177
- cim-mapping
178+
- scl-auto-alignment
179+
- scl-validator
149180
- open-scd
150181

151182
volumes:

compas/reverse-proxy/nginx.conf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,26 @@ http {
126126
proxy_redirect off;
127127
}
128128

129+
# Forwarding to the SCL Auto Alignment Service container.
130+
location /compas-scl-validator/ {
131+
include /etc/nginx/include/authenticate.include;
132+
133+
proxy_set_header X-Real-IP $remote_addr;
134+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
135+
proxy_set_header X-Forwarded-Proto $scheme;
136+
proxy_set_header X-Forwarded-Port $server_port;
137+
proxy_set_header Authorization "Bearer ${access_token}";
138+
139+
# Added Header back to browser to get JWT Content for Debugging, should not do this in production.
140+
add_header X-Debug-Bearer "Bearer ${access_token}" always;
141+
142+
proxy_pass http://scl-validator:8080/compas-scl-validator/;
143+
144+
proxy_set_header Host $http_host;
145+
proxy_cache_bypass $http_upgrade;
146+
proxy_redirect off;
147+
}
148+
129149
# redirect server error pages to the static page /40x.html
130150
error_page 404 /404.html;
131151
location = /40x.html {

0 commit comments

Comments
 (0)