Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.springframework.security.core.context.SecurityContextHolder
- import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler
- import org.springframework.stereotype.Controller
- import org.springframework.web.bind.annotation.GetMapping
- import javax.servlet.http.HttpServletRequest
- import javax.servlet.http.HttpServletResponse
- @Controller
- class LogoutController {
- @GetMapping("/logout")
- fun logout(request: HttpServletRequest, response: HttpServletResponse): String {
- val auth = SecurityContextHolder.getContext().authentication
- if (auth != null) {
- SecurityContextLogoutHandler().logout(request, response, auth)
- }
- return "redirect:${oauthProviderLogoutUrl}"
- }
- companion object {
- const val oauthProviderLogoutUrl = "https://oauth-provider.com/logout"
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement