Search in sources :

Example 1 with CookieClearingLogoutHandler

use of org.springframework.security.web.authentication.logout.CookieClearingLogoutHandler in project pigatron-web by pigatron-industries.

the class AdminSecurityController method logout.

// @RequestMapping(value = "/${url.admin}/login", method = RequestMethod.GET)
// public String adminLogin() {
// if(userRepository.count() == 0) {
// return VIEW_CONFIGURE;
// } else {
// return VIEW_ADMINLOGIN;
// }
// }
// @RequestMapping(value = "/${url.setup}", method = RequestMethod.POST)
// public String setup(@ModelAttribute CreateUserForm configurationForm) {
// if(userRepository.count() == 0) {
// secUserDetailsService.createAdminUser(configurationForm.getAdminUsername(), configurationForm.getAdminPassword());
// return "redirect:/" + adminUrl;
// } else {
// throw new ResourceNotFoundException();
// }
// }
@RequestMapping(value = "/logout", method = RequestMethod.POST)
@ResponseBody
public void logout(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    CookieClearingLogoutHandler cookieClearingLogoutHandler = new CookieClearingLogoutHandler(AbstractRememberMeServices.SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY);
    SecurityContextLogoutHandler securityContextLogoutHandler = new SecurityContextLogoutHandler();
    cookieClearingLogoutHandler.logout(request, response, null);
    securityContextLogoutHandler.logout(request, response, null);
}
Also used : SecurityContextLogoutHandler(org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler) CookieClearingLogoutHandler(org.springframework.security.web.authentication.logout.CookieClearingLogoutHandler) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with CookieClearingLogoutHandler

use of org.springframework.security.web.authentication.logout.CookieClearingLogoutHandler in project steve by RWTH-i5-IDSG.

the class SignOutController method signOut.

@RequestMapping(value = "/signout", method = RequestMethod.GET)
public String signOut(HttpServletRequest request, HttpServletResponse response) {
    new SecurityContextLogoutHandler().logout(request, response, null);
    new CookieClearingLogoutHandler(AbstractRememberMeServices.SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY).logout(request, response, null);
    return "redirect:/manager/signin";
}
Also used : SecurityContextLogoutHandler(org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler) CookieClearingLogoutHandler(org.springframework.security.web.authentication.logout.CookieClearingLogoutHandler) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with CookieClearingLogoutHandler

use of org.springframework.security.web.authentication.logout.CookieClearingLogoutHandler in project tutorials by eugenp.

the class AuthController method logout.

@GetMapping("/logout")
public String logout(HttpServletRequest request, HttpServletResponse response, SecurityContextLogoutHandler logoutHandler) {
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    logoutHandler.logout(request, response, auth);
    new CookieClearingLogoutHandler(AbstractRememberMeServices.SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY).logout(request, response, auth);
    return "auth/logout";
}
Also used : Authentication(org.springframework.security.core.Authentication) CookieClearingLogoutHandler(org.springframework.security.web.authentication.logout.CookieClearingLogoutHandler) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 4 with CookieClearingLogoutHandler

use of org.springframework.security.web.authentication.logout.CookieClearingLogoutHandler in project esup-papercut by EsupPortail.

the class AuthController method logout.

@GetMapping("/logout")
public String logout(HttpServletRequest request, HttpServletResponse response, SecurityContextLogoutHandler logoutHandler) {
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    logoutHandler.logout(request, response, auth);
    new CookieClearingLogoutHandler(AbstractRememberMeServices.SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY).logout(request, response, auth);
    return "auth/logout";
}
Also used : Authentication(org.springframework.security.core.Authentication) CookieClearingLogoutHandler(org.springframework.security.web.authentication.logout.CookieClearingLogoutHandler) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

CookieClearingLogoutHandler (org.springframework.security.web.authentication.logout.CookieClearingLogoutHandler)4 Authentication (org.springframework.security.core.Authentication)2 SecurityContextLogoutHandler (org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler)2 GetMapping (org.springframework.web.bind.annotation.GetMapping)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1