【发布时间】:2019-12-28 03:21:24
【问题描述】:
我在 ZUUL 应用程序中使用 Spring Security,我的 API 控制对我的微服务的所有访问。使用过滤器可以允许每次登录的特定路由,在过滤器里面我有对象 HttpSecurity 通过方法“.antMatchers”进行控制。
例如:
protected void configure(HttpSecurity http) throws Exception {
http.cors().and().csrf().disable();
http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
http.authorizeRequests()
.antMatchers("/**/swagger-ui.html").permitAll()
.antMatchers("/**/webjars/**").permitAll()
.antMatchers("/**/swagger-resources/**").permitAll()
.antMatchers("/**/csrf/**").permitAll()
.antMatchers("/**/v2/**").permitAll()
.antMatchers("/**/signin/**").permitAll()
.antMatchers("/**/microservice/chatws/**").permitAll()
.antMatchers("/**/microservice/*swagger*").permitAll()
.antMatchers("/**/microservice/swagger-resources/**").permitAll()
.antMatchers("/**/microservice/v2/**").permitAll()
.antMatchers("/**/microservice/webjars/**").permitAll()
.antMatchers("/**/microservice/csrf/**").permitAll()
.anyRequest()
.authenticated();
http.apply(new JwtTokenFilterConfigurer(jwtTokenProvider));
}
我想允许在任何语言环境中、在乞讨、中间或结尾处有“招摇”的所有路线。我在考虑类似 String 类的方法 contains,如果包含“swagger”,那么 permitAll。
【问题讨论】:
标签: spring spring-boot spring-security