Advertisement
SimpleCookie

Untitled

Feb 12th, 2024
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.86 KB | None | 0 0
  1. import org.springframework.security.core.context.SecurityContextHolder
  2. import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler
  3. import org.springframework.stereotype.Controller
  4. import org.springframework.web.bind.annotation.GetMapping
  5. import javax.servlet.http.HttpServletRequest
  6. import javax.servlet.http.HttpServletResponse
  7.  
  8. @Controller
  9. class LogoutController {
  10.  
  11.     @GetMapping("/logout")
  12.     fun logout(request: HttpServletRequest, response: HttpServletResponse): String {
  13.         val auth = SecurityContextHolder.getContext().authentication
  14.         if (auth != null) {
  15.             SecurityContextLogoutHandler().logout(request, response, auth)
  16.         }
  17.         return "redirect:${oauthProviderLogoutUrl}"
  18.     }
  19.  
  20.     companion object {
  21.         const val oauthProviderLogoutUrl = "https://oauth-provider.com/logout"
  22.     }
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement