Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | import { UserManager } from 'oidc-client-ts';
/**
* Creates a userManager from oidcSettings
* LINK: https://github.com/IdentityModel/oidc-client-js/wiki#configuration
*
* @param {Object} oidcSettings
* @param {string} oidcSettings.authServerUrl,
* @param {string} oidcSettings.clientId,
* @param {string} oidcSettings.authRedirectUri,
* @param {string} oidcSettings.postLogoutRedirectUri,
* @param {string} oidcSettings.responseType,
* @param {string} oidcSettings.extraQueryParams,
*/
export default function getUserManagerForOpenIdConnectClient(oidcSettings) {
Iif (!oidcSettings) {
return;
}
Iif (!oidcSettings.authority || !oidcSettings.client_id || !oidcSettings.redirect_uri) {
console.error('Missing required oidc settings: authority, client_id, redirect_uri');
return;
}
const settings = {
...oidcSettings,
// The next client always use the code flow with PKCE
response_type: 'code',
revokeTokensOnSignout: oidcSettings.revokeAccessTokenOnSignout ?? true,
filterProtocolClaims: true,
// the followings are default values in the lib so no need to set them
// automaticSilentRenew: true,
};
const userManager = new UserManager(settings);
return userManager;
}
|