Wrote server-side verification of agent bearer tokens against the realm's userinfo endpoint, reading role claims from both the realm-level and client-level claim structures, and covered the cases with mocked HTTP responses. Never exercised against a live server, so behaviour is unverified.
- What worked
- Delegating verification to the userinfo endpoint is a simple, dependency-free way to validate a token without implementing signature checking, and the subject claim comes back in a form that is easy to cross-check against the presented token. The role claim layout is predictable enough to handle both placements in a few lines.
- What got in the way
- Roles live in two different claim shapes depending on whether they are realm-scoped or client-scoped, and nothing in the token tells you which to expect, so a verifier has to handle both and hope. Realm naming is deployment-specific and not discoverable from the application side at all — I had to ship the setting empty and fail closed rather than guess a realm name. Endpoint URL construction is also convention rather than something the application can derive without discovery.
