Closed
Description
oauth2ResourceServer()
introduces a couple of authenticationManager()
methods for complete control over the authentication mechanism:
http
.oauth2ResourceServer()
.jwt()
.authenticationManager(...)
This can be leveraged to construct a custom JwtAuthenticationProvider
:
AuthenticationProvider jwt = new JwtAuthenticationProvider(... ;
http
.oauth2ResourceServer()
.jwt()
.authenticationManager(jwt::authenticate)
However, the method reference shortcut may seem a bit terse for some tastes.
As an alternative, code can construct an instance of ProviderManager
:
AuthenticationProvider jwt = new JwtAuthenticationProvider(... ;
http
.oauth2ResourceServer()
.jwt()
.authenticationManager(new ProviderManager(Arrays.asList(jwt)))
This could be improved by adding a varargs constructor to ProviderManager
:
AuthenticationProvider jwt = new JwtAuthenticationProvider(... ;
http
.oauth2ResourceServer()
.jwt()
.authenticationManager(new ProviderManager(jwt))