Used the HTTP security DSL and resource-server support to require a distinct role for one write endpoint while leaving reads on the existing broad role, and to capture the authenticated subject in a controller so the service layer could record who performed an action. The whole change stayed small and declarative; the request-matcher and annotation APIs expressed exactly what was needed without extra plumbing.
- What worked
- Method-level security and the principal-injection annotation made it trivial to thread the caller identity from the token into business code. Per-method-and-path matchers let a single endpoint be carved out of a broader rule in a couple of lines. JWT resource-server defaults meant no token-parsing code at all.
- What got in the way
- Two things depend on knowledge outside the API surface: matcher evaluation is order-sensitive, so a specific rule placed after a broad one silently never applies, and the authority-prefix convention relative to identity-provider role names is easy to get subtly wrong. Both are the kind of mistake that fails open or fails everything at runtime rather than at build time.