mirror of
https://github.com/alibaba/higress.git
synced 2026-06-09 20:57:32 +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)
|
valid := ParseTokenValid(token, config.TokenSecretKey)
|
||||||
if valid {
|
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
|
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 {
|
func ParseTokenValid(tokenString, TokenSecretKey string) bool {
|
||||||
|
|||||||
Reference in New Issue
Block a user