2016-03-27 6 views
2

安全でないコントローラエンドポイント/foo/barを私のアプリケーションに追加しようとしていますが、呼び出すときはいつでも401 Unauthorizedとなります。ここでHttpSecurityの設定 - すべてが依然として基本認証を要求しています

は私WebSecurityConfigurerAdapterです:

http 
    .authorizeRequests() 
     .antMatchers("/foo/**").permitAll() 
    .and() 
    .formLogin() 
     .loginPage("/login").permitAll() 
    .and() 
    .requestMatchers() 
     .antMatchers("/login", "/oauth/authorize", "/oauth/confirm_access") 
    .and() 
    .authorizeRequests() 
     .anyRequest().authenticated(); 

Somoneのは、親切に私が何をしないのです指摘するだろうか? 1つのauthorizeRequestsセクションで

+0

/fooの/バーは、GETやPOSTまたは両方に許可すべきか? – Sanj

+0

@Sanj認証メカニズムについては問題はありません。メソッドはRequestMappingによって除外されます – Benedictus

答えて

2

を連結する複数のantMatchers

@Override 
protected void configure(HttpSecurity http) throws Exception { 
    http 
      .authorizeRequests() 
       .antMatchers("/foo/**").permitAll() 
       .anyRequest().authenticated() 
      .and() 
      .formLogin().loginPage("/login").permitAll(); 
} 
1

は、私はあなたのconfighierarchyを何かわからないが、それはないと思えます。

試してみてください。

http 
    .formLogin() 
     .loginPage("/login") 
     .and() 
    .authorizeRequests() 
     .antMatchers("/foo/**").permitAll() 
     .anyRequest().authenticated(); 
関連する問題