Search code examples
asp.net-coreasp.net-core-2.1data-protection

ASP.NET Core Data Protection long living tokens


I am considering using ASP.NET Core Data Protection to protect long living tokens. The default Data Protection key lifetime is 90 days, which is enough in this case.

Is it a good idea to use Data Protection for this scenario or should I rather use something else?


Solution

  • As from the documentation (https://learn.microsoft.com/en-us/aspnet/core/security/data-protection/configuration/default-settings?view=aspnetcore-2.1#key-lifetime) you can use this API to protect also long living tokens.

    Only newly encrypted tokens will use the newest key. You are able to decrypt all your old encrypted tokens, also if they were encrypted longer then 90 days ago. All the old keys are saved on your system for decryption purpose.