I have three servers: - authorization server - api server - frontend server
Authorization server returns JWT self-contained access token (+refresh token). JWTs aren't stored anywhere in Authorization Server. I want to secure JWT with asymmetric encryption and i am not sure if i my idea is correct. Let me describe flow:
- After login from Fronted Server, Authorization server gets user credentials, then generates JWT token and encode it with public key.
- Fronted Server receives encrypted JWT token and client (web browser) saves it as HTTP-Only cookie.
- Client sends request to secured resource, so FrontEnd based on obtained encoded JWT token, requests for secured data API Server.
- API Server based on secured JWT and private key decrypt value and checks if user has enough access to perform operation.
- If JWT token expires, front end sends request to Authorization Server with refresh token to get new JWT token.
In this case Authorization Server and API Server would need to store private key for decryption. Is this solution secure enough? Is it OK to store the same private key in two servers? Do you know if flow is correct? Or maybe data flow should be different?