some changes ;]]]]]

This commit is contained in:
2020-01-15 20:40:53 +01:00
parent f24c030d8f
commit ab802985e9
12 changed files with 449 additions and 204 deletions

View 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()
}
}