some changes ;]]]]]
This commit is contained in:
23
security/tokenMiddleware.go
Normal file
23
security/tokenMiddleware.go
Normal file
@ -0,0 +1,23 @@
|
||||
package security
|
||||
|
||||
import (
|
||||
"gitea-issue/proxy"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func BearerToken() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
token := c.GetHeader("Authorization")
|
||||
if (token == "") {
|
||||
c.AbortWithStatus(http.StatusBadRequest)
|
||||
}
|
||||
var tokenArr []string
|
||||
tokenArr = strings.Split(token, " ")
|
||||
if (tokenArr[1] != proxy.Bearer) {
|
||||
c.AbortWithStatus(http.StatusUnauthorized)
|
||||
}
|
||||
c.Next()
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user