2

パスの下にないすべての URL と/cobrandsパスワード/fdtの要求に対してそれを希望します。たとえば/fdt/name、http 認証を求められるべきではありません。

public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
 /** code **/

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.exceptionHandling().authenticationEntryPoint(entryPoint()).and()
                .authorizeUrls()
                .antMatchers("/**").hasAnyAuthority("wf_cobrand_lettura", "wf_cobrand_fdt")
                .antMatchers("/cobrands/*").permitAll()
                .antMatchers("/fdt/*").permitAll()
                .and()
                .httpBasic();

    }

}
4

1 に答える 1

2

マッチャーは順番に処理されるため、

.antMatchers("/**")

すべてのリクエストをキャッチし、残りの 2 つのマッチャーは評価されません。

このように言えば:

http.exceptionHandling().authenticationEntryPoint(entryPoint()).and()
            .authorizeUrls()
            .antMatchers("/cobrands/*").permitAll()
            .antMatchers("/fdt/*").permitAll()
            .antMatchers("/**").hasAnyAuthority("wf_cobrand_lettura", "wf_cobrand_fdt")
            .and()
            .httpBasic();
于 2013-07-26T09:44:16.123 に答える