AliBazzi / IdentityServer4.Contrib.RedisStore

A persistence layer using Redis DB for operational data and for caching capability for Identity Server 4
https://www.nuget.org/packages/IdentityServer4.Contrib.RedisStore
MIT License
137 stars 48 forks source link

Questions about persisted store #36

Closed lyubomirr closed 4 years ago

lyubomirr commented 4 years ago

Hi, I have three questions regarding the persisted store which are not clear to me enough.

First question is on "GetAllAsync" method why do you check for keys which have no value and delete them. Is this possible to happen and why?

Second, why do you check the TTL for the (subjectId) and (subjectId, clientId) cache and extend it only if it has less TTL but for set (subjectId, clientId, type) you always set the new expiration without checking? Is it because all the items inside have the same TTL and your last is always the one with most TTL?

And lastly in method "StoreAsync" you check if (!string.IsNullOrEmpty(grant.SubjectId)) . Is it possible to have grants without subjectid?

Sorry, if questions are stupid but I just want to know what is really happening. Thanks in advance!

AliBazzi commented 4 years ago

Hi @lyubomirr

First question is on "GetAllAsync" method why do you check for keys which have no value and delete them. Is this possible to happen and why?

Yes, because Redis sets may contain dangling keys that we need to cleanup.

why do you check the TTL for the (subjectId) and (subjectId, clientId) cache and extend it only if it has less TTL but for set (subjectId, clientId, type) you always set the new expiration without checking? Is it because all the items inside have the same TTL and your last is always the one with most TTL?

it's because I need to expire the whole set entry in Redis if it's not renewed with another entry on StoreAsync.

And lastly in method "StoreAsync" you check if (!string.IsNullOrEmpty(grant.SubjectId)) . Is it possible to have grants without subjectid?

yes, using client_credentials grant will not yield a sub in the access token.

lyubomirr commented 4 years ago

Thank you very much for your answers!

AliBazzi commented 4 years ago

you are welcome !