Skip to content

Instantly share code, notes, and snippets.

@mizzy
Created December 11, 2012 02:11
Show Gist options
  • Select an option

  • Save mizzy/4255222 to your computer and use it in GitHub Desktop.

Select an option

Save mizzy/4255222 to your computer and use it in GitHub Desktop.
hmac = require "hmac";
local args = ngx.req.get_uri_args()
ngx.var.filename = args["filename"];
if ngx.now() > ngx.parse_http_time(args["expire"]) then
ngx.exit(403);
end
if args["sign"] ~= hmac.hmac_sha1("secret", args["filename"] .. args["expire"]) then
ngx.exit(403);
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment