upgrade 2.4.1: bugfix: default token

This commit is contained in:
UlricQin 2020-05-29 16:02:00 +08:00
parent 834669bf36
commit a366f14434
2 changed files with 4 additions and 2 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash
# release version
version=2.4.0
version=2.4.1
CWD=$(cd $(dirname $0)/; pwd)
cd $CWD

View File

@ -70,11 +70,13 @@ func headerUser(c *gin.Context) string {
return pair[0]
}
const internalToken = "monapi-builtin-token"
// CheckHeaderToken check thirdparty x-srv-token
func CheckHeaderToken() gin.HandlerFunc {
return func(c *gin.Context) {
token := c.GetHeader("x-srv-token")
if !slice.ContainsString(config.Get().Tokens, token) {
if token != internalToken && !slice.ContainsString(config.Get().Tokens, token) {
errors.Bomb("token[%s] invalid", token)
}
c.Next()