From 463de748e72de3c229cfbe4d39e9e83d71fe9d41 Mon Sep 17 00:00:00 2001 From: Shubham Bansal Date: Wed, 13 Mar 2024 19:07:50 +0530 Subject: [PATCH 1/3] Issue #CO-824: dynamic redirect URL --- .../login/resources/js/telemetry_service.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ansible/artifacts/sunbird/login/resources/js/telemetry_service.js b/ansible/artifacts/sunbird/login/resources/js/telemetry_service.js index 5b4b6c6125..fab6bf3087 100644 --- a/ansible/artifacts/sunbird/login/resources/js/telemetry_service.js +++ b/ansible/artifacts/sunbird/login/resources/js/telemetry_service.js @@ -3159,6 +3159,16 @@ var handleGoogleAuthEvent = () => { redirectToLib(); } }; + +const allowedUrlForRedirect = [ + "https://dockstaging.sunbirded.org/sourcing", + "https://dock.sunbirded.org/sourcing", + "https://dock.sunbirded.org/contribute", + "https://dockstaging.sunbirded.org/contribute", + "https://ckoci.sunbirded.org/sourcing", + "https://ckoci.sunbirded.org/contribute" +]; + var redirectToPortal = (redirectUrlPath) => { // redirectUrlPath for sso and self signUp const curUrlObj = window.location; var redirect_uri = getValueFromSession('redirect_uri'); @@ -3171,9 +3181,7 @@ var redirectToPortal = (redirectUrlPath) => { // redirectUrlPath for sso and sel const redirect_uriLocation = new URL(redirect_uri); if (client_id === 'android' || client_id === 'desktop') { window.location.href = sessionUrlObj.protocol + '//' + sessionUrlObj.host + redirectUrlPath + updatedQuery; - } else if(client_id === 'portal' && - redirectUrlPath === '/sign-in/sso/select-org' && - (redirect_uri.includes('dock.sunbirded.org') || redirect_uri.includes('dockstaging.sunbirded.org'))) { + } else if(client_id === 'portal' && redirectUrlPath === '/sign-in/sso/select-org' && allowedUrlForRedirect.some(allowedUrl => allowedUrl.includes(redirect_uriLocation.host))) { window.location.href = sessionUrlObj.protocol + '//' + sessionUrlObj.host + redirectUrlPath + updatedQuery; } else { window.location.href = redirect_uriLocation.protocol + '//' + redirect_uriLocation.host + From 856963bea6d801532e27c769e5aee74423324a21 Mon Sep 17 00:00:00 2001 From: Shubham Bansal Date: Thu, 14 Mar 2024 15:28:00 +0530 Subject: [PATCH 2/3] Issue #CO-824: dynamic redirect URL --- .../sunbird/login/resources/js/telemetry_service.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/ansible/artifacts/sunbird/login/resources/js/telemetry_service.js b/ansible/artifacts/sunbird/login/resources/js/telemetry_service.js index fab6bf3087..f6eb58cbb8 100644 --- a/ansible/artifacts/sunbird/login/resources/js/telemetry_service.js +++ b/ansible/artifacts/sunbird/login/resources/js/telemetry_service.js @@ -3161,12 +3161,11 @@ var handleGoogleAuthEvent = () => { }; const allowedUrlForRedirect = [ - "https://dockstaging.sunbirded.org/sourcing", - "https://dock.sunbirded.org/sourcing", - "https://dock.sunbirded.org/contribute", - "https://dockstaging.sunbirded.org/contribute", - "https://ckoci.sunbirded.org/sourcing", - "https://ckoci.sunbirded.org/contribute" + "dockstaging.sunbirded.org", + "dock.sunbirded.org", + "ckoci.sunbirded.org", + "vdn.diksha.gov.in", + "dock.preprod.ntp.net.in" ]; var redirectToPortal = (redirectUrlPath) => { // redirectUrlPath for sso and self signUp @@ -3181,7 +3180,7 @@ var redirectToPortal = (redirectUrlPath) => { // redirectUrlPath for sso and sel const redirect_uriLocation = new URL(redirect_uri); if (client_id === 'android' || client_id === 'desktop') { window.location.href = sessionUrlObj.protocol + '//' + sessionUrlObj.host + redirectUrlPath + updatedQuery; - } else if(client_id === 'portal' && redirectUrlPath === '/sign-in/sso/select-org' && allowedUrlForRedirect.some(allowedUrl => allowedUrl.includes(redirect_uriLocation.host))) { + } else if(client_id === 'portal' && redirectUrlPath === '/sign-in/sso/select-org' && allowedUrlForRedirect.includes(redirect_uriLocation.host)) { window.location.href = sessionUrlObj.protocol + '//' + sessionUrlObj.host + redirectUrlPath + updatedQuery; } else { window.location.href = redirect_uriLocation.protocol + '//' + redirect_uriLocation.host + From cc13e083b39057a5448ef3e60e567b6c7d36f7b4 Mon Sep 17 00:00:00 2001 From: Shubham Bansal Date: Fri, 15 Mar 2024 16:37:59 +0530 Subject: [PATCH 3/3] Issue #CO-824: SSO Isse condition update --- .../sunbird/login/resources/js/telemetry_service.js | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/ansible/artifacts/sunbird/login/resources/js/telemetry_service.js b/ansible/artifacts/sunbird/login/resources/js/telemetry_service.js index f6eb58cbb8..1460374799 100644 --- a/ansible/artifacts/sunbird/login/resources/js/telemetry_service.js +++ b/ansible/artifacts/sunbird/login/resources/js/telemetry_service.js @@ -3160,14 +3160,6 @@ var handleGoogleAuthEvent = () => { } }; -const allowedUrlForRedirect = [ - "dockstaging.sunbirded.org", - "dock.sunbirded.org", - "ckoci.sunbirded.org", - "vdn.diksha.gov.in", - "dock.preprod.ntp.net.in" -]; - var redirectToPortal = (redirectUrlPath) => { // redirectUrlPath for sso and self signUp const curUrlObj = window.location; var redirect_uri = getValueFromSession('redirect_uri'); @@ -3180,7 +3172,7 @@ var redirectToPortal = (redirectUrlPath) => { // redirectUrlPath for sso and sel const redirect_uriLocation = new URL(redirect_uri); if (client_id === 'android' || client_id === 'desktop') { window.location.href = sessionUrlObj.protocol + '//' + sessionUrlObj.host + redirectUrlPath + updatedQuery; - } else if(client_id === 'portal' && redirectUrlPath === '/sign-in/sso/select-org' && allowedUrlForRedirect.includes(redirect_uriLocation.host)) { + } else if(client_id === 'portal' && redirectUrlPath === '/sign-in/sso/select-org' && (sessionUrlObj.host !== redirect_uriLocation.host)) { window.location.href = sessionUrlObj.protocol + '//' + sessionUrlObj.host + redirectUrlPath + updatedQuery; } else { window.location.href = redirect_uriLocation.protocol + '//' + redirect_uriLocation.host +