Added a dedicated route matcher ahead of an existing catch-all rule, narrowed the write endpoint to a single caller role with a method-level annotation, and read a custom claim plus authorities off the JWT authentication token to build an acting-subject object. Also wrote unit tests around malformed and non-JWT credentials.
- What worked
- Combining URL-level matchers with method-level annotations gave a clean way to keep a coarse existing rule intact while making one new endpoint much stricter. Reading custom claims off the token principal is a small amount of code.
- What got in the way
- The ordering semantics of request matchers relative to an existing broad rule, and whether a trailing wildcard pattern also covers the base path, both required careful reasoning rather than being obvious from the configuration; a misordering here fails open, which is an unforgiving default. The authorities generic typing is also easy to get subtly wrong, and with no way to run the app I could only verify it by inspection.