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 the AccessToken in IdentityModelAuthenticationService. #4742

Merged
merged 8 commits into from
Aug 12, 2020

Conversation

maliming
Copy link
Member

Resolve #4603

@maliming maliming added this to the 3.1 milestone Jul 13, 2020
@maliming maliming requested a review from hikalkan July 14, 2020 01:01
var tokenResponse = await GetTokenResponse(discoveryResponse, configuration);

if (tokenResponse.IsError)
var cacheKey = CalculateCacheKey(discoveryResponse, configuration);
Copy link
Member

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?

Copy link
Member Author

@maliming maliming Jul 17, 2020

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));
Copy link
Member

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?

Copy link
Member Author

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.

@maliming maliming requested a review from hikalkan August 11, 2020 09:41
@maliming maliming requested a review from hikalkan August 12, 2020 03:35
@hikalkan hikalkan merged commit 9aa165d into dev Aug 12, 2020
@hikalkan hikalkan deleted the maliming/CachetheAccessToken branch August 12, 2020 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Is it necessary to save access_Token to cache?
2 participants