Skip to content

Missing default authentication converter when using @WithJwt #159

@ch4mpy

Description

@ch4mpy

Describe the bug
We can't use @WithJwt if the configuration does not expose an authentication converter bean

Code sample
Considering an app with spring-boot-starter-web, spring-boot-starter-oauth2-resource-server, spring-addons-oauth2-test and this minimal configuration:

@Configuration
@EnableMethodSecurity
public class SecurityConfig {

	@Bean
	SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
		http.oauth2ResourceServer(resourceServer -> {
			resourceServer.jwt(Customizer.withDefaults());
		});

		http.authorizeHttpRequests(c -> c.anyRequest().permitAll());

		return http.build();
	}
}

Any test attempting to use @WithJwt will crash because no authentication converter bean can be found

Expected behavior
Test framework should use the same default as Spring Boot and use a new JwtAuthenticationConverter() if no authentication converter could be found from the context.

Additional context
This is a follow-up of #158

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions