0
我有使用spring-boot的swagger UI。我有一個無狀態的身份驗證設置,用於我的spring rest API,它基於每個API路徑的角色進行限制。限制對Swager UI的訪問
但是,我不確定我怎樣才能將<server_url>/swagger-ui.html
放在基本身份驗證之後。
UPDATE
我有以下websecurity通過WebSecurityConfig
@Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
httpSecurity
.csrf().disable()
.exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
.authorizeRequests()
.antMatchers("/sysadmin/**").hasRole("SYSADMIN")
.antMatchers("/admin/**").hasRole("ADMIN")
.antMatchers("/siteadmin/**").hasRole("SITEADMIN")
.antMatchers("/api/**").hasRole("USER")
.anyRequest().permitAll();
// Custom JWT based security filter
httpSecurity
.addFilterBefore(authenticationTokenFilterBean(), UsernamePasswordAuthenticationFilter.class);
}
一般而言,這是值得包括如何您目前有你的安全規定,使人們可以提供,對於設置工作的解決方案。有很多方法可以做到,但瞭解更多關於你的實施會有所幫助。 –
更新了我的問題 –