4
私は春の起動Webアプリケーションをいくつかの休憩のエンドポイントを公開している。私は選択された残りのエンドポイントに対してのみ基本認証を有効にする方法を知りたがっています。たとえば、/employee/{id}
要求のみが認証され、他のすべての残りのエンドポイントは無視されるとします。私は次のコードを使用しています。私の質問は、antMatcher
は指定された要求を認証するだけですか?現在、すべての残りのエンドポイントの認証を有効にしています。選択された残りのエンドポイントのみを認証する:春の起動
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
// How does it work will it only authenticate employee &
// ignore any other request?? Its authenticating all the requests currently.
http
.authorizeRequests()
.antMatchers("/employee/*").authenticated()
.and()
.httpBasic()
.and()
.csrf()
.disable();
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth
.inMemoryAuthentication()
.withUser("admin").password("admin").roles("USER");
}
}
あなたの構成が私には罰金です。この設定が適用されていることを確認しますか?あなたはコンソール上のデフォルトの 'user'のためのランダムなパスワードを見ていますか?プロジェクトの構成を投稿してください。 –