* BAEL-509: Initial Commit - working but needs a few fixes to REST API, etc. * Fixed Authentication Failure - added subscription handlers - sufficient for Websocket Authentication/Authorization - still some issues to resolve with subscriptions and REST API * Final version * CSRF token controller - cleanup of chat wrapper
25 lines
1.0 KiB
Java
25 lines
1.0 KiB
Java
package com.baeldung.springsecuredsockets.security;
|
|
|
|
import com.baeldung.springsecuredsockets.domain.User;
|
|
import com.baeldung.springsecuredsockets.repositories.UserRepository;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.security.core.Authentication;
|
|
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import java.io.IOException;
|
|
|
|
public class CustomLoginSuccessHandler implements AuthenticationSuccessHandler {
|
|
|
|
@Autowired
|
|
UserRepository userRepository;
|
|
|
|
@Override
|
|
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException {
|
|
User user = userRepository.findByUsername(authentication.getName());
|
|
response.setStatus(HttpStatus.OK.value());
|
|
response.sendRedirect(request.getContextPath() + "/secured/success");
|
|
}
|
|
} |