-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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 the AccessToken in IdentityModelAuthenticationService. #4742
Conversation
var tokenResponse = await GetTokenResponse(discoveryResponse, configuration); | ||
|
||
if (tokenResponse.IsError) | ||
var cacheKey = CalculateCacheKey(discoveryResponse, configuration); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not including the GetDiscoveryResponse
call to the cached part? Should we always call it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I forgot it, I will cache it.
But can we use configuration.Authority + /connect/token
directly? Because this url is seem fixed(not sure), of course, developers can also rewrite the method to call the api.
|
||
public static string CalculateCacheKey(DiscoveryDocumentResponse discoveryResponse, IdentityClientConfiguration configuration) | ||
{ | ||
return discoveryResponse.TokenEndpoint + string.Join(",", configuration.Select(x => x.Key + ":" + x.Value)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of such a long key (which may have problems with cache providers), can we get MD5 (or use a better algorithm) hash of the string. I am just thiking and not sure about it. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the name of the key does not need to have any meaning, md5 is no problem.
Resolve #4603