Backend: Frontend: Add OIDC Autologin#4475
Backend: Frontend: Add OIDC Autologin#4475mudit06mah wants to merge 4 commits intokubernetes-sigs:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request adds OIDC auto-login functionality to Headlamp, allowing automatic redirection to the OIDC provider when enabled via the oidc-auto-login server flag. This eliminates the manual step of clicking "Sign In" for OIDC-authenticated clusters.
Changes:
- Added
oidc-auto-loginconfiguration flag to the backend that can be enabled via command line - Extended Redux state to store the
oidcAutoLoginsetting from the backend configuration - Implemented auto-redirect logic in the Layout component to automatically initiate OIDC authentication flow
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| backend/pkg/config/config.go | Adds OidcAutoLogin boolean field and corresponding command-line flag |
| backend/cmd/server.go | Initializes OidcAutoLogin from config when creating HeadlampConfig |
| backend/cmd/headlamp.go | Adds OidcAutoLogin field to HeadlampConfig struct and includes it in clientConfig API response |
| backend/cmd/stateless.go | Includes oidcAutoLogin in clientConfig for parseKubeConfig endpoint (hardcoded to false) |
| frontend/src/redux/configSlice.ts | Adds oidcAutoLogin field to ConfigState and updates setConfig action to accept it |
| frontend/src/components/authchooser/index.tsx | Preserves oidcAutoLogin when updating cluster config after auth testing |
| frontend/src/components/App/Layout.tsx | Implements auto-redirect logic via useEffect that redirects to OIDC provider when conditions are met |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
b6ad78c to
d221613
Compare
0e497aa to
836eafc
Compare
2d138ea to
6acebea
Compare
|
@illume I have made all the changes requested by copilot, Please review this again :) |
|
Hi that's awesome! What would be the behavior when running in cluster config ? Would the user being automatically be redirected when reaching the homepage ? Anyway thanks a lot |
I haven't tested it properly but, yes, It should redirect the user to homepage :) |
|
@illume Can you Please review this again? 👾 |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
6acebea to
2de498f
Compare
|
@illume I have made the changes suggested by copilot, Can you please review this again? |
2de498f to
25e19e8
Compare
illume
left a comment
There was a problem hiding this comment.
Thank you for those changes.
I noticed there's now a merge conflict.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Comments suppressed due to low confidence (1)
backend/pkg/config/config.go:451
- A new config flag/koanf key is introduced (
oidc-auto-login), but there’s no corresponding config parsing test coverage. Add a test case inbackend/pkg/config/config_test.goverifying the flag (and ideallyHEADLAMP_CONFIG_OIDC_AUTO_LOGINenv var) correctly setsOidcAutoLogin, to prevent regressions in the flag/env precedence logic.
func addOIDCFlags(f *flag.FlagSet) {
f.Bool("oidc-auto-login", false, "Automatic Redirect to OIDC provider")
f.String("oidc-client-id", "", "ClientID for OIDC")
f.String("oidc-client-secret", "", "ClientSecret for OIDC")
f.String("oidc-validator-client-id", "", "Override ClientID for OIDC during validation")
f.String("oidc-idp-issuer-url", "", "Identity provider issuer URL for OIDC")
f.String("oidc-callback-url", "", "Callback URL for OIDC")
f.String("oidc-validator-idp-issuer-url", "", "Override Identity provider issuer URL for OIDC during validation")
f.String("oidc-scopes", "profile,email", "A comma separated list of scopes needed from the OIDC provider")
f.Bool("oidc-skip-tls-verify", false, "Skip TLS verification for OIDC")
f.String("oidc-ca-file", "", "CA file for OIDC")
f.Bool("oidc-use-access-token", false, "Setup oidc to pass through the access_token instead of the default id_token")
f.Bool("oidc-use-pkce", false, "Use PKCE (Proof Key for Code Exchange) for enhanced security in OIDC flow")
f.String("me-username-path", DefaultMeUsernamePath,
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
8e87ad4 to
f00c57c
Compare
f00c57c to
3c4f223
Compare
illume
left a comment
There was a problem hiding this comment.
Looking good.
Can you please check the final open review comments? If you disagree with them, please write in there why and mark them as resolved.
I had already made those changes earlier :) |
illume
left a comment
There was a problem hiding this comment.
🎉 thanks!
This looks fine to me. I’ll leave it open a bit longer before merging to give someone else a chance to review it if they feel inclined.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: illume, mudit06mah The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
3c4f223 to
d615418
Compare
|
@illume While working on my other PR related to adding a flag, I noticed that I have not added this flag to the |
Summary
This PR Adds feature to enable Autologin on OIDC as well as support for OIDC autologin.
Related Issue
Fixes #4343
Changes
oidc-auto-loginflag to headlamp-serverLayout.tsxSteps to Test
oidc-auto-login=trueand other oidc flags (oidc-client-id,oidc-idp-issuer-url, etc.)auth-provider = 'oidc'Screenshots
oidc_autologin.mp4
Note
I couldn't correctly configure my OIDC client locally, but it completely works logically as intended.