Implement a functional logout for spring-boot-keycloak
This commit is contained in:
parent
53eedb7ad5
commit
37c6fe33d7
@ -8,6 +8,8 @@ import java.security.Principal;
|
|||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class WebController {
|
public class WebController {
|
||||||
|
|
||||||
@ -19,6 +21,12 @@ public class WebController {
|
|||||||
return "external";
|
return "external";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/logout")
|
||||||
|
public String logout(HttpServletRequest request) throws Exception {
|
||||||
|
request.logout();
|
||||||
|
return "redirect:/";
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping(path = "/customers")
|
@GetMapping(path = "/customers")
|
||||||
public String customers(Principal principal, Model model) {
|
public String customers(Principal principal, Model model) {
|
||||||
addCustomers();
|
addCustomers();
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
</table>
|
</table>
|
||||||
<div id="pagefoot" th:include="layout :: footerFragment">Footer
|
<div id="pagefoot" th:include="layout :: footerFragment">Footer
|
||||||
</div>
|
</div>
|
||||||
|
<a href="/logout">Logout</a>
|
||||||
</div>
|
</div>
|
||||||
<!-- container -->
|
<!-- container -->
|
||||||
</body>
|
</body>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user