私はこのコードを持っています
UserDetails userDetails = userDetailsServiceImpl.loadUserByUsername(email);
Authentication authentication = new UsernamePasswordAuthenticationToken(userDetails, userDetails.getPassword(), userDetails.getAuthorities());
SecurityContext securityContext = SecurityContextHolder.getContext();
securityContext.setAuthentication(authentication);
HttpSession session = request.getSession(true);
session.setAttribute("SPRING_SECURITY_CONTEXT", securityContext);
これは、春のセキュリティでユーザーを手動で認証することです。私の質問は、このコードをどこに配置すればよいですか? これをサービスレイヤーに配置すると、HttpSessionオブジェクトをサービスレイヤーに持ち込む必要がありますが、これはAFAIKが悪いです。認証ロジックをプレゼンテーション層に配置することがどれほど良いかについてもわかりません。洞察力のある人はいますか??
前もって感謝します。