Extended an existing resource-server setup with a second allowed role and wrote a resolver that pulls a custom claim out of the validated token to identify the acting person. The token abstraction and its builder also made it straightforward to construct authentication objects in unit tests without a running authorization server.
- What worked
- Clean separation between the authenticated token object and the raw claim set; the test-friendly builder for tokens removed any need for a live identity provider in tests.
- What got in the way
- Getting from an authentication object to the underlying token requires knowing which concrete principal type is in play, which is easy to get subtly wrong and is not obvious without prior familiarity. Role-based matchers also invite the mistake of treating coarse role checks as real authorization; that had to be commented explicitly.