Bom dia.
Quando acesso o caminho do Swagger, está estourando o seguinte erro:
java.lang.IllegalArgumentException: JWT String argument cannot be null or empty.
Ele esta passando pela classe (AutenticacaoTokenFilter) de filtro do token.
Implementações das classes:
@Configuration
public class SwaggerConfigurations {
@Bean
public Docket api(){
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("br.com.formula.bancaria.api"))
.paths(PathSelectors.ant("/**"))
.build()
.ignoredParameterTypes(Usuario.class)
.globalOperationParameters(
Arrays.asList(
new ParameterBuilder()
.name("Authorization")
.description("Header para Token JWT")
.modelRef(new ModelRef("string"))
.parameterType("header")
.required(false)
.build()
)
);
}
}
===========================================================
@EnableWebSecurity
@Configuration
public class SecurityConfigurations extends WebSecurityConfigurerAdapter {
@Autowired
private TokenService tokenService;
@Autowired
private UsuarioRepository usuarioRepository;
@Autowired
private AutenticacaoService autenticacaoService;
@Override
@Bean
protected AuthenticationManager authenticationManager() throws Exception {
return super.authenticationManager();
}
//Configura autenticação
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(autenticacaoService).passwordEncoder(new BCryptPasswordEncoder());
}
// Configura autorização
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers(HttpMethod.POST, "/auth").permitAll()
.anyRequest()
.authenticated()
.and()
.csrf().disable()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.addFilterBefore(new AutenticacaoTokenFilter(tokenService, usuarioRepository),
UsernamePasswordAuthenticationFilter.class);
}
// Configura os arquivos estaticos
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/**.html", "/v2/api-docs", "/webjars/**", "/configuration/**", "/swagger-resources/**");
}
}
=================================================
@SpringBootApplication
@EnableSpringDataWebSupport
@EnableCaching
@EnableSwagger2
public class ApiApplication {
public static void main(String[] args) {
SpringApplication.run(ApiApplication.class, args);
}
}
O caminho do Swagger não era para estar livre, sem precisar passar pelo filtro?