Closed teddiebui closed 2 months ago
Developed a little bit which was integrated inside AuthenticationService..
Will develope it full scale later on..
After discussion, we found some issue
Key Error
decryption exception when key are changed.
Let's look at a typical study case:
Key Error
exception. In order to by pass this error, they must use the previous public key for the decryption for this token. Yes, and the straight forward solution is to somehow cache the previous key. By caching the keys, the microservie whenever facing the Key Error
exception, they can use the cached key to decrypt tokens.Key Error
exception. In order to understand the cause of that scenarior, we must have to look back at the flow. When you do so, you will conclude the problem with one question: "Under what scenarior, both keys wont decrypt the token?". Yes, and the answer is: those token encrypted with keys that no more being "current key" and "cached key", means their session has been expired throughout 2 rotations. Or simpler, their session is over 12 hours and expired. In that case, their token's corresponding public key wont be cached anymore, thus microservices now can't have any ways to validate the tokens. That would be very a suitable thing for those expired session: they need to login again!! and they will be! So the final solution for this scenarior is that, clients with expired token OR failed decryption with both "current key" and "cached key" will be identified as expired session, thus need to login again, so in your case you should return 400 code.Because the private key needs to be confidentials, then which service will hold this keys? Answer: the one who issue the TOken will hold the private key.
While in the development process, we found that AuthenticationService is hardly coupled with KeyVault, what is it cannot works without KeyVault and if this service is down, so as the AuthenticationService, so we will integrate the KeyVault inside AuthenticationService, make it a whole complete service
close first
KeyVault is a feature that enable Application that implementing cryptographic keys to be changed for every interval time, which extensively enhance the security aspect of an Application.
KeyVault in the scope of this Project
Implementation Strategy