I have created a basic JWT generator but need advice on a couple of aspects. I have been using JWT.io 's guides and the auth0/java-jwt libraries/repo to produce the tokens.
The JWTs are being signed with 2 different keys.
The refresh tokens are being signed using the RSA512 algorithm using a 4096bit key.
.sign(Algorithm.RSA512(rsaPublicKey, rsaPrivateKey));
The access tokens are being signed with a 1024 bit RSA key through the RSA256 algorithm.
.sign(Algorithm.RSA256(rsaPublicKey, rsaPrivateKey));
I have gone for this with the recommendations on "speed" as a 4096 bit verification process takes longer, but seeming as there a fewer requests for refresh tokens, the trade off for security seems fair.
On the other hand, the access tokens are verified at the resource server endpoints, and they are sent much more often, so I have opted for a shorter (256) signature which was preformed with a quicker 1024bit key.
I know the keys are "practically" impossible to break...but key rotation is recommended?
I hold the jks (keystore) in a private folder on the auth server and the resource servers. The keystore holds the 2 keypairs, one for the refresh token sign/verify and one for the access token sign/verify.
Do I need to refresh/form new keys? If so...how often? What is the recommended way to do this?
There can be multiple instances of the auth and resource microservices behind load balancers...so RAM generated keys are a no as they will not propagate between instances.
I have had a look at maybe having a "key-server" that can say create new keys and append them to the keystore and dish out the new jks file to update with new keypairs... similar to this:
So for example, every 15 seconds, the EC2 auth servers and resource servers ping the key-server requesting a copy of the current jks (and version check).
Any recommendations?
Thank you!