Skip to content

Commit e6be69d

Browse files
itpickclaude
andcommitted
Show auth chooser when GCP OAuth is enabled
When GCP OAuth is configured, show the auth chooser dialog instead of automatically redirecting to the token page. This allows users to choose between Google Sign In and token authentication. The redirect to token page is now conditional on GCP OAuth being disabled, which preserves backward compatibility with e2e tests and non-GCP deployments. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 4edbd8c commit e6be69d

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

frontend/src/components/authchooser/index.tsx

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { getAppUrl } from '../../helpers/getAppUrl';
2626
import { getCluster, getClusterPrefixedPath } from '../../lib/cluster';
2727
import { useClustersConf } from '../../lib/k8s';
2828
import { testAuth } from '../../lib/k8s/api/v1/clusterApi';
29+
import { isGCPOAuthEnabled } from '../../lib/k8s/gke';
2930
import { queryClient } from '../../lib/queryClient';
3031
import { createRouteURL } from '../../lib/router/createRouteURL';
3132
import { getRoute } from '../../lib/router/getRoute';
@@ -160,21 +161,33 @@ function AuthChooser({ children }: AuthChooserProps) {
160161
if (cluster.useToken === false) {
161162
history.replace(from);
162163
} else if (!clusterAuthType) {
163-
// we know that it requires token and also doesn't have oidc configured
164-
// so let's redirect to token page
165-
history.replace({
166-
pathname: generatePath(getClusterPrefixedPath('token'), {
167-
cluster: clusterName as string,
168-
}),
164+
// Check if GCP OAuth is enabled before auto-redirecting to token page.
165+
// If GCP OAuth is enabled, we want to show the auth chooser so users can
166+
// choose between Google Sign In and token authentication.
167+
isGCPOAuthEnabled().then(gcpEnabled => {
168+
if (!gcpEnabled && !cancelledRef.current) {
169+
// GCP OAuth not enabled, so redirect to token page
170+
history.replace({
171+
pathname: generatePath(getClusterPrefixedPath('token'), {
172+
cluster: clusterName as string,
173+
}),
174+
});
175+
}
176+
// If GCP OAuth is enabled, stay on auth chooser to show both options
169177
});
170178
}
171179
}
172180
});
173181
} else if (cluster.useToken) {
174-
history.replace({
175-
pathname: generatePath(getClusterPrefixedPath('token'), {
176-
cluster: clusterName as string,
177-
}),
182+
// Check if GCP OAuth is enabled before auto-redirecting
183+
isGCPOAuthEnabled().then(gcpEnabled => {
184+
if (!gcpEnabled && !cancelledRef.current) {
185+
history.replace({
186+
pathname: generatePath(getClusterPrefixedPath('token'), {
187+
cluster: clusterName as string,
188+
}),
189+
});
190+
}
178191
});
179192
}
180193
},

0 commit comments

Comments
 (0)