mirror of
https://github.com/Li4n0/revsuit.git
synced 2026-09-27 00:51:55 +08:00
fix(server): fix auth failure when complex characters in token (#42)
Co-authored-by: E99p1ant <[email protected]> Co-authored-by: Li4n0 <[email protected]>
This commit is contained in:
@@ -31,8 +31,11 @@ func (revsuit *Revsuit) registerPlatformRouter() {
|
|||||||
// /api need Authorization
|
// /api need Authorization
|
||||||
api := revsuit.http.Router.Group(revsuit.config.AdminPathPrefix + "/api")
|
api := revsuit.http.Router.Group(revsuit.config.AdminPathPrefix + "/api")
|
||||||
api.Use(func(c *gin.Context) {
|
api.Use(func(c *gin.Context) {
|
||||||
cookieToken, err := c.Request.Cookie("token")
|
token, err := c.Cookie("token")
|
||||||
if !(c.Request.Header.Get("Token") == revsuit.http.Token || err == nil && cookieToken.Value == revsuit.http.Token) {
|
if err == http.ErrNoCookie {
|
||||||
|
token = c.Request.Header.Get("Token")
|
||||||
|
}
|
||||||
|
if token != revsuit.http.Token {
|
||||||
c.Abort()
|
c.Abort()
|
||||||
c.Status(403)
|
c.Status(403)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user