# HG changeset patch # User Kim Alvefur # Date 1432726076 -7200 # Node ID 6f34e51a23f0af273fb6fa27ca935bc969df92ba # Parent e72f9eac51c8de64b7c3a72d9e0f8f94d26a7ab7 mod_compact_resource: Enforces short random resources diff -r e72f9eac51c8 -r 6f34e51a23f0 mod_compact_resource/mod_compact_resource.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mod_compact_resource/mod_compact_resource.lua Wed May 27 13:27:56 2015 +0200 @@ -0,0 +1,12 @@ + +local base64_encode = require"util.encodings".base64.encode; +local random_bytes = require"util.random".bytes; + +local b64url = { ["+"] = "-", ["/"] = "_", ["="] = "" }; +local function random_resource() + return base64_encode(random_bytes(8)):gsub("[+/=]", b64url); +end + +module:hook("pre-resource-bind", function (event) + event.resource = random_resource(); +end);