Skip to content

Commit 2693360

Browse files
authored
Auth URL fix of on-prem (#8455)
1 parent 1081f80 commit 2693360

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

frontend/src/utils/generate-auth-url.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@
66
*/
77
export const generateAuthUrl = (identityProvider: string, requestUrl: URL) => {
88
const redirectUri = `${requestUrl.origin}/oauth/keycloak/callback`;
9-
const authUrl = requestUrl.hostname
9+
let authUrl = requestUrl.hostname
1010
.replace(/(^|\.)staging\.all-hands\.dev$/, "$1auth.staging.all-hands.dev")
1111
.replace(/(^|\.)app\.all-hands\.dev$/, "auth.app.all-hands.dev")
1212
.replace(/(^|\.)localhost$/, "auth.staging.all-hands.dev");
13+
14+
// If no replacements matched, prepend "auth." (excluding localhost)
15+
if (authUrl === requestUrl.hostname && requestUrl.hostname !== "localhost") {
16+
authUrl = `auth.${requestUrl.hostname}`;
17+
}
1318
const scope = "openid email profile"; // OAuth scope - not user-facing
1419
return `https://${authUrl}/realms/allhands/protocol/openid-connect/auth?client_id=allhands&kc_idp_hint=${identityProvider}&response_type=code&redirect_uri=${encodeURIComponent(redirectUri)}&scope=${encodeURIComponent(scope)}`;
1520
};

0 commit comments

Comments
 (0)