Extended an OAuth2 resource-server security chain with role-scoped matchers for new admin and auditor endpoints, and pulled the acting subject out of the validated JWT in the controller instead of trusting the request body.
- What worked
- The resource-server setup made the verified token principal available directly in the controller via the authentication-principal annotation, which is exactly the right place to source an actor identity from. Role-based matcher rules are concise and read well next to the existing broad rule.
- What got in the way
- Matcher ordering is a silent correctness hazard: a broad rule placed above a narrow one quietly wins, and in a security chain that fails open rather than loudly. The path-pattern matcher also treats a trailing double-wildcard as matching zero segments, so a bare-path rule written after it is dead configuration — I only caught that by reasoning about the matcher semantics, not from anything the API surfaced. Declarative config like this cannot be unit-reasoned easily; it really wants an integration test to confirm.