mirror of
https://github.com/alibaba/higress.git
synced 2026-04-20 11:37:27 +08:00
Update main.go
This commit is contained in:
@@ -58,15 +58,13 @@ func onHttpRequestHeaders(ctx wrapper.HttpContext, config Config, log wrapper.Lo
|
||||
}
|
||||
valid := ParseTokenValid(token, config.TokenSecretKey)
|
||||
if valid {
|
||||
_ = proxywasm.ResumeHttpRequest()
|
||||
return types.ActionPause
|
||||
} else {
|
||||
res.Code = http.StatusUnauthorized
|
||||
res.Msg = "认证失败"
|
||||
data, _ := json.Marshal(res)
|
||||
_ = proxywasm.SendHttpResponse(http.StatusUnauthorized, nil, data, -1)
|
||||
return types.ActionContinue
|
||||
}
|
||||
res.Code = http.StatusUnauthorized
|
||||
res.Msg = "认证失败"
|
||||
data, _ := json.Marshal(res)
|
||||
_ = proxywasm.SendHttpResponse(http.StatusUnauthorized, nil, data, -1)
|
||||
return types.ActionContinue
|
||||
}
|
||||
|
||||
func ParseTokenValid(tokenString, TokenSecretKey string) bool {
|
||||
|
||||
Reference in New Issue
Block a user