fix: use SPA availability check instead of UseInCluster for OIDC callback routing#3
Draft
fix: use SPA availability check instead of UseInCluster for OIDC callback routing#3
Conversation
…back The OIDC callback handler used `!config.UseInCluster` to determine whether to use the desktop flow (token polling + success HTML) vs the web flow (redirect to /auth). This check was incorrect because the actual requirement is whether the SPA handler is available to serve the /auth frontend route. When no SPA is registered (Electron desktop mode - no static dir and no embedded files), redirecting to /auth results in a 404 because the backend has no handler for that route. Changed the check to `!hasSPA` (based on `spa.UseEmbeddedFiles || config.StaticDir != ""`) which correctly determines if the /auth route can be served by the SPA handler. Co-authored-by: mechermu <189133602+mechermu@users.noreply.github.com>
Co-authored-by: mechermu <189133602+mechermu@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix OIDC sign-in issue with 404 error
fix: use SPA availability check instead of UseInCluster for OIDC callback routing
Mar 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes OIDC sign-in on desktop returning 404 at
/auth?cluster=my-cluster. The OIDC callback used!config.UseInClusterto choose between desktop flow (token polling) and web flow (redirect to/auth), but the correct check is whether the SPA handler exists to serve/auth.Related Issue
Changes
backend/cmd/headlamp.go: Replace!config.UseInClusterwith SPA availability check in the OIDC callback handlerbackend/cmd/headlamp_test.go: Add test for/oidc-token-pollendpointThe callback handler now checks whether the SPA can actually serve the
/authroute:Routing matrix after fix:
/auth✓-html-static-dir/auth✓Steps to Test
Screenshots (if applicable)
Notes for the Reviewer
!config.UseInCluster) was a proxy for "are we in desktop mode" but conflated deployment mode with SPA availability. The new check directly tests what the code path needs: whether/authcan be served.spa.UseEmbeddedFilesis a compile-time constant (truewithembedbuild tag,falseotherwise).config.StaticDiris set via-html-static-dirflag. Together they cover all cases where the SPA handler is registered (line 954–967 of headlamp.go).Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
test-cluster.example.com/tmp/go-build3901459589/b001/cmd.test /tmp/go-build3901459589/b001/cmd.test -test.testlogfile=/tmp/go-build3901459589/b001/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true lient-go@v0.33.3-errorsas .cfg ux_amd64/vet -p /informers/admis-atomic -lang=go1.24 ux_amd64/vet -I 6996502/b1238/_p-errorsas pkg/mod/github.c-ifaceassert ux_amd64/vet --gdwarf-5 /tools/portforwa-atomic -o ux_amd64/vet(dns block)/tmp/go-build2130730644/b001/cmd.test /tmp/go-build2130730644/b001/cmd.test -test.testlogfile=/tmp/go-build2130730644/b001/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true se 3834763/b080/vet-ifaceassert ux_amd64/vet r/executer.go /tmp/go-build144ls-files -I ux_amd64/vet(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.