mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 04:22:33 +08:00
feat: 禁止通过api访问ws接口
This commit is contained in:
@@ -49,6 +49,16 @@ func MustLogin(t *gotext.Locale, session *sessions.Manager, userToken biz.UserTo
|
||||
|
||||
userID := uint(0)
|
||||
if r.Header.Get("Authorization") != "" {
|
||||
// 禁止访问 ws 相关的接口
|
||||
if strings.HasPrefix(r.URL.Path, "/api/ws") {
|
||||
render := chix.NewRender(w)
|
||||
defer render.Release()
|
||||
render.Status(http.StatusForbidden)
|
||||
render.JSON(chix.M{
|
||||
"msg": t.Get("ws not allowed"),
|
||||
})
|
||||
return
|
||||
}
|
||||
// API 请求验证
|
||||
if userID, err = userToken.ValidateReq(r); err != nil {
|
||||
render := chix.NewRender(w)
|
||||
|
||||
Reference in New Issue
Block a user