【发布时间】:2019-11-02 12:19:32
【问题描述】:
我正在尝试同时使用 Swagger 和 Auth0。当我点击http://localhost:8080/swagger-ui 时,仅 Swagger 就可以正常工作。但是,在配置 auth0.它显示403 Forbidden Error
我正在使用带有 gradle 的 spring boot。我已经尝试使用 antMatchers 函数来允许招摇和所有。
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Value(value = "${auth0.apiAudience}")
private String apiAudience;
@Value(value = "${auth0.issuer}")
private String issuer;
@Override
protected void configure(HttpSecurity http) throws Exception {
JwtWebSecurityConfigurer
.forRS256(apiAudience, issuer)
.configure(http)
.cors().and().csrf().disable().authorizeRequests()
.antMatchers("/v2/api-docs", "/swagger-resources/configuration/ui", "/swagger-resources", "/swagger-resources/configuration/security", "/swagger-ui.html", "/webjars/**").permitAll()
.and()
.authorizeRequests()
.anyRequest()
.authenticated()
.and()
.csrf().disable();
}
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/v2/api-docs", "/swagger-resources/configuration/ui", "/swagger-resources", "/swagger-resources/configuration/security", "/swagger-ui.html", "/webjars/**");
}
}
因为我正在学习并且对 java 和 spring boot 很陌生。我希望http://localhost:8080/swagger-ui 即使没有安全措施也足够了。
【问题讨论】:
标签: java spring-boot gradle swagger-ui auth0