Skip to content
Snippets Groups Projects
Commit 917300fa authored by Steinwender, Tamara's avatar Steinwender, Tamara
Browse files

Merge branch 'master' of gitlab.tugraz.at:dbp/web-components/toolkit

parents 50d5b917 437152cf
No related branches found
No related tags found
No related merge requests found
Pipeline #12940 passed
...@@ -712,7 +712,7 @@ export class AppShell extends ScopedElementsMixin(LitElement) { ...@@ -712,7 +712,7 @@ export class AppShell extends ScopedElementsMixin(LitElement) {
return html` return html`
<slot class="${slotClassMap}"></slot> <slot class="${slotClassMap}"></slot>
<dbp-auth-keycloak lang="${this.lang}" url="${kc.url}" realm="${kc.realm}" client-id="${kc.clientId}" silent-check-sso-redirect-uri="${kc.silentCheckSsoRedirectUri || ''}" scope="${kc.scope || ''}" load-person try-login></dbp-auth-keycloak> <dbp-auth-keycloak lang="${this.lang}" url="${kc.url}" realm="${kc.realm}" client-id="${kc.clientId}" silent-check-sso-redirect-uri="${kc.silentCheckSsoRedirectUri || ''}" scope="${kc.scope || ''}" idp-hint="${kc.idpHint || ''}" load-person try-login></dbp-auth-keycloak>
<div class="${mainClassMap}"> <div class="${mainClassMap}">
<div id="main"> <div id="main">
<dbp-notification lang="${this.lang}"></dbp-notification> <dbp-notification lang="${this.lang}"></dbp-notification>
......
...@@ -42,6 +42,7 @@ export class AuthKeycloak extends LitElement { ...@@ -42,6 +42,7 @@ export class AuthKeycloak extends LitElement {
this.clientId = null; this.clientId = null;
this.silentCheckSsoRedirectUri = null; this.silentCheckSsoRedirectUri = null;
this.scope = null; this.scope = null;
this.idpHint = '';
// Create the events // Create the events
this.initEvent = new CustomEvent("dbp-auth-init", { "detail": "KeyCloak init event", bubbles: true, composed: true }); this.initEvent = new CustomEvent("dbp-auth-init", { "detail": "KeyCloak init event", bubbles: true, composed: true });
...@@ -174,6 +175,7 @@ export class AuthKeycloak extends LitElement { ...@@ -174,6 +175,7 @@ export class AuthKeycloak extends LitElement {
clientId: { type: String, attribute: 'client-id' }, clientId: { type: String, attribute: 'client-id' },
silentCheckSsoRedirectUri: { type: String, attribute: 'silent-check-sso-redirect-uri' }, silentCheckSsoRedirectUri: { type: String, attribute: 'silent-check-sso-redirect-uri' },
scope: { type: String }, scope: { type: String },
idpHint: { type: String, attribute: 'idp-hint' },
}; };
} }
...@@ -188,7 +190,7 @@ export class AuthKeycloak extends LitElement { ...@@ -188,7 +190,7 @@ export class AuthKeycloak extends LitElement {
throw Error("client-id not set"); throw Error("client-id not set");
this._bus = new EventBus(); this._bus = new EventBus();
this._kcwrapper = new KeycloakWrapper(this.keycloakUrl, this.realm, this.clientId, this.silentCheckSsoRedirectUri); this._kcwrapper = new KeycloakWrapper(this.keycloakUrl, this.realm, this.clientId, this.silentCheckSsoRedirectUri, this.idpHint);
this._kcwrapper.addEventListener('changed', this._onKCChanged); this._kcwrapper.addEventListener('changed', this._onKCChanged);
this._bus.subscribe('auth-login', () => { this._bus.subscribe('auth-login', () => {
......
...@@ -39,7 +39,7 @@ const ensureURL = function(urlOrPath) { ...@@ -39,7 +39,7 @@ const ensureURL = function(urlOrPath) {
*/ */
export class KeycloakWrapper extends EventTarget { export class KeycloakWrapper extends EventTarget {
constructor(baseURL, realm, clientId, silentCheckSsoUri) { constructor(baseURL, realm, clientId, silentCheckSsoUri, idpHint) {
super(); super();
this._baseURL = baseURL; this._baseURL = baseURL;
...@@ -48,6 +48,7 @@ export class KeycloakWrapper extends EventTarget { ...@@ -48,6 +48,7 @@ export class KeycloakWrapper extends EventTarget {
this._keycloak = null; this._keycloak = null;
this._initDone = false; this._initDone = false;
this._silentCheckSsoUri = silentCheckSsoUri; this._silentCheckSsoUri = silentCheckSsoUri;
this._idpHint = idpHint;
} }
_onChanged() { _onChanged() {
...@@ -105,6 +106,7 @@ export class KeycloakWrapper extends EventTarget { ...@@ -105,6 +106,7 @@ export class KeycloakWrapper extends EventTarget {
async _keycloakInit(options) { async _keycloakInit(options) {
// https://gitlab.tugraz.at/dbp/apps/library/issues/41 // https://gitlab.tugraz.at/dbp/apps/library/issues/41
// retry the keycloak init in case it fails, maybe it helps :/ // retry the keycloak init in case it fails, maybe it helps :/
options['idpHint'] = 'eid-oidc';
try { try {
return await this._keycloak.init(options); return await this._keycloak.init(options);
} catch (e) { } catch (e) {
...@@ -120,10 +122,12 @@ export class KeycloakWrapper extends EventTarget { ...@@ -120,10 +122,12 @@ export class KeycloakWrapper extends EventTarget {
const options = { const options = {
promiseType: 'native', promiseType: 'native',
pkceMethod: 'S256' pkceMethod: 'S256',
}; };
if (this._silentCheckSsoUri) { if (this._silentCheckSsoUri) {
options['onLoad'] = 'check-sso'; options['onLoad'] = 'check-sso';
options['silentCheckSsoRedirectUri'] = ensureURL(this._silentCheckSsoUri); options['silentCheckSsoRedirectUri'] = ensureURL(this._silentCheckSsoUri);
...@@ -136,6 +140,7 @@ export class KeycloakWrapper extends EventTarget { ...@@ -136,6 +140,7 @@ export class KeycloakWrapper extends EventTarget {
} else { } else {
await this._keycloakInit(options); await this._keycloakInit(options);
} }
} }
/** /**
...@@ -164,7 +169,9 @@ export class KeycloakWrapper extends EventTarget { ...@@ -164,7 +169,9 @@ export class KeycloakWrapper extends EventTarget {
kcLocale: language, // Keycloak < 9.0 kcLocale: language, // Keycloak < 9.0
locale: language, locale: language,
scope: scope, scope: scope,
idpHint: this._idpHint,
}); });
//options['idpHint'] = 'eid-oidc';
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment