From c22dc6dab56ff4a31df84475f629cf6d15f1f5bd Mon Sep 17 00:00:00 2001 From: Christoph Reiter <reiter.christoph@gmail.com> Date: Mon, 4 May 2020 11:21:33 +0200 Subject: [PATCH] Try again: Add attribute for forwarding the keycloak config No longer depend on env.js to select the right config but require it to be passed explicitely in the attributes. --- packages/app-shell/README.md | 3 ++- packages/app-shell/assets/index.html | 2 +- packages/app-shell/src/app-shell.js | 8 ++++---- packages/app-shell/src/vpu-app-shell-user-profile.js | 2 +- packages/app-shell/vendor/auth | 2 +- packages/app-shell/vendor/person-profile | 2 +- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/app-shell/README.md b/packages/app-shell/README.md index 9d9543de..dfb036c0 100644 --- a/packages/app-shell/README.md +++ b/packages/app-shell/README.md @@ -14,10 +14,11 @@ activities. Handles login, language selection, activity switching, menus etc. ## Attributes - `lang` (optional, default: `de`): set to `de` or `en` for German or English - - example `<vpu-auth lang="de" </vpu-auth>` + - example `<vpu-app-shell lang="de" </vpu-app-shell>` - `src`: The path to a topic metadata file (json) - `base-path` (optional, default: `/`: An absolute base path for routing - `entry-point-url`: Entry point URL to access the API +- `keycloak-config`: See `vpu-auth` for details ## Topic Metadata diff --git a/packages/app-shell/assets/index.html b/packages/app-shell/assets/index.html index a3c18219..d3bc8319 100644 --- a/packages/app-shell/assets/index.html +++ b/packages/app-shell/assets/index.html @@ -15,7 +15,7 @@ <body> -<vpu-app-shell src="/example.topic.metadata.json"></vpu-app-shell> +<vpu-app-shell keycloak-config='{"url": "https://auth-dev.tugraz.at/auth", "realm": "tugraz", "clientId": "auth-dev-mw-frontend-local", "silentCheckSsoRedirectUri": "/silent-check-sso.html"}' src="/example.topic.metadata.json"></vpu-app-shell> </body> </html> \ No newline at end of file diff --git a/packages/app-shell/src/app-shell.js b/packages/app-shell/src/app-shell.js index 2c9ef61e..43e72aef 100644 --- a/packages/app-shell/src/app-shell.js +++ b/packages/app-shell/src/app-shell.js @@ -5,8 +5,8 @@ import {LanguageSelect} from 'vpu-language-select'; import {Icon} from 'vpu-common'; import {Auth} from 'vpu-auth'; import {Notification} from 'vpu-notification'; -import * as commonUtils from 'vpu-common/utils'; import * as commonStyles from 'vpu-common/styles'; +import * as commonUtils from 'vpu-common/utils'; import buildinfo from 'consts:buildinfo'; import {classMap} from 'lit-html/directives/class-map.js'; import {Router} from './router.js'; @@ -54,6 +54,7 @@ export class AppShell extends ScopedElementsMixin(LitElement) { this.metadata = {}; this.topic = {}; this.basePath = '/'; + this.keycloakConfig = null; this._updateAuth = this._updateAuth.bind(this); this._loginStatus = 'unknown'; @@ -218,6 +219,7 @@ export class AppShell extends ScopedElementsMixin(LitElement) { basePath: { type: String, attribute: 'base-path' }, activeView: { type: String, attribute: false}, entryPointUrl: { type: String, attribute: 'entry-point-url' }, + keycloakConfig: { type: Object, attribute: 'keycloak-config' }, metadata: { type: Object, attribute: false }, topic: { type: Object, attribute: false }, subtitle: { type: String, attribute: false }, @@ -637,8 +639,6 @@ export class AppShell extends ScopedElementsMixin(LitElement) { } render() { - const silentCheckSsoUri = commonUtils.getAssetURL('silent-check-sso.html'); - const getSelectClasses = (name => { return classMap({selected: this.activeView === name}); }); @@ -685,7 +685,7 @@ export class AppShell extends ScopedElementsMixin(LitElement) { <div class="hd1-middle"> </div> <div class="hd1-right"> - <vpu-auth lang="${this.lang}" show-profile keycloak-config='{"clientId": "${commonUtils.setting('keyCloakClientId')}", "silentCheckSsoRedirectUri": "${silentCheckSsoUri}"}' load-person try-login></vpu-auth> + <vpu-auth lang="${this.lang}" show-profile keycloak-config="${JSON.stringify(this.keycloakConfig)}" load-person try-login></vpu-auth> </div> <div class="hd2-left"> <div class="header"> diff --git a/packages/app-shell/src/vpu-app-shell-user-profile.js b/packages/app-shell/src/vpu-app-shell-user-profile.js index 04dee0ac..8d62cace 100644 --- a/packages/app-shell/src/vpu-app-shell-user-profile.js +++ b/packages/app-shell/src/vpu-app-shell-user-profile.js @@ -48,7 +48,7 @@ class AppShellUserProfile extends ScopedElementsMixin(LitElement) { render() { return html` - <vpu-person-profile value="${this._personId}" entry-point-url="${this.entryPointUrl}"" lang="${this.lang}"></vpu-person-profile> + <vpu-person-profile value="${this._personId}" entry-point-url="${this.entryPointUrl}" lang="${this.lang}"></vpu-person-profile> `; } } diff --git a/packages/app-shell/vendor/auth b/packages/app-shell/vendor/auth index b9fbe487..2e179331 160000 --- a/packages/app-shell/vendor/auth +++ b/packages/app-shell/vendor/auth @@ -1 +1 @@ -Subproject commit b9fbe487a8a6117ae90a423a8ba318a0321bf51b +Subproject commit 2e179331c2f7572a85e98c825736a3c93494e1ea diff --git a/packages/app-shell/vendor/person-profile b/packages/app-shell/vendor/person-profile index 8158d845..5cb9000f 160000 --- a/packages/app-shell/vendor/person-profile +++ b/packages/app-shell/vendor/person-profile @@ -1 +1 @@ -Subproject commit 8158d8451e08bfaf495ee263d208a448df83e12d +Subproject commit 5cb9000f7ae43558b3db7df4b61f3bb177f02fe2 -- GitLab