Hi Paulo,
thanks for your reply!
> There is no easy solution for this. Mostly because there is (or there
> wasn't) any spec regarding key rotation when this was implemented.
Hmm, I see.
> What you can do is define a periodic task say, every hour or every day
> (depending on the granularity your application needs) that reloads the
> keys. This still does not solve the issue entirely as key invalidation
> can happen at any moment and if the old keys are not preserved for some
> leeway time you will be failing to authenticate in a the time between
> the key rotated and the key got reloaded.
At the moment the provider gives me the last three recently used keys,
but I don't know the provider's key rotation schedule, so this approach
is not possible in my case. Ignoring the unnecessary network traffic,
even checking every ten seconds would be unacceptable for users in my
opinion.
I probably could figure out the provider's regular schedule, but this
still does not account for out-of-schedule key renewals for whatever
reason (in all likelihood they won't occurr at all or at least
incredibly rarely, but the probability is not zero).
> I'm not sure you can/should rely on exceptions for this, since a
> malformed token (either due to new key, or bad intended behavior by an
> attacker) would now trigger the reload of keys. If these keys are loaded
> over the network and attacker could use this as an opportunity for DDoS
> the authorization server.
Yes, true. I could ensure that a key reload will not happen unless the
last attempt was at least e.g. ten seconds ago. What's the recommended
way of handling this?
So I'm probably best off implementing this myself or quite heavily
refactoring the library.
Cheers
Julian