sha1 比對的腳本如下 (需要把程式放在 vcl_error 類別底下):
其中 base64_decode 裡面放的是自己的加密 key 包成 base64 的字串。
declare local var.test STRING; declare local var.bs STRING; declare local var.test_my STRING; declare local var.test_real STRING; set var.test = regsub(digest.hmac_sha1(digest.base64_decode("VE9EQVlJU01ZSEFQUFlEQVkmXnNzJCEhQCNz"), req.url.path req.http.X-Exp), "^0x", ""); set var.test_my = regsub(digest.hmac_sha1(digest.base64_decode("VE9EQVlJU01ZSEFQUFlEQVkmXnNzJCEhQCNz"), req.url.path req.http.X-Exp),"",""); set var.test_real = digest.hmac_sha1(digest.base64_decode("VE9EQVlJU01ZSEFQUFlEQVkmXnNzJCEhQCNz"), req.url.path req.http.X-Exp); set var.bs = digest.base64_decode("VE9EQVlJU01ZSEFQUFlEQVkmXnNzJCEhQCNz"); synthetic {"SIGN:"} + var.test + {" path: "} + req.url.path + {" x-exp:"} + req.http.X-Exp + {" mackey:"} + var.bs + {" myset:"} + var.test_my + {" realtest:"} + var.test_real + {" "}; return(deliver);
Reference:
http://book.varnish-software.com/3.0/VCL_functions.html
https://docs.fastly.com/guides/vcl/local-variables-in-vcl.html
http://book.varnish-software.com/3.0/VCL_Basics.html
http://book.varnish-software.com/3.0/VCL_functions.html
https://docs.fastly.com/guides/vcl/local-variables-in-vcl.html
http://book.varnish-software.com/3.0/VCL_Basics.html
沒有留言:
張貼留言