Make sure redirect URI is HTTPS unless it is for localhost (#9076)

This commit is contained in:
chuckbutkus 2025-06-11 14:19:15 -04:00 committed by GitHub
parent c11dcad309
commit 7dede37fd8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5,7 +5,10 @@
* @returns The URL to redirect to for OAuth
*/
export const generateAuthUrl = (identityProvider: string, requestUrl: URL) => {
const redirectUri = `${requestUrl.origin}/oauth/keycloak/callback`;
// Use HTTPS protocol unless the host is localhost
const protocol =
requestUrl.hostname === "localhost" ? requestUrl.protocol : "https:";
const redirectUri = `${protocol}//${requestUrl.host}/oauth/keycloak/callback`;
let authUrl = requestUrl.hostname
.replace(/(^|\.)staging\.all-hands\.dev$/, "$1auth.staging.all-hands.dev")
.replace(/(^|\.)app\.all-hands\.dev$/, "auth.app.all-hands.dev")