0

I have setup a spring boot project using spring boot version 3.3.5 and added springdoc version 2.6.0, this project also includes spring security and my Security config is as follow:

  @Bean
  public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
    http.csrf(AbstractHttpConfigurer::disable)
        .sessionManagement(
            session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
        .authorizeHttpRequests(
            auth ->
                auth.requestMatchers("/actuator/**")
                    .permitAll()
                    .requestMatchers("/v3/api-docs/**", "/swagger-ui/**", "/swagger-ui.html")
                    .permitAll()
                    .requestMatchers("/login")
                    .permitAll()
                    .requestMatchers("/reset-password")
                    .permitAll()
                    .requestMatchers("/validate-account")
                    .permitAll()
                    .requestMatchers("/forgot-password")
                    .permitAll()
                    .requestMatchers("/validate-token")
                    .permitAll()
                    .anyRequest()
                    .authenticated());
    http.authenticationProvider(authenticationProvider());
    http.addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class);
    return http.build();
  }

The security config class is annotated with both @Configuration, @EnableWebSecurity and @EnableMethodSecurity(securedEnabled = true, jsr250Enabled = true)

Based on their official doc, including just the springdoc dependency it should expose the open api swagger definition under the path: /v3/api-docs which can be accessed as shown from the image but returns an empty response: enter image description hereenter image description here

For the record, I'm using the following dependency 'cause I don't need the UI:

        <dependency>
            <groupId>org.springdoc</groupId>
            <artifactId>springdoc-openapi-starter-webmvc-api</artifactId>
            <version>${springdoc.version}</version>
        </dependency>
2
  • Do you have any demo app code where we can replicate this behavior? Commented Nov 22, 2024 at 4:31
  • Can you add "/favicon.ico" next to "/swagger-ui.html" for permitAl()? Commented Mar 26 at 23:08

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.