Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions lib/keycloak.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,13 @@ export interface KeycloakInitOptions {
* HTTP method for calling the end_session endpoint. Defaults to 'GET'.
*/
logoutMethod?: 'GET' | 'POST';

/**
* Configures url parameters to forward to Keycloak server.
* These are specified as an object with key-value pairs.
* Note that the keys need to be enabled in the Keycloak server in the 'Forwarded parameters' section.
*/
forwardParameters?: { [key: string]: string };
}

export interface KeycloakLoginOptions {
Expand Down Expand Up @@ -295,6 +302,13 @@ export interface KeycloakLoginOptions {
*/
locale?: string;

/**
* Configures url parameters to forward to Keycloak server.
* These are specified as an object with key-value pairs.
* Note that the keys need to be enabled in the Keycloak server in the 'Forwarded parameters' section.
*/
forwardParameters?: { [key: string]: string };

/**
* Specifies arguments that are passed to the Cordova in-app-browser (if applicable).
* Options 'hidden' and 'location' are not affected by these arguments.
Expand Down
13 changes: 13 additions & 0 deletions lib/keycloak.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ export default class Keycloak {
/** @type {KeycloakPkceMethod} */
pkceMethod = 'S256';
enableLogging = false;
/** @type {{ [key: string]: string }=} */
forwardParameters;
/** @type {'GET' | 'POST'} */
logoutMethod = 'GET';
/** @type {string=} */
Expand Down Expand Up @@ -268,6 +270,10 @@ export default class Keycloak {
this.scope = initOptions.scope;
}

if (initOptions.forwardParameters) {
this.forwardParameters = initOptions.forwardParameters;
}

if (typeof initOptions.messageReceiveTimeout === 'number' && initOptions.messageReceiveTimeout > 0) {
this.messageReceiveTimeout = initOptions.messageReceiveTimeout;
}
Expand Down Expand Up @@ -1268,6 +1274,13 @@ export default class Keycloak {
params.append('acr_values', options.acrValues);
}

if (options?.forwardParameters) {
const forwardParameters = options.forwardParameters;
Object.keys(forwardParameters).forEach(function (key) {
params.append(key, forwardParameters[key]);
});
}

if (this.pkceMethod) {
try {
const codeVerifier = generateCodeVerifier(96);
Expand Down