Skip to content

pkg/auth/oauth: factor shared non-caching refresher and lift duplicated helpers #5066

Closed as not planned

Description

@yrobla

Status: Absorbed into #5050

All scope from this issue has been addressed as part of #5050 (Extract shared OAuthTokenSource from pkg/registry/auth and pkg/llm).

Original context

Flagged in #5052 (review by @JAORMX). pkg/llm/tokensource.go introduced nonCachingRefresher, which does the same cfg.Exchange(ctx, "", opts...) dance as pkg/auth/oauth/resourceTokenSource (resource_token_source.go:88). The only meaningful difference is that resourceTokenSource.Token() short-circuits on r.token.Valid() (line 45), which is exactly what withPreemptiveRefresh needs to not happen.

What was done (in #5050)

Scope 1 — Non-caching refresher: NonCachingRefresher was already extracted to pkg/auth/oauth in #5052. resourceTokenSource delegates to it. pkg/llm.nonCachingRefresher was removed as part of the #5050 extraction — the shared type is used via pkg/auth/tokensource.

Scope 2 — Lifted helpers:

  • ensureOfflineAccess → tokensource.EnsureOfflineAccess in pkg/auth/tokensource
  • DeriveSecretKey → tokensource.DeriveSecretKey(prefix, url, issuer) (parameterized prefix) in pkg/auth/tokensource

Both helpers are now shared across pkg/llm and pkg/registry/auth; the duplicates have been deleted.

Activity

  1. added
    enhancement
    go
    on Apr 27, 2026
  2. yrobla commented on Apr 28, 2026

    @yrobla
    ContributorAuthor

    Closing in favour of #5050 which covers the same ground as a superset. The NonCachingRefresher extraction and the ensureOfflineAccess/DeriveSecretKey helper lifts are part of the shared OAuthTokenSource refactor scoped there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    authenticationenhancementgo

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions