From 1e69bb0f491bb98bc7379a7035d40bbe13b18159 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?gr=C3=A9goire=20parant?= Date: Thu, 30 Sep 2021 11:16:25 +0200 Subject: [PATCH] Manage redirect URL from admin and save in hydra via pusher (#1492) Add redirect parameter url to connect user directly on private openId application Signed-off-by: Gregoire Parant --- front/src/Connexion/ConnectionManager.ts | 7 +++++-- pusher/src/Controller/AuthenticateController.ts | 5 +++-- pusher/src/Services/OpenIDClient.ts | 3 ++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/front/src/Connexion/ConnectionManager.ts b/front/src/Connexion/ConnectionManager.ts index 7ad861dd..dc094a06 100644 --- a/front/src/Connexion/ConnectionManager.ts +++ b/front/src/Connexion/ConnectionManager.ts @@ -46,8 +46,11 @@ class ConnectionManager { loginSceneVisibleIframeStore.set(false); return null; } - const redirectUrl = `${this._currentRoom.iframeAuthentication}?state=${state}&nonce=${nonce}&playUri=${this._currentRoom.key}`; - window.location.assign(redirectUrl); + const redirectUrl = new URL(`${this._currentRoom.iframeAuthentication}`); + redirectUrl.searchParams.append("state", state); + redirectUrl.searchParams.append("nonce", nonce); + redirectUrl.searchParams.append("playUri", this._currentRoom.key); + window.location.assign(redirectUrl.toString()); return redirectUrl; } diff --git a/pusher/src/Controller/AuthenticateController.ts b/pusher/src/Controller/AuthenticateController.ts index 8f9cabf9..ce217439 100644 --- a/pusher/src/Controller/AuthenticateController.ts +++ b/pusher/src/Controller/AuthenticateController.ts @@ -28,7 +28,7 @@ export class AuthenticateController extends BaseController { }); try { - const { nonce, state, playUri } = parse(req.getQuery()); + const { nonce, state, playUri, redirect } = parse(req.getQuery()); if (!state || !nonce) { throw "missing state and nonce URL parameters"; } @@ -36,7 +36,8 @@ export class AuthenticateController extends BaseController { const loginUri = await openIDClient.authorizationUrl( state as string, nonce as string, - playUri as string | undefined + playUri as string | undefined, + redirect as string | undefined ); res.writeStatus("302"); res.writeHeader("Location", loginUri); diff --git a/pusher/src/Services/OpenIDClient.ts b/pusher/src/Services/OpenIDClient.ts index da636c02..c9137ad5 100644 --- a/pusher/src/Services/OpenIDClient.ts +++ b/pusher/src/Services/OpenIDClient.ts @@ -20,7 +20,7 @@ class OpenIDClient { return this.issuerPromise; } - public authorizationUrl(state: string, nonce: string, playUri?: string) { + public authorizationUrl(state: string, nonce: string, playUri?: string, redirect?: string) { return this.initClient().then((client) => { return client.authorizationUrl({ scope: "openid email", @@ -28,6 +28,7 @@ class OpenIDClient { state: state, nonce: nonce, playUri: playUri, + redirect: redirect, }); }); }