|
|
|
@ -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})
|
|
|
|
|