feat(wasm-plugin): add tests and docs for hmac-auth-apisix (#2842)

This commit is contained in:
韩贤涛
2025-09-01 14:07:57 +08:00
committed by GitHub
parent fff5903007
commit 7e74eeb333
9 changed files with 1769 additions and 46 deletions

View File

@@ -18,12 +18,12 @@ func main() {}
func init() {
wrapper.SetCtx(
"replay-protection",
wrapper.ParseConfigBy(config.ParseConfig),
wrapper.ProcessRequestHeadersBy(onHttpRequestHeaders),
wrapper.ParseConfig(config.ParseConfig),
wrapper.ProcessRequestHeaders(onHttpRequestHeaders),
)
}
func onHttpRequestHeaders(ctx wrapper.HttpContext, cfg config.ReplayProtectionConfig, log log.Log) types.Action {
func onHttpRequestHeaders(ctx wrapper.HttpContext, cfg config.ReplayProtectionConfig) types.Action {
nonce, _ := proxywasm.GetHttpRequestHeader(cfg.NonceHeader)
if cfg.ForceNonce && nonce == "" {
// In force mode, reject the request if a required header is missing.