mirror of
https://github.com/alibaba/higress.git
synced 2026-04-21 20:17:29 +08:00
feat: Add statusCodeDetails info when returning response in Wasm plugins directly (#1116)
This commit is contained in:
@@ -276,7 +276,7 @@ func onHttpRequestHeaders(ctx wrapper.HttpContext, config KeyAuthConfig, log wra
|
||||
|
||||
// header/query
|
||||
if len(tokens) > 1 {
|
||||
return deniedMutiKeyAuthData()
|
||||
return deniedMultiKeyAuthData()
|
||||
} else if len(tokens) <= 0 {
|
||||
return deniedNoKeyAuthData()
|
||||
}
|
||||
@@ -321,20 +321,20 @@ func onHttpRequestHeaders(ctx wrapper.HttpContext, config KeyAuthConfig, log wra
|
||||
return types.ActionContinue
|
||||
}
|
||||
|
||||
func deniedMutiKeyAuthData() types.Action {
|
||||
_ = proxywasm.SendHttpResponse(http.StatusUnauthorized, WWWAuthenticateHeader(protectionSpace),
|
||||
[]byte("Request denied by Key Auth check. Muti Key Authentication information found."), -1)
|
||||
func deniedMultiKeyAuthData() types.Action {
|
||||
_ = proxywasm.SendHttpResponseWithDetail(http.StatusUnauthorized, "key-auth.multi_key", WWWAuthenticateHeader(protectionSpace),
|
||||
[]byte("Request denied by Key Auth check. Multi Key Authentication information found."), -1)
|
||||
return types.ActionContinue
|
||||
}
|
||||
|
||||
func deniedNoKeyAuthData() types.Action {
|
||||
_ = proxywasm.SendHttpResponse(http.StatusUnauthorized, WWWAuthenticateHeader(protectionSpace),
|
||||
_ = proxywasm.SendHttpResponseWithDetail(http.StatusUnauthorized, "key-auth.no_key", WWWAuthenticateHeader(protectionSpace),
|
||||
[]byte("Request denied by Key Auth check. No Key Authentication information found."), -1)
|
||||
return types.ActionContinue
|
||||
}
|
||||
|
||||
func deniedUnauthorizedConsumer() types.Action {
|
||||
_ = proxywasm.SendHttpResponse(http.StatusForbidden, WWWAuthenticateHeader(protectionSpace),
|
||||
_ = proxywasm.SendHttpResponseWithDetail(http.StatusForbidden, "key-auth.unauthorized", WWWAuthenticateHeader(protectionSpace),
|
||||
[]byte("Request denied by Key Auth check. Unauthorized consumer."), -1)
|
||||
return types.ActionContinue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user