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 <g.parant@thecodingmachine.com>
This commit is contained in:
grégoire parant 2021-09-30 11:16:25 +02:00 committed by GitHub
parent 4650f4e8cf
commit 1e69bb0f49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 5 deletions

View File

@ -46,8 +46,11 @@ class ConnectionManager {
loginSceneVisibleIframeStore.set(false); loginSceneVisibleIframeStore.set(false);
return null; return null;
} }
const redirectUrl = `${this._currentRoom.iframeAuthentication}?state=${state}&nonce=${nonce}&playUri=${this._currentRoom.key}`; const redirectUrl = new URL(`${this._currentRoom.iframeAuthentication}`);
window.location.assign(redirectUrl); redirectUrl.searchParams.append("state", state);
redirectUrl.searchParams.append("nonce", nonce);
redirectUrl.searchParams.append("playUri", this._currentRoom.key);
window.location.assign(redirectUrl.toString());
return redirectUrl; return redirectUrl;
} }

View File

@ -28,7 +28,7 @@ export class AuthenticateController extends BaseController {
}); });
try { try {
const { nonce, state, playUri } = parse(req.getQuery()); const { nonce, state, playUri, redirect } = parse(req.getQuery());
if (!state || !nonce) { if (!state || !nonce) {
throw "missing state and nonce URL parameters"; throw "missing state and nonce URL parameters";
} }
@ -36,7 +36,8 @@ export class AuthenticateController extends BaseController {
const loginUri = await openIDClient.authorizationUrl( const loginUri = await openIDClient.authorizationUrl(
state as string, state as string,
nonce as string, nonce as string,
playUri as string | undefined playUri as string | undefined,
redirect as string | undefined
); );
res.writeStatus("302"); res.writeStatus("302");
res.writeHeader("Location", loginUri); res.writeHeader("Location", loginUri);

View File

@ -20,7 +20,7 @@ class OpenIDClient {
return this.issuerPromise; 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 this.initClient().then((client) => {
return client.authorizationUrl({ return client.authorizationUrl({
scope: "openid email", scope: "openid email",
@ -28,6 +28,7 @@ class OpenIDClient {
state: state, state: state,
nonce: nonce, nonce: nonce,
playUri: playUri, playUri: playUri,
redirect: redirect,
}); });
}); });
} }