oidc-client-ts integration WIP

This commit is contained in:
Markus Thielen 2023-11-01 09:22:00 +01:00
parent 3c30049dc2
commit be1e94ee06
Signed by: markus
GPG Key ID: 3D4980D3EC9C8E26
3 changed files with 9 additions and 7 deletions

View File

@ -39,16 +39,17 @@ router.beforeEach(async (to, from) => {
/* catch OIDC callback */
if (to.path === callbackPath) {
console.info("OIDC: got signin callback request to ", to);
const userMgr = getOidcUserManager();
try {
const user = await userMgr.signinRedirectCallback();
console.log("OIDC: login complete, user: ", user);
const user = await userMgr.signinRedirectCallback(location.origin + to.fullPath);
console.info("OIDC: login complete, user: ", user);
storeInit(user);
/* redirect to home page */
return {name: 'home'};
} catch (err) {
console.error("OIDC: login failed: ", err);
console.error("OIDC: Error handling signin callback: ", err);
}
/* redirect to home page */
return {name: 'home'};
}
/* if no user is logged in, we redirect to the home page */

View File

@ -11,7 +11,7 @@ Log.level = (process.env.NODE_ENV === 'production') ? Log.ERROR : Log.DEBUG;
// OIDC configuration
const oidcProviderDomain = 'https://basebox-test-1.eu.auth0.com';
const clientId = '5wl8hQV1thh07rScSoJ3aN56ETuXWprg';
const scopes = "openid profile email";
const scopes = "openid profile email name nickname";
export const callbackPath = "/auth/callback"
/* OIDC UserManager singleton */
@ -29,6 +29,7 @@ export const getOidcUserManager = () => {
client_id: clientId,
redirect_uri: window.location.origin + callbackPath,
response_type: 'code',
response_mode: 'query',
scope: scopes,
post_logout_redirect_uri: window.location.origin + '/home?action=logout',
accessTokenExpiringNotificationTime: 10,

View File

@ -19,7 +19,7 @@ function doLogin() {
console.log("doLogin");
const userMgr = getOidcUserManager();
userMgr.signinRedirect().then(() => {
console.log("signinRedirect");
console.info("signinRedirect");
}).catch((err) => {
console.error("signinRedirect failed", err);
});