master
huanghai 5 years ago
parent 84c635df59
commit 8235540e6e

@ -41,15 +41,6 @@ func init() {
func SsoHandler() gin.HandlerFunc {
return func(c *gin.Context) {
//植入一个写入未登录用户访问时记录浏览器ID或者机器ID的方法
_, err := c.Request.Cookie("browser_id")
if err == nil {
//读取到
} else {
//没有设置过
c.SetCookie("browser_id", CommonUtil.GetUUID(), -1, "/", "", false, true)
}
//获取访问的完整地址(包括参数)
requestUri := c.Request.RequestURI
host := c.Request.Host
@ -109,6 +100,15 @@ func SsoHandler() gin.HandlerFunc {
//needLoginFlag为true说明需要跳转到统一认证否则通过
if needLoginFlag {
c.Abort()
//植入一个写入未登录用户访问时记录浏览器ID或者机器ID的方法
_, err := c.Request.Cookie("browser_id")
if err == nil {
} else {
//没有设置过
c.SetCookie("browser_id", CommonUtil.GetUUID(), -1, "/", "", false, true)
}
//将访问的全整路径进行base64加码
oauthCallback := base64.StdEncoding.EncodeToString([]byte("http://" + host + requestUri))
loginUrl := ssoServer + authCodeURI + "?client_id=" + clientId + "&redirect_uri=" + redirectURI + "&response_type=" + responseType + "&oauth_callback=" + oauthCallback + "&device_id=1"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -31,7 +31,7 @@ import (
// @contact.email support@swagger.io
// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
// @host 10.10.14.187:8002
// @host 127.0.0.1:8002
func main() {
// 发布模式
//gin.SetMode(gin.ReleaseMode)

Loading…
Cancel
Save