Spring Security 5.1 provides a number of new features. Below are the highlights of the release.
authorization_code grant support
client_credentials grant support
AccessDeniedHandler by RequestMatcher
Added OAuth2 support
@WithUserDetails now works with ReactiveUserDetailsService
Added support for the following HTTP headers
Improvements for @AuthenticationPrincipal
errorOnInvalidType
BadCredentialsException
@WithMockUser supports customizing when the SecurityContext is setup in the test.
For example, @WithMockUser(setupBefore = TestExecutionEvent.TEST_EXECUTION) will setup a user after JUnit’s @Before and before the test executes.