-
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
Changes from 1 commit
a1ca597
7892532
c509499
c5bfdb7
df8ad3b
b6cde3a
1f72c48
2eb0913
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System; | ||
using System.Linq; | ||
using IdentityModel.Client; | ||
using Volo.Abp.MultiTenancy; | ||
|
||
namespace Volo.Abp.IdentityModel | ||
{ | ||
[Serializable] | ||
[IgnoreMultiTenancy] | ||
public class IdentityModelTokenCacheItem | ||
{ | ||
public string AccessToken { get; set; } | ||
|
||
public IdentityModelTokenCacheItem() | ||
{ | ||
|
||
} | ||
|
||
public IdentityModelTokenCacheItem(string accessToken) | ||
{ | ||
AccessToken = accessToken; | ||
} | ||
|
||
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 commentThe 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 commentThe 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. |
||
} | ||
} | ||
} |
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.