Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache keys in ITokenValidableExtension.AreTokensValidAsync #948

Open
meum opened this issue Dec 16, 2024 · 2 comments
Open

Cache keys in ITokenValidableExtension.AreTokensValidAsync #948

meum opened this issue Dec 16, 2024 · 2 comments

Comments

@meum
Copy link

meum commented Dec 16, 2024

Is your feature request related to a problem? Please describe the problem.

Every time I call AreTokensValidAsync, I see two requests to login.microsoftonline.com. One to /common/.well-known/openid-configuration and one to /common/discovery/keys.
I assume these keys don't change very often, so they should be cached.

Describe the solution you'd like.

I would like the keys to be cached, to avoid these two requests being repeated so often.

Additional context?

No response

@meum meum added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:feature New experience request labels Dec 16, 2024
@andrueastman
Copy link
Member

Thanks for raising this @meum

Taking a look at this, this looks to be caused by the call here to configurationManager.GetConfigurationAsync()

https://github.com/microsoftgraph/msgraph-sdk-dotnet-core/blob/fa698f16386655667a0ad54dbea318112301a123/src/Microsoft.Graph.Core/Extensions/ITokenValidableExtension.cs#L70C17-L70C30

Arguably if the same wellKnownUri parameter is used, it would be useful to cache this property to avoid repeated fetching of configuration whenever the function is called.

Any chance this is something you'd be willing to submit a PR for?

@andrueastman andrueastman added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed status:waiting-for-triage An issue that is yet to be reviewed or assigned labels Jan 13, 2025
@meum
Copy link
Author

meum commented Jan 20, 2025

Yes, I can try to make a PR. Is there caching elsewhere in Microsoft.Graph.Core I can look at?

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close labels Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants