Backend Engineer: Accessing Multiple Resource Servers With OAuth 2.0

2017-10-03 13:05:00+00:00

An end user client app needs to be able to access user facing services without intermediary.

It doesn't make senses that client app need to go through game player state service in order to fetch user guide article.

So instead of doing this:

We should be doing this:

By changing the component dependency, some network and CPU loads have been removed from the Game Playing State Service.

As the Wiki Service will be accessible via the Internet the same way the Game Playing State Service does, we need to put some access security on it.

When accessing the Wiki Service, we will use the same access token being used to access the Game Playing State Service.

Doing that, we only need to authorize the client once, and then use the resulting access token to access all public facing services we have.

How do we authorize a client app?

We need to have a login form user interface to allow users to enter username and password.

When the entered username and password are valid, the client app is authorized to access the resources on behalf of that user.

Who handles the checking of username and password?

Is it the Game Playing State Service? Or is it the Wiki Service?

The truth is that we need another service to check username and password. It called the Authorization Service.

The Authorization Service

After adding an Authorization Service, the component dependency is becoming like this:

Client Side App will access Authorization Server to exchange username and password with an access token.

Using the access token, Client Side App can access resources that are controlled by Game Playing State Service and Wiki Service.

By sending introspection request to Authorization Server, the Game Playing State Server and Wiki Server check the validity of the access token they have received from Client Side App.

References

Audience-Scoped JWT Access Tokens (`aud`) Across Federated OAuth 2.0 Resource Servers

Prevent token confused-deputy attacks by validating resource-specific `aud` claims and fine-grained scopes at every microservice gateway.


About the Author — Hire Aldian Fazrihady (Cloud Engineer, GCP Professional Cloud Architect, GCP Professional Data Engineer, Backend, AI & Full Stack Engineer)

Aldian Fazrihady is a Top-Rated Senior Cloud Engineer, GCP Professional Cloud Architect (Google Cloud Certified), GCP Professional Data Engineer (Google Cloud Certified), Backend Engineer (Python, Django, FastAPI, Go, PostgreSQL), AI Application Engineer (LLMs, RAG, MCP, Google ADK, LangGraph), and Full Stack Engineer (React, Next.js, TypeScript) with 15+ years of production software engineering experience.

Hire Aldian Fazrihady on Upwork | Book 1-Day Programming Service ($100 USD / Rp 1.000.000) | View Live AI Portfolio | Send a Direct Message

Related Engineering Articles

Engineering Role Pillar Guides & Category Hubs