hmac authentication using vcl

Comments

3 comments

  • Hiro

    Hi jsp,

    I'd suggest testing with querystring.regfilter(<string>, <string>). Documentation: https://docs.fastly.com/guides/vcl/query-string-manipulation-vcl-features

    For example, If you add the following code in your vcl_recv, set req.url = querystring.regfilter(req.url, "^hmac"); It will extract the hmac query from the URL, so your origin will receive the request as /?q1=xxx&q2=yyy instead. If you don't want to manipulate the original URL, you can work around with req.http.* header or local variables to store the hmac value.

    Best, Hiro

    0
    Comment actions Permalink
  • jsp

    Hiro, Thanks for replying. I tried the following ...any thoughts on this

    set var.message = subfield(req.url, "x", "?") "&" subfield(req.url, "y", "&");
    set var.urlhash = subfield(req.url, "hmac", "&");
    

    jsp

    0
    Comment actions Permalink
  • Junichi

    Hello,

    You can use req.url.qs instead. set var.urlhash = subfield(req.url.qs, "hmac", "&");

    Works. https://fiddle.fastlydemo.net/fiddle/ee893bc7

    I hope this will be helpful.

    Junichi

    0
    Comment actions Permalink

Please sign in to leave a comment.