CSE Roadmap

Core tier · about 9 hours · 17 parts

Part 2 of 17 · 2 min read

A token is a string; five checks make it mean something

A bearer token carries no truth on its own -- it is only as good as what the server checks before trusting it.

Think of a wristband at a festival. By itself it is just a strip of paper. The gate staff make it mean "this person may enter." They scan it, check the date printed on it, and compare it to tonight's colour.

In plain words: a resource server (the MCP server) accepts bearer tokens from a client, issued by a separate authorization server for one resource owner (the person), and a token is only meaningful once the server has checked its signature, issuer, audience, expiry and scope -- skip any one of the five and the token can be forged, borrowed, stale, or simply pointed at the wrong service.

A worked example. Against eight presented tokens, the careful example server answers: no token -> 401; garbage, wrong key, wrong issuer, wrong audience, no audience at all, or expired -> 401 invalid_token for all five; a valid token -> 200. Removing just the audience check lets a token issued for https://calendar.example/api work against the notes server anyway (200, data returned, where the careful server says 401). Removing the scope check lets a read-only token call the administrator's export (403 becomes a silent 200).

The key lines. From code/mini-auth/protected.py:

# from code/mini-auth/protected.py
if self.check_issuer and claims.get("iss") != self.issuer:
    return self._deny(401, challenge("invalid_token", description="wrong issuer"), "invalid token: wrong issuer")
if self.check_audience and claims.get("aud") != CANONICAL:
    return self._deny(401, challenge("invalid_token", description="token was not issued for this server"), "invalid token: wrong audience")
have = tokens.scopes(claims)

Read it as: each check is a separate if, with its own switch (self.check_issuer, self.check_audience). This lets the experiment turn exactly one off at a time. The five checks are independent controls, not one bundled "is this token OK" test. That is why removing any single one opens a specific, nameable hole rather than a vague weakening.

Resource server, client, authorization server

The resource server is the MCP server, which accepts tokens and answers 401/403. The client is the MCP host's connector, which runs the flow and holds the token. The authorization server is a separate service that signs the person in and issues tokens for one named resource.

Example: the notes server in the example is the resource server; its job is entirely the five-check list above, and nothing it does can make a token meaningful if the authorization server that issued it, or the audience it was issued for, was wrong in the first place.