Tia*_*sta 1 java spring-security springfox
我试图将 Spring 安全配置为仅阻止对 swagger 的请求,但是它阻止了所有 url。有谁知道如何只锁定 swagger 的 url 而其余的都不安全?
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable()
.authorizeRequests().anyRequest().permitAll()
.and()
.authorizeRequests()
.antMatchers("/swagger*/**").authenticated();
http.httpBasic();
}
Run Code Online (Sandbox Code Playgroud)
请尝试以下操作:
http.authorizeRequests()
.antMatchers("/swagger*/**").authenticated()
.anyRequest().permitAll()
.and()
.csrf().disable();
Run Code Online (Sandbox Code Playgroud)
这应该只验证 swagger 但允许其余的请求。
| 归档时间: |
|
| 查看次数: |
4096 次 |
| 最近记录: |