master
huanghai 5 years ago
parent 95d375919e
commit 82aa654c1a

@ -0,0 +1,4 @@
package Const
//整数最大值
const Int32Max = 2147483647

@ -1,9 +1,11 @@
package ControllerOauth2
import (
"dsSso/Const"
"dsSso/Const/DefaultConst"
"dsSso/Controller/ControllerRecaptcha"
"dsSso/Model"
"dsSso/Service/ServiceJoinApp"
"dsSso/Service/ServiceLoginPerson"
"dsSso/Utils/AesUtil"
"dsSso/Utils/CommonUtil"
@ -15,8 +17,10 @@ import (
"dsSso/Utils/SsoUtil"
"encoding/base64"
"encoding/json"
"fmt"
"github.com/dchest/captcha"
"github.com/gin-gonic/gin"
"io/ioutil"
"net/http"
"strconv"
"strings"
@ -404,6 +408,29 @@ func authorizeGet(context *gin.Context) {
// @Success 200 {string} string
// @Router /oauth2/logout [get]
func logout(context *gin.Context) {
//取出现在的cookie中的accessToken
accessToken := SsoUtil.ReadSsoCookie(context)
//获取所有接入系统的
list, _ := ServiceJoinApp.GetJoinAppList(1, Const.Int32Max, "")
for i := range list {
//每个系统的退出地址
logoutUri := list[i]["logout_uri"].(string)
//如果注册了退出地址的话
if len(logoutUri) > 0 {
//开启协程进行调用
go func() {
resp, err := http.Get(logoutUri + "?access_token=" + accessToken)
if err != nil {
fmt.Println(err)
return
}
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
}()
}
}
//清除cookie
SsoUtil.DeleteSsoCookie(context)
msg := "统一认证退出成功!"
context.JSON(http.StatusOK, map[string]interface{}{"success": false, "msg": msg})

@ -260,6 +260,29 @@ var doc = `{
]
}
},
"/oauth2/logout": {
"get": {
"description": "退出统一认证",
"consumes": [
"application/x-www-form-urlencoded"
],
"produces": [
"application/json"
],
"tags": [
"登录验证类"
],
"summary": "退出统一认证",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "string"
}
}
}
}
},
"/sso/addJoinApp": {
"post": {
"description": "增加一条接入系统的记录",

@ -244,6 +244,29 @@
]
}
},
"/oauth2/logout": {
"get": {
"description": "退出统一认证",
"consumes": [
"application/x-www-form-urlencoded"
],
"produces": [
"application/json"
],
"tags": [
"登录验证类"
],
"summary": "退出统一认证",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "string"
}
}
}
}
},
"/sso/addJoinApp": {
"post": {
"description": "增加一条接入系统的记录",

@ -198,6 +198,21 @@ paths:
- 登录验证类
x-lengthlimit:
- captchaId: 20,20
/oauth2/logout:
get:
consumes:
- application/x-www-form-urlencoded
description: 退出统一认证
produces:
- application/json
responses:
"200":
description: OK
schema:
type: string
summary: 退出统一认证
tags:
- 登录验证类
/sso/addJoinApp:
post:
consumes:

Loading…
Cancel
Save