2016-12-05 6 views
0

ユーザーが登録しているときに、同じ手順でも認証しようとしています。私はオンラインの周りを見回しましたが、これはそうする方法のようだ:JSESSIONID Cookieを設定していないSpringセキュリティ

UserDetails userDetails userDetailsService.loadUserByUsername(username); 
// Set authenticated 
Authentication auth = new UsernamePasswordAuthenticationToken(userDetails, password, userDetails.getAuthorities()); 
authenticationManager.authenticate(auth); 
if (auth.isAuthenticated()){ 
    // This is hit every time, seemingly signaling 
    // that authentication is happening 
    SecurityContextHolder.getContext().setAuthentication(auth); 
} 

はしかし、これはユーザーが保護されたリソースにアクセスしようとする最初の時間をJSESSIONIDクッキーを設定し、それゆえされていない、彼らは再度ログインする必要があります。どのようにこれを修正するための任意の考え?私はSpring Securityの4.0.1.RELEASEバージョンを使用しています。

私も自分の設定で次のように設定していますが、私はそれが関係している可能性があるかどうかわからないです:

http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.IF_REQUIRED); 
http.sessionManagement().maximumSessions(1); 
http.sessionManagement().sessionFixation().migrateSession(); 

答えて

0

私のサーバーが何らかの形で破損していたが判明しました。また、ランダムにapiコールを拒否していたので、私はサーバーを新しくインストールしましたが、今はすべて動作します。

関連する問題