更新sso路径

This commit is contained in:
shuzheng 2017-02-06 12:31:35 +08:00
parent 6361a1f746
commit ba0f40a474
3 changed files with 13 additions and 10 deletions

View File

@ -71,7 +71,7 @@ public class SSOFilter implements Filter {
else {
// 认证中心地址
StringBuffer sso_server_url = new StringBuffer(filterConfig.getInitParameter(SSO_SERVER_URL));
sso_server_url.append("/sso");
sso_server_url.append("/sso/index");
// 判断是否有认证中心token
String token = request.getParameter("token");
// 已拿到token

View File

@ -41,7 +41,7 @@ public class SSOController {
private final static Logger _log = LoggerFactory.getLogger(SSOController.class);
private final static int TIMEOUT = 2 * 60 * 60;
private final static String ZHENG_UPMS_SSO_SERVER_SESSION_ID = "zheng-upms-sso-server-session-id";
private final static String ZHENG_UPMS_SERVER_SESSION_ID = "zheng-upms-server-session-id";
@Autowired
UpmsSystemService upmsSystemService;
@ -55,7 +55,7 @@ public class SSOController {
* @return
* @throws Exception
*/
@RequestMapping(value = "", method = RequestMethod.GET)
@RequestMapping(value = "/index", method = RequestMethod.GET)
public String index(HttpServletRequest request, HttpServletResponse response) throws Exception {
String system_name = request.getParameter("system_name");
String backurl = request.getParameter("backurl");
@ -70,10 +70,10 @@ public class SSOController {
return "/404";
}
// 分配单点登录sessionId不使用session获取会话id改为cookie防止session丢失
String sessionId = CookieUtil.getCookie(request, ZHENG_UPMS_SSO_SERVER_SESSION_ID);
String sessionId = CookieUtil.getCookie(request, ZHENG_UPMS_SERVER_SESSION_ID);
if (StringUtils.isEmpty(sessionId)) {
sessionId = request.getSession().getId();
CookieUtil.setCookie(response, ZHENG_UPMS_SSO_SERVER_SESSION_ID, sessionId);
CookieUtil.setCookie(response, ZHENG_UPMS_SERVER_SESSION_ID, sessionId);
}
// 判断是否存在全局会话
// 未登录
@ -98,7 +98,7 @@ public class SSOController {
*/
@RequestMapping(value = "/login", method = RequestMethod.GET)
public String login(HttpServletRequest request) {
String sessionId = CookieUtil.getCookie(request, ZHENG_UPMS_SSO_SERVER_SESSION_ID);
String sessionId = CookieUtil.getCookie(request, ZHENG_UPMS_SERVER_SESSION_ID);
_log.info("认证中心sessionId={}", sessionId);
String backurl = request.getParameter("backurl");
if (!StringUtils.isEmpty(sessionId) && !StringUtils.isEmpty(backurl)) {
@ -163,10 +163,10 @@ public class SSOController {
return result;
}
// 分配单点登录sessionId不使用session获取会话id改为cookie防止session丢失
String sessionId = CookieUtil.getCookie(request, ZHENG_UPMS_SSO_SERVER_SESSION_ID);
String sessionId = CookieUtil.getCookie(request, ZHENG_UPMS_SERVER_SESSION_ID);
if (StringUtils.isEmpty(sessionId)) {
sessionId = request.getSession().getId();
CookieUtil.setCookie(response, ZHENG_UPMS_SSO_SERVER_SESSION_ID, sessionId);
CookieUtil.setCookie(response, ZHENG_UPMS_SERVER_SESSION_ID, sessionId);
}
// 默认验证帐号密码正确创建token
String token = UUID.randomUUID().toString();
@ -215,8 +215,10 @@ public class SSOController {
*/
@RequestMapping(value = "/logout", method = RequestMethod.GET)
public String logout(HttpServletRequest request) {
String sessionId = CookieUtil.getCookie(request, ZHENG_UPMS_SSO_SERVER_SESSION_ID);
// shiro退出登录
SecurityUtils.getSubject().logout();
String sessionId = CookieUtil.getCookie(request, ZHENG_UPMS_SERVER_SESSION_ID);
// 当前全局会话sessionId
String token = RedisUtil.get(sessionId + "_token");
// 清除全局会话

View File

@ -24,7 +24,8 @@
/swagger-ui.html = anon
/webjars/** = anon
/resources/** = anon
/sso/login = anon
/sso/** = anon
/403 = anon
/druid/**=authc
/manage/**=authc
</value>