Repository navigation
Load client-go auth-provider plugins so oidc kubeconfigs connect - #9
Conversation
A kubeconfig user that logs in through `auth-provider: oidc`, which kubectl still reads, failed before any request with clientset: no Auth Provider found for name "oidc" client-go only knows the auth-provider plugins a program imports, and k10s imported none: the context showed in the header, then the connection failed and the No cluster panel showed that line. Import k8s.io/client-go/plugin/pkg/client/auth, as kubectl and k9s do: the oidc plugin, plus stubs for the removed gcp and azure providers that say what replaced them. The oidc plugin refreshes an expired id-token against the identity provider with its own HTTP client and writes the new one back to the kubeconfig file that holds the user, so read-only mode, which guards only requests to the API server, does not stand in its way. Signed-off-by: Adao Oliveira Jr <[email protected]>
a49f736 to
62e3ddd
Compare
|
First of all, sorry for the slow review. I was sick for the past week and today is the first day I've been back at a computer, so this is the first chance I've had to look at it properly. Reviewed and verified locally on top of
The test setup is really thorough: a TLS fake API server, a fake IdP with discovery + token endpoint, multi-file Approving. One more thing: this is your third PR here (#6, #7 and now this one), and every one of them has been well-reasoned, well-tested and carefully written. Would you be interested in becoming a maintainer of k10s? That would mean triage, reviewing and merging PRs, and a say in where the project goes. No pressure at all, but if you're up for it, just say so and I'll send the invite. |
A kubeconfig whose user logs in through
auth-provider: oidcshows its context in the header, and then the connection fails with:client-go only knows the auth-provider plugins a program imports, and k10s imports none. This adds the import kubectl and k9s use,
k8s.io/client-go/plugin/pkg/client/auth: the oidc plugin, plus stubs for the removed gcp and azure providers, so a kubeconfig that still names one of those gets client-go's pointer to the replacement credential plugin instead of the same "not found".Tests in
internal/k8s/auth_test.go, against an https test API server:TestOIDCAuthProviderKubeconfigConnects: a valid id-token connects, and the API server receives it as the bearer token.TestOIDCAuthProviderRefreshesExpiredToken: an expired id-token is refreshed against a fake identity provider (discovery, then one refresh-token grant), the API server only ever sees the new token, and the new tokens are written back to the file that holds the user, here the second file of a two-fileKUBECONFIG. It runs with and without--readonly: the refresh is a POST, but it goes to the identity provider through the plugin's own client, which the read-only guard does not wrap.TestRemovedAuthProviderIsStillRecognised: agcpauth-provider gets client-go's removal notice.All three fail on main with the "no Auth Provider found" error. Checked with
gofmt,go vet ./...andgo test ./...on Go 1.26.9, and a build for each release platform. I also ran a build of this branch against a real cluster whose kubeconfig logs in this way, and it connects.