Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Security] Set OIDC JWKS cache TTL from provider headers#62369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@Ali-HENDA
Copy link
Contributor

@Ali-HENDAAli-HENDA commentedNov 12, 2025
edited by nicolas-grekas
Loading

QA
Branch?7.4
Bug fix?yes
New feature?no
Deprecations?no
IssuesFix#62340
LicenseMIT

This PR aligns the OIDC JWKS discovery cache with OpenID Connect best practices by making it dynamic and respecting provider cache headers.

Before

  • The JWKS was cached with a fixed lifetime, ignoring the OIDC provider’s cache policy.

After

  • The cache TTL is now automatically determined from the provider response:
    • PreferCache-Control: max-age
    • Fallback toExpires
    • When multiple providers are configured, the lowest TTL is applied.

@Ali-HENDAAli-HENDAforce-pushed thefeature/oidc-auto-cache-expiry branch 2 times, most recently from38cd272 to981d813CompareNovember 13, 2025 00:10
Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I'd consider this as a bugfix for 7.4

@Ali-HENDAAli-HENDAforce-pushed thefeature/oidc-auto-cache-expiry branch from981d813 tocf49d44CompareNovember 13, 2025 20:58
@nicolas-grekasnicolas-grekasforce-pushed thefeature/oidc-auto-cache-expiry branch fromcf49d44 to8898652CompareNovember 14, 2025 09:55
@nicolas-grekasnicolas-grekasforce-pushed thefeature/oidc-auto-cache-expiry branch from8898652 to61acbf1CompareNovember 14, 2025 09:57
@nicolas-grekas
Copy link
Member

Thank you@Ali-HENDA.

@nicolas-grekasnicolas-grekas merged commit42a8072 intosymfony:7.4Nov 14, 2025
12 checks passed
This was referencedNov 16, 2025
* The cache entry lifetime is automatically adjusted based on the lowest TTL
* advertised by the providers (via "Cache-Control: max-age" or "Expires" headers).
*
* @internal this method is public to enable async offline cache population
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Where is this method called publicly ?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Because per PR#30572, async recomputation via Messenger only works with callables of the form [$service, 'publicMethod'], so the callback must be public.

nicolas-grekas reacted with thumbs up emoji
}

$jwkSetResponses = [];
foreach ($client->stream($configResponses)as$response =>$chunk) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is broken IMO:

  • $client might be undefined (if the loop is empty)
  • if the clients are different, there is no guarantee that callingstream will work. Responses must be streamed with the client that created them.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

After checking, this issue was already present before my patch. I didn't notice it when working on the cache handling. You're absolutely right to point it out.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@Ali-HENDA up to send a PR fixing this?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Sure, I’ll open a PR for this.

nicolas-grekas reacted with heart emoji
Comment on lines +348 to +351
$this->assertSame('user-cache-control',$handler->getUserBadgeFrom($token)->getUserIdentifier());
$this->assertSame(2,$requestCount);
$this->assertSame('user-cache-control',$handler->getUserBadgeFrom($token)->getUserIdentifier());
$this->assertSame(2,$requestCount);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Why are these lines duplicated?

And does this test actually test that the cache-control header is used as cache TTL?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The lines are duplicated because the first call fills the cache (2 requests) and the second call verifies that the cached JWKS is reused (request count stays at 2). The TTL is tested implicitly: since the second call happens
within the max-age window, it must be a cache hit.

Comment on lines +388 to +391
$this->assertSame('user-expires',$handler->getUserBadgeFrom($token)->getUserIdentifier());
$this->assertSame(2,$requestCount);
$this->assertSame('user-expires',$handler->getUserBadgeFrom($token)->getUserIdentifier());
$this->assertSame(2,$requestCount);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Same here.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Same reason as above

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

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@stofstofstof left review comments

@chalasrchalasrAwaiting requested review from chalasrchalasr is a code owner

+1 more reviewer

@jdreesenjdreesenjdreesen left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

7.4

Development

Successfully merging this pull request may close these issues.

OIDC Discovery - verification of key id/cache invalidation

5 participants

@Ali-HENDA@nicolas-grekas@jdreesen@stof@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp