diff --git a/dsSso/Controller/ControllerOauth2/ControllerOauth2.go b/dsSso/Controller/ControllerOauth2/ControllerOauth2.go index 073a9fbb..756e55a0 100644 --- a/dsSso/Controller/ControllerOauth2/ControllerOauth2.go +++ b/dsSso/Controller/ControllerOauth2/ControllerOauth2.go @@ -36,6 +36,9 @@ func Routers(r *gin.RouterGroup) { r.GET("/getCaptcha", getCaptcha) //获取验证码图片 r.GET("/getCaptchaPng", getCaptchaPng) + //退出接口 + r.GET("/logout", logout) + r.POST("/logout", logout) return } @@ -392,3 +395,16 @@ func authorizeGet(context *gin.Context) { url := "/sso/static/index.html?redirect_uri=" + redirectUri + "&response_type=code&client_id=" + paraClientId + "&oauth_callback=" + oauthCallback context.Redirect(302, url) } + +// @Summary 退出统一认证 +// @Description 退出统一认证 +// @Tags 登录验证类 +// @Accept application/x-www-form-urlencoded +// @Produce json +// @Success 200 {string} string +// @Router /oauth2/logout [get] +func logout(context *gin.Context) { + SsoUtil.DeleteSsoCookie(context) + msg := "统一认证退出成功!" + context.JSON(http.StatusOK, map[string]interface{}{"success": false, "msg": msg}) +} diff --git a/dsSso/Utils/SsoUtil/SsoUtil.go b/dsSso/Utils/SsoUtil/SsoUtil.go index f8baea1e..4ee68e93 100644 --- a/dsSso/Utils/SsoUtil/SsoUtil.go +++ b/dsSso/Utils/SsoUtil/SsoUtil.go @@ -61,6 +61,6 @@ func ReadSsoCookie(c *gin.Context) string { 作者:黄海 时间:2020-02-22 */ -func deleteSsoCookie(c *gin.Context) { +func DeleteSsoCookie(c *gin.Context) { c.SetCookie(ConfigUtil.AccessToken, "", -1, "/", "", false, true) }