I use OAuth 2 for authorization and need to implement it in a load balanced cluster. I've considered a few approaches, but it seems there is no way around a centralized approach. Here are my thoughts:
1. Balancing using source IP
Caching the tokens on one server and balancing by IP would be ideal, however, the IP can not assumed to be static. So when the same user tries to access services that require authorization from another IP with a valid token, it will fail, because it is not cached on this machine. Also other devices logged in with this user will not reach the same machine.
2. Balancing using a load balancing cookie
Also not really an option, since it cannot be assumed that every client implements cookie storage.
3. Balancing using the Authorization
header
Balancing by hashing the Authorization: Bearer
token header is problematic, because the first request (for requesting the authorization token) has no Authorization
header, thus, the following request might not hit the same instance.
My current approach is to use a central Redis instance for authorization token storage. Is there an option left, where a centralized approach can be avoided?