如何解决无需身份验证即可访问Swagger UI Spring Boot
尝试访问此URL http:// localhost:8080 / swagger-ui.html /
时收到以下错误{“错误”:“错误请求”,“消息”:“令牌为空或开头不为 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-resources/configuration/security")
.permitAll()
.anyRequest()
.authenticated();
// Add our custom JWT security filter
http.addFilterBefore(jwtAuthFilter,UsernamePasswordAuthenticationFilter.class);
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。