Skip to content

Commit d0c12c6

Browse files
fix(platform): fix broken dashboard login by token (#2661)
<!-- Thank you for making a contribution! Here are some tips for you: - Use Conventional Commits for the PR title: `type(scope): description` - Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore - Scopes are not an exhaustive list — pick the most specific scope for the change and extend the list when a genuinely new area appears. Examples: - System components: dashboard, platform, operator, cilium, kube-ovn, linstor, fluxcd, cluster-api - Managed apps: postgres, mariadb, redis, kafka, clickhouse, virtual-machine, kubernetes - Development and maintenance: api, hack, tests, ci, docs, maintenance - Breaking changes: append `!` after type/scope (`feat(api)!: ...`) or add a `BREAKING CHANGE:` footer - If it's a work in progress, consider creating this PR as a draft. - Don't hesistate to ask for opinion and review in the community chats, even if it's still a draft. - Add the label `backport` if it's a bugfix that needs to be backported to a previous version. --> ## What this PR does ### Screenshots <!-- REQUIRED for UI changes: attach screenshots or screen recordings demonstrating the visual impact of your changes. PRs with UI changes without screenshots will not be merged. --> ### Release note <!-- Write a release note: - Explain what has changed internally and for users. - Start with the same `type(scope):` prefix as in the PR title - Follow the guidelines at https://github.com/kubernetes/community/blob/master/contributors/guide/release-notes.md. --> ```release-note fix regression of broken auth by token to the cozy-dashboard ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Fixed a regression in JWK cache initialization where custom HTTP client configurations for cluster authentication were not being properly applied, ensuring secure cluster communication and service-account token handling work as intended. <!-- review_stack_entry_start --> [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/cozystack/cozystack/pull/2661) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2 parents e4f9a18 + 15c015c commit d0c12c6

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

  • packages/system/dashboard/images/token-proxy

‎packages/system/dashboard/images/token-proxy/main.go‎

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,31 +82,30 @@ func init() {
8282
Timeout: 10 * time.Second,
8383
}
8484

85-
// Create httprc client with custom HTTP client
86-
httprcClient := httprc.NewClient(
87-
httprc.WithHTTPClient(httpClient),
88-
)
85+
// jwx v3 / httprc v3 regression: jwk.Cache.Register *always* overrides
86+
// the HTTPClient for each Resource. The client from httprc.NewClient is
87+
// ignored; without an explicit jwk.WithHTTPClient on Register, jwk falls
88+
// back to its own plain http.Client which has neither our cluster CA nor
89+
// the SA bearer token, so the in-cluster JWKS fetch fails TLS verification
90+
// and the controller's Ready() never signals — Register blocks forever.
91+
// See [email protected]/jwk/cache.go:141-180.
92+
httprcClient := httprc.NewClient()
8993

90-
// Create JWK cache
9194
jwkCache, err = jwk.NewCache(ctx, httprcClient)
9295
if err != nil {
93-
jwkCacheErr := fmt.Errorf("failed to create JWK cache: %w", err)
94-
panic(jwkCacheErr)
96+
panic(fmt.Errorf("failed to create JWK cache: %w", err))
9597
}
9698

97-
// Register the JWKS URL with refresh settings
9899
if err := jwkCache.Register(ctx, jwksURL,
100+
jwk.WithHTTPClient(httpClient),
99101
jwk.WithMinInterval(5*time.Minute),
100102
jwk.WithMaxInterval(15*time.Minute),
101103
); err != nil {
102-
jwkCacheErr := fmt.Errorf("failed to register JWKS URL: %w", err)
103-
panic(jwkCacheErr)
104+
panic(fmt.Errorf("failed to register JWKS URL: %w", err))
104105
}
105106

106-
// Perform initial fetch to ensure the JWKS is available
107107
if _, err := jwkCache.Refresh(ctx, jwksURL); err != nil {
108-
jwkCacheErr := fmt.Errorf("failed to fetch initial JWKS: %w", err)
109-
panic(jwkCacheErr)
108+
panic(fmt.Errorf("failed to fetch initial JWKS: %w", err))
110109
}
111110

112111
log.Printf("JWK cache initialized with JWKS URL: %s", jwksURL)

0 commit comments

Comments
 (0)