[fix] Neo api guard
This commit is contained in:
parent
1d102f110b
commit
5fbf84bf8e
2 changed files with 3 additions and 15 deletions
|
|
@ -382,7 +382,7 @@ func (neo *DSL) setGuard(router *gin.Engine) error {
|
|||
|
||||
if neo.Guard == "" {
|
||||
router.Use(func(c *gin.Context) {
|
||||
token := c.Query("token")
|
||||
token := strings.TrimSpace(strings.TrimPrefix(c.Query("token"), "Bearer "))
|
||||
if token == "" {
|
||||
c.JSON(403, gin.H{"message": "token is required", "code": 403})
|
||||
c.Abort()
|
||||
|
|
|
|||
|
|
@ -65,20 +65,8 @@ func hdAuth(c *gin.Context) {
|
|||
tokenString := c.Request.Header.Get("Authorization")
|
||||
|
||||
// Get token from query
|
||||
if tokenString == "" {
|
||||
|
||||
// Temporary solution (will be removed in the future)
|
||||
tokenString = strings.TrimSpace(strings.TrimPrefix(c.Query("token"), "Bearer "))
|
||||
if tokenString == "" {
|
||||
c.JSON(403, gin.H{"code": 403, "message": "No permission"})
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
claims := helper.JwtValidate(tokenString, []byte(config.Conf.JWTSecret))
|
||||
c.Set("__sid", claims.SID)
|
||||
c.Next()
|
||||
return
|
||||
if c.Query("studio") != "" {
|
||||
tokenString = c.Query("studio")
|
||||
}
|
||||
|
||||
if strings.HasPrefix(tokenString, "Bearer") {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue