mirror of
https://github.com/fatedier/frp.git
synced 2026-05-15 08:05:49 -06:00
[PR #5173] [CLOSED] auth/oidc: cache OIDC access token and refresh before expiry #5154
Labels
No labels
In Progress
WIP
WaitingForInfo
bug
doc
duplicate
easy
enhancement
future
help wanted
invalid
lifecycle/stale
need-issue-template
need-usage-help
no plan
proposal
pull-request
question
todo
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/frp#5154
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/fatedier/frp/pull/5173
Author: @shani1998
Created: 2/11/2026
Status: ❌ Closed
Base:
dev← Head:fix/oidc-token-caching📝 Commits (1)
aac0cbbauth/oidc: cache access token to avoid redundant requests on each heartbeat📊 Changes
2 files changed (+60 additions, -14 deletions)
View changed files
📝
pkg/auth/oidc.go(+14 -14)📝
pkg/auth/oidc_test.go(+46 -0)📄 Description
WHY
When
auth.additionalScopesincludesHeartBeats, every heartbeat callsclientcredentials.Config.Token(ctx)which creates a newoauth2.ReuseTokenSourceon each invocation — the token is never actually reused between calls. This causes
a redundant HTTP request to the OIDC token endpoint on every heartbeat interval.
Changes
Config.TokenSource(ctx)once at init to create a persistentoauth2.TokenSourcethat caches the token and only refreshes when it approaches expiry
oauth2.ReuseTokenSourceWithExpiryfor a configurable early-refresh buffertokenRefreshAdvanceDurationconfig option (default: 300s) to control howearly before expiry the token is refreshed
multiple login and ping calls
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.