Skip to content
Snippets Groups Projects
Commit 9c0f7753 authored by Paul-Christian Volkmer's avatar Paul-Christian Volkmer
Browse files

Store spring authentication in security context

If user is successfully logged in, store authentication in security context
else redirect to login page.
parent c67e4512
No related merge requests found
......@@ -176,13 +176,18 @@ public class LoginController extends AbstractController {
Authentication token = new UsernamePasswordAuthenticationToken(user, password, getAuthorities());
try {
Authentication auth = ldapAuthenticationProvider.authenticate(token);
if (auth.isAuthenticated()) {
SecurityContextHolder.getContext().setAuthentication(token);
request.getSession(true).setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY,
SecurityContextHolder.getContext());
return new RedirectView("/#auth/checkLogin");
}
LOGGER.info("LDAPLOGIN: {}", auth.isAuthenticated());
return new RedirectView(referer + "#auth/checkLogin");
}
catch (AuthenticationException e) {
LOGGER.info("No LDAP login: {}", e);
return new RedirectView("/login.html");
}
return new RedirectView("/login.html");
}
return null;
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment