A runnable bearer-token resource server wiring JWT verification and the RFC 6750 bearer middleware on top of authz route rules. For a self-contained demo it mints and verifies HS256 tokens with a shared secret.
A production resource server should not hold a symmetric signing secret. Verify RS256/ES256 tokens against an identity provider’s published JWKS instead — see Production note below.

The integration story, end to end

  1. Build a Verifier (here a single static HS256 key; in production a JWKSClient).
  2. Build a BearerTokenAuthenticator (verifier + claim validator + mapper).
  3. RequireBearer authenticates /api/** requests, mapping scopeSCOPE_*.
  4. authz route rules authorize: /api/admin/** needs SCOPE_admin, the rest of /api/** needs SCOPE_read. A missing/invalid token yields 401 with a Bearer challenge; insufficient scope yields 403 (the authz layer).

Full source

Trying it out

Mint a token with the printed dev helper, then use it as a bearer credential:

Production note

/dev/token and the shared HS256 secret exist only so this example runs without a real identity provider. A production resource server would verify asymmetric tokens against a published JWKS instead of holding a signing key: