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

Token credential with local cache #3835

Closed
Jinming-Hu opened this issue Jul 16, 2022 · 2 comments · Fixed by #4024
Closed

Token credential with local cache #3835

Jinming-Hu opened this issue Jul 16, 2022 · 2 comments · Fixed by #4024
Assignees
Labels
Azure.Identity Client This issue points to a problem in the data-plane of the library. feature-request This issue requires a new behavior in the product in order be resolved.
Milestone

Comments

@Jinming-Hu
Copy link
Member

We got a feature request from one of our customers.
Basically they're using token credential for authorization and they need different client options (like retry options) for different kind of requests so they need to initialize many clients for those requests.
The problem is the access token is cached in BearerTokenAuthenticationPolicy, which is created when initializing a blob client. So the access token cannot be shared among these blob clients even though requests are sent to the same storage account.

I'm looking for some way to fix this problem and while I'm looking at .Net code, I found SharedTokenCacheCredential. I think such a credential with local cache can work in this scenario.

@RickWinter @antkmsft What do you think? Can we provide the same credential in C++?

@Jinming-Hu Jinming-Hu added Client This issue points to a problem in the data-plane of the library. Azure.Identity labels Jul 16, 2022
@antkmsft
Copy link
Member

@Jinming-Hu, please help me to understand the request better. It sounds like what you want is to minimize token requests and token refresh requests. I.e. a case 100 clients are using the same credential, you call method of one of them, and it gets the token to reuse within the next hour. But currently that would be reused with only that one client, while all other 99 clients will send the same token request. And in an hour, all 100 of them will need to send a request to refresh the token.
What you would like to see is one request per (tenant id, client id, auth scope) to get the token initially, and a single request to refresh the token, not 100 of them. The cash is "local" - it only lives during process run time and is not shared between processes, and is not persistent after process quits.

Is this accurate?

@Jinming-Hu
Copy link
Member Author

it only lives during process run time and is not shared between processes, and is not persistent after process quits.

Cache within the process can meet this customer's requirement. I think it's much easier to implement because the cache can reside in memory, it involves no file operations or inter-process communication or synchronization. It's good enough for now.

But we should be aware of the fact that .Net has a more advanced implementation. Cache can be shared across processes with .Net. We should keep this in mind when designing the API interface, so that it can be easily extended if we do have such a feature request in the future.

@RickWinter RickWinter removed their assignment Aug 30, 2022
@RickWinter RickWinter added the feature-request This issue requires a new behavior in the product in order be resolved. label Aug 30, 2022
@RickWinter RickWinter changed the title Feature request: Token credential with local cache Token credential with local cache Oct 4, 2022
@RickWinter RickWinter added this to the 2023-04 milestone Oct 18, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Apr 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Azure.Identity Client This issue points to a problem in the data-plane of the library. feature-request This issue requires a new behavior in the product in order be resolved.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants