We are currently using a third-party authentication provider implementing the OAuth2.0 protocol.
Essentially, the workflow is that the User is re-directed to the third-party site, where they sign in and are issued an access token. When a user requests a resource from our server, the user provides this access token to us as a Bearer [my_token]
in the Authorization
header field. We get this token on the backend and then need to identify/authenticate the user. In order to identify/authenticate the user based on this token, we make a request to the third-party with this token. The response contains information that identifies the user (a username).
This workflow is unfortunate, because it doubles the latency for every request that a user makes to our service. I.e. each request not only requires the round-trip time to our servers, but requires an intermediate round-trip request to the third-party from our servers before we can begin servicing the request.
What is a safe and performant way to prevent constant third-party round trip requests when using OAuth for authentication?