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

Configure TTL to redis keys #34

Closed bmenezes05 closed 4 years ago

bmenezes05 commented 4 years ago

I am using IdentityServer4 configured to use the Redis as an operational store. I would like to know if its possible to configure an expiration time for keys saved?

This is my configuration: .AddOperationalStore(options => { options.RedisConnectionString = settings.RedisConnectionString; options.KeyPrefix = PREFIX_OPERATIONAL_STORE; options.Db = 0; }

I'm using Implicit Flow to authenticate and my keys are being saved with TTL -1.

Can you help me?

AliBazzi commented 4 years ago

Hi,

The library will respect the ttl for each key given by identity server 4, so you don't have to configure that manually from your side as a consumer of the library.

Can you elaborate more ?

seygi commented 4 years ago

@AliBazzi where can i configure the ttl for each client keys? Do you know what is the property?

Can you help us please?

AliBazzi commented 4 years ago

@seygi you can configure ttl of each client on Identity server side, not on the library side you can look here: https://identityserver4.readthedocs.io/en/latest/reference/client.html

bmenezes05 commented 4 years ago

@AliBazzi According of documentation:

  1. for Key(SubjectId) and Key(SubjectId,ClientId) the expiration is not set, since the same and only store type is persisting the grants regardless of their type

I have a lot of users authenticating in my app and I don't want to keep their data in my storage for more than one month. Is there a way to set an expiration time in this case?

AliBazzi commented 4 years ago

nope, there is no way, you rely on your eviction policy configured in Redis.

AliBazzi commented 4 years ago

I will close this, feel free to open if you have more questions