私は、認証にスプリングセキュリティを使用する既存のWebアプリケーションを持っています。また、XSS攻撃を防止するためにセッション管理を使用して、ユーザーが事前定義された時間、XSRFトークンにログインできるようにします。パスによるSpringセキュリティセッション/ xsrf設定
@Override
protected void configure(HttpSecurity http) throws Exception {
// @formatter:off
http
.exceptionHandling()
.authenticationEntryPoint(restEntryPoint())
.and()
.headers().addHeaderWriter(new StaticHeadersWriter("Server",""))
.and()
.httpBasic()
.authenticationEntryPoint(restEntryPoint())
.and()
.logout().addLogoutHandler(myLogoutHandler())
.logoutSuccessHandler(logoutSuccessHandler())
.and()
.authorizeRequests()
.antMatchers("/index.html", "/login", "/").permitAll()
.antMatchers(HttpMethod.OPTIONS).denyAll()
.antMatchers(HttpMethod.HEAD).denyAll()
.anyRequest().authenticated()
.and()
.authenticationProvider(myAuthenticationProvider)
.csrf()
.csrfTokenRepository(csrfTokenRepository())
.and()
.addFilterAfter(csrfHeaderFilter(), SessionManagementFilter.class);
// @formatter:on
}
これは、Webアプリケーションに最適です。しかし、今や、サードパーティのクライアントアプリケーションが純粋なREST呼び出しを介して私のサービスを呼び出せるような設定を追加するように要求されました。つまり、完全にステートレスで、http基本認証を使用する必要があります。セッションを作成せずにxsrfを無効にする必要があります思う...)。
これらのクライアントAPI呼び出しの共有URLパスを定義できます。しかし、既存のセキュリティ構成とサーバーを両方の要件をサポートするためにどのように活用できますか?自分の質問に答える