我是靠谱客的博主 阳光石头,这篇文章主要介绍CAS单点登录 - 跳转至登录,现在分享给大家,希望可以做个参考。

复制代码
1
2
3
4
5
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency>
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<!DOCTYPE html> <html lang="en" xmlns:th="http://www.thymeleaf.org"> <head> <meta charset="UTF-8"> <title>SSO单点登录</title> </head> <body> <h1>欢迎访问单点登录系统</h1> <form action="doLogin" method="post"> <input type="text" name="username" placeholder="请输入用户名"/> <input type="password" name="password" placeholder="请输入密码"/> <input type="hidden" name="returnUrl" th:value="${returnUrl}"> <input type="submit" value="提交登录"/> </form> <span style="color:red" th:text="${errmsg}"></span> </body> </html>
复制代码
1
2
3
4
5
6
thymeleaf: mode: HTML encoding: UTF-8 prefix: classpath:/templates/ suffix: .html
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
@GetMapping("/login") public String login(String returnUrl, Model model, HttpServletRequest request, HttpServletResponse response) { model.addAttribute("returnUrl", returnUrl); // 1. 获取userTicket门票,如果cookie中能够获取到,证明用户登录过,此时签发一个一次性的临时票据并且回跳 String userTicket = getCookie(request, COOKIE_USER_TICKET); boolean isVerified = verifyUserTicket(userTicket); if (isVerified) { String tmpTicket = createTmpTicket(); return "redirect:" + returnUrl + "?tmpTicket=" + tmpTicket; } // 2. 用户从未登录过,第一次进入则跳转到CAS的统一登录页面 return "login"; }

 

最后

以上就是阳光石头最近收集整理的关于CAS单点登录 - 跳转至登录的全部内容,更多相关CAS单点登录内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(44)

评论列表共有 0 条评论

立即
投稿
返回
顶部