A custom authentication object is an application-defined authentication-token subtype that preserves identity and authorities while adding data needed for authorization. For JWT resource servers, extend JwtAuthenticationToken and expose fields such as priority through the SecurityContext. section 15.2
Custom authentication in a test
Tests can construct a specific Authentication type by defining a custom annotation, implementing WithSecurityContextFactory, linking them with @WithSecurityContext, and applying the annotation to a MockMvc test. section 18.3
