|
|
|
@ -19,6 +19,7 @@ import (
|
|
|
|
|
"encoding/base64"
|
|
|
|
|
"encoding/json"
|
|
|
|
|
"fmt"
|
|
|
|
|
"github.com/RangelReale/osin"
|
|
|
|
|
"github.com/dchest/captcha"
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
|
"github.com/tidwall/gjson"
|
|
|
|
@ -54,6 +55,10 @@ func Routers(r *gin.RouterGroup) {
|
|
|
|
|
r.POST("/bindWxUser", bindWxUser)
|
|
|
|
|
//解除绑定
|
|
|
|
|
r.POST("/unBindWxUser", unBindWxUser)
|
|
|
|
|
//添加接入系统
|
|
|
|
|
r.GET("/AddClient", AddClient)
|
|
|
|
|
//删除接入系统
|
|
|
|
|
r.GET("/DelClient", DelClient)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -638,9 +643,9 @@ func checkOpenId(context *gin.Context) {
|
|
|
|
|
// @Tags 登录验证类
|
|
|
|
|
// @Accept application/x-www-form-urlencoded
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Param username formData string true "username"
|
|
|
|
|
// @Param password formData string true "password"
|
|
|
|
|
// @Param openId formData string true "openId"
|
|
|
|
|
// @Param username query string true "username"
|
|
|
|
|
// @Param password query string true "password"
|
|
|
|
|
// @Param openId query string true "openId"
|
|
|
|
|
// @Success 200 {string} string
|
|
|
|
|
// @Router /oauth2/bindWxUser [get]
|
|
|
|
|
func bindWxUser(context *gin.Context) {
|
|
|
|
@ -732,3 +737,67 @@ func unBindWxUser(context *gin.Context) {
|
|
|
|
|
Msg: "解除绑定成功!",
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @Summary 增加一个接入系统
|
|
|
|
|
// @Description 增加一个接入系统
|
|
|
|
|
// @Tags 统一认证管理
|
|
|
|
|
// @Accept application/x-www-form-urlencoded
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Param access_key query string true "access_key"
|
|
|
|
|
// @Param secret_key query string true "secret_key"
|
|
|
|
|
// @Param redirect_uri query string true "redirect_uri"
|
|
|
|
|
// @Success 200 {string} string
|
|
|
|
|
// @Router /oauth2/AddClient [get]
|
|
|
|
|
func AddClient(context *gin.Context) {
|
|
|
|
|
ip := context.ClientIP()
|
|
|
|
|
if ip != "127.0.0.1" {
|
|
|
|
|
context.JSON(http.StatusOK, Model.Res{
|
|
|
|
|
Code: http.StatusNotImplemented,
|
|
|
|
|
Msg: "内部接口,只限本机进行调用!",
|
|
|
|
|
})
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
accessKey := context.Query("access_key")
|
|
|
|
|
secretKey := context.Query("secret_key")
|
|
|
|
|
redirectUri := context.Query("redirect_uri")
|
|
|
|
|
RedisStorage.OAuth2RedisStorage.CreateClient(
|
|
|
|
|
&osin.DefaultClient{
|
|
|
|
|
Id: accessKey,
|
|
|
|
|
Secret: secretKey,
|
|
|
|
|
RedirectUri: redirectUri,
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
context.JSON(http.StatusOK, Model.Res{
|
|
|
|
|
Code: http.StatusOK,
|
|
|
|
|
Msg: "增加成功!",
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @Summary 删除一个接入系统
|
|
|
|
|
// @Description 删除一个接入系统
|
|
|
|
|
// @Tags 统一认证管理
|
|
|
|
|
// @Accept application/x-www-form-urlencoded
|
|
|
|
|
// @Produce json
|
|
|
|
|
// @Param access_key query string true "access_key"
|
|
|
|
|
// @Success 200 {string} string
|
|
|
|
|
// @Router /oauth2/DelClient [get]
|
|
|
|
|
func DelClient(context *gin.Context) {
|
|
|
|
|
ip := context.ClientIP()
|
|
|
|
|
if ip != "127.0.0.1" {
|
|
|
|
|
context.JSON(http.StatusOK, Model.Res{
|
|
|
|
|
Code: http.StatusNotImplemented,
|
|
|
|
|
Msg: "内部接口,只限本机进行调用!",
|
|
|
|
|
})
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
accessKey := context.Query("access_key")
|
|
|
|
|
RedisStorage.OAuth2RedisStorage.DeleteClient(
|
|
|
|
|
&osin.DefaultClient{
|
|
|
|
|
Id: accessKey,
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
context.JSON(http.StatusOK, Model.Res{
|
|
|
|
|
Code: http.StatusOK,
|
|
|
|
|
Msg: "删除成功!",
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|