Skip to content

ProviderManager should have a varargs constructor #7713

Closed
@jzheaux

Description

@jzheaux

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))

Metadata

Metadata

Assignees

Labels

in: coreAn issue in spring-security-coretype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions