0

I receive the following error when trying to access this URL http://localhost:8080/swagger-ui.html/

{"error":"Bad Request","message":"Token is empty or doesn't start with Bearer","timestamp":"2020-10-16T18:06:02.121550","status":400}

 @Override
  protected void configure(HttpSecurity http) throws Exception {
    http.cors()
        .and()
        .csrf()
        .disable()
        .exceptionHandling()
        .authenticationEntryPoint(unauthorizedHandler)
        .and()
        .sessionManagement()
        .sessionCreationPolicy(SessionCreationPolicy.STATELESS)
        .and()
        .authorizeRequests()
        .antMatchers("/v2/api-docs",
                "/configuration/ui",
                "/swagger-resources",
                "/configuration/**",
                "/configuration/security",
                "/swagger-ui.html",
                "/webjars/**",
                "/swagger-resources/configuration/ui",
                "/swagger-ui.html",
                "/swagger-resources/configuration/security")
        .permitAll()
        .anyRequest()
        .authenticated();

    // Add our custom JWT security filter
    http.addFilterBefore(jwtAuthFilter, UsernamePasswordAuthenticationFilter.class);
  }
hiddeneyes02
  • 2,562
  • 1
  • 31
  • 58
agm98
  • 1
  • 1
  • I suspect this is caused by your custom jwtAuthFilter. Can you post the code for it? I'm also curious what version of Spring Security you are using? Spring Security 5 has built in support for jwt authentication. – Rob Winch Oct 16 '20 at 18:58
  • https://stackoverflow.com/questions/37671125/how-to-configure-spring-security-to-allow-swagger-url-to-be-accessed-without-aut Check this out – VaibS Oct 16 '20 at 20:16

0 Answers0