【发布时间】:2016-11-02 14:00:12
【问题描述】:
我有一个使用 spring security oauth2 的项目。
HttpSecurity 配置如下所示:
http.antMatcher("/**").authorizeRequests().antMatchers(RESOURCE_LOCATIONS).permitAll().and()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER)
.and().httpBasic().disable()
.authorizeRequests().anyRequest().authenticated();
通过此设置,除 RESOURCE_LOCATIONS 下的 url 之外的任何请求都受 ouath2 协议保护。对于这些请求,HTTP Basic 已关闭。
现在我想保护 /internal/** 下面的网址,但只能通过 HTTP 基本身份验证。
我正在尝试类似的方法或类似的方法:
http.antMatcher("/**").authorizeRequests().antMatchers(RESOURCE_LOCATIONS).permitAll().and()
.antMatcher("/internal/**").httpBasic().and() //<--ADDED THIS LINE
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER)
.and().httpBasic().disable()
.authorizeRequests().anyRequest().authenticated();
但令人惊讶的是,所有请求都是公开的并且没有基本身份验证。
有没有人提示解决这个问题?
BR, 迈克尔
【问题讨论】:
标签: java spring security spring-security