File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change 6
6
*/
7
7
export const generateAuthUrl = ( identityProvider : string , requestUrl : URL ) => {
8
8
const redirectUri = `${ requestUrl . origin } /oauth/keycloak/callback` ;
9
- const authUrl = requestUrl . hostname
9
+ let authUrl = requestUrl . hostname
10
10
. replace ( / ( ^ | \. ) s t a g i n g \. a l l - h a n d s \. d e v $ / , "$1auth.staging.all-hands.dev" )
11
11
. replace ( / ( ^ | \. ) a p p \. a l l - h a n d s \. d e v $ / , "auth.app.all-hands.dev" )
12
12
. replace ( / ( ^ | \. ) l o c a l h o s t $ / , "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
+ }
13
18
const scope = "openid email profile" ; // OAuth scope - not user-facing
14
19
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 ) } ` ;
15
20
} ;
You can’t perform that action at this time.
0 commit comments