Hex Decode Function Unavailable
I'd like to have Fastly serve as a mid-tier CDN cache, which includes re-validating signed URLs already validated by other CDNs at the edge. One of the CDNs we're using has an URL-signing scheme that uses a hex-encoded URL signature. The signature must be decoded at Fastly to perform validation.
Fastly doesn't appear to include VCL functions to hex-decode strings. Does anyone have recommendations for how to accomplish this? Is there something akin to the 'decode' function in 'vmod.blob'?
-
Hi skidder,
We have had customer requests to add a hex encoding/decoding function to Fastly in the past. We do have a ticket in with engineering, but it looks like it's currently in their backlog. I'll definitely add this request to the ticket so they know this is still an actively requested feature.
In the mean time, I'm not sure how your hex-encoded URL signature is set up, but if it happens to be built off of a time stamp, we do have time.hex_to_time().
And, as always, we encourage you to reach out to our support team at support@fastly.com with any specific questions so we might be able to help you find a solution.
-
Found a clever way to get hex decode since vcl support urldecode:
declare local var.foo STRING;
set var.foo ="636F6C696E";
set var.foo = regsuball(var.foo, "(..)", "%25\1");
#will yield "colin"
log urldecode(var.foo);
Please sign in to leave a comment.
Comments
2 comments