From fbda5d558eba3d11fd41ad6e8374752e636b88e8 Mon Sep 17 00:00:00 2001 From: thinkgem Date: Tue, 30 Aug 2022 21:43:49 +0800 Subject: [PATCH] add sso demo --- .../modules/sys/web/SsoController.java | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/modules/core/src/main/java/com/jeesite/modules/sys/web/SsoController.java b/modules/core/src/main/java/com/jeesite/modules/sys/web/SsoController.java index cf79cdcb..9fccbfd9 100644 --- a/modules/core/src/main/java/com/jeesite/modules/sys/web/SsoController.java +++ b/modules/core/src/main/java/com/jeesite/modules/sys/web/SsoController.java @@ -4,19 +4,6 @@ */ package com.jeesite.modules.sys.web; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import io.swagger.annotations.Api; -import org.apache.commons.lang3.StringUtils; -import org.apache.shiro.authc.AuthenticationException; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; - import com.jeesite.common.codec.EncodeUtils; import com.jeesite.common.config.Global; import com.jeesite.common.lang.ObjectUtils; @@ -26,6 +13,18 @@ import com.jeesite.common.web.BaseController; import com.jeesite.common.web.http.ServletUtils; import com.jeesite.modules.sys.entity.User; import com.jeesite.modules.sys.utils.UserUtils; +import io.swagger.annotations.Api; +import org.apache.commons.lang3.StringUtils; +import org.apache.shiro.authc.AuthenticationException; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; /** * 单点登录Controller @@ -36,7 +35,14 @@ import com.jeesite.modules.sys.utils.UserUtils; @Api(tags = "SSO - 单点登录") @ConditionalOnProperty(name={"user.enabled","web.core.enabled"}, havingValue="true", matchIfMissing=true) public class SsoController extends BaseController{ - + +// public static void main(String[] args) { +// String username = "system"; +// String secretKey = Global.getConfig("shiro.sso.secretKey"); +// String token = Md5Utils.md5(secretKey + username + DateUtils.getDate("yyyyMMdd")); +// System.out.println("http://127.0.0.1:3100/js/sso/" + username + "/" + token + "?url=../sys/office/index"); +// } + /** * 单点登录(如已经登录,则直接跳转) * @param username 登录用户名(loginCode) @@ -81,8 +87,4 @@ public class SsoController extends BaseController{ return "error/403"; } -// public static void main(String[] args) { -// System.out.println(UserUtils.getSsoToken("system")); -// } - }