Skip to content
Snippets Groups Projects
Commit e9df546e authored by Reiter, Christoph's avatar Reiter, Christoph :snake:
Browse files

Allow silentCheckSsoRedirectUri to be a relative/absolute path as well

In some cases we want to set the path via a html attribute where we can't easily
compute a URL relative to the bundle or page. Convert a path to an URL
if parsing it as an URL doesn't work instead.
parent 943c0220
No related branches found
No related tags found
No related merge requests found
......@@ -28,7 +28,7 @@
- `url`: The base URL of the Keycloak server
- `realm`: The Keycloak realm
- `clientId`: The Keycloak client to use
- `silentCheckSsoRedirectUri`: URI to a separate page for checking the login session in an iframe, see https://www.keycloak.org/docs/latest/securing_apps/#_javascript_adapter
- `silentCheckSsoRedirectUri`: URI or path to a separate page for checking the login session in an iframe, see https://www.keycloak.org/docs/latest/securing_apps/#_javascript_adapter
- `scope`: Space separated list of scopes to request. These scopes get added in addition to the default ones, assuming the scope is in the optional scopes list of the Keycloak client in use.
## Events to listen to
......
......@@ -17,6 +17,18 @@ const promiseTimeout = function(ms, promise) {
};
/**
* Returns a URL for a relative path or URL
*/
const ensureURL = function(urlOrPath) {
try {
return new URL(urlOrPath).href;
} catch (e) {
return new URL(urlOrPath, window.location.href).href;
}
}
/**
* Wraps the keycloak API to support async/await, adds auto token refreshing and consolidates all
* events into one native "changed" event
......@@ -111,7 +123,7 @@ export class KeycloakWrapper extends EventTarget {
if (this._silentCheckSsoUri) {
options['onLoad'] = 'check-sso';
options['silentCheckSsoRedirectUri'] = this._silentCheckSsoUri;
options['silentCheckSsoRedirectUri'] = ensureURL(this._silentCheckSsoUri);
// When silent-sso-check is active but the iframe doesn't load/work we will
// never return here, so add a timeout and emit a signal so the app can continue
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment