comparison mod_pubsub_post/mod_pubsub_post.lua @ 3504:9ef5b229f73e

mod_pubsub_post: Make debug messages more informative
author Kim Alvefur <zash@zash.se>
date Sat, 30 Mar 2019 21:34:28 +0100
parents 882180b459a0
children 0d3926e49b55
comparison
equal deleted inserted replaced
3503:882180b459a0 3504:9ef5b229f73e
93 return hmac(secret, body) == from_hex(digest); 93 return hmac(secret, body) == from_hex(digest);
94 end 94 end
95 95
96 function handle_POST(event, path) 96 function handle_POST(event, path)
97 local request = event.request; 97 local request = event.request;
98 module:log("debug", "Handling POST: \n%s\n", tostring(request.body));
99 98
100 local content_type = request.headers.content_type or "application/octet-stream"; 99 local content_type = request.headers.content_type or "application/octet-stream";
101 local actor = actors and actors[path] or default_actor or request.ip; 100 local actor = actors and actors[path] or default_actor or request.ip;
102 local secret = actor_secrets and actor_secrets[path] or default_secret; 101 local secret = actor_secrets and actor_secrets[path] or default_secret;
103 102
103 module:log("debug", "Handling POST to node %q by %q with %q: \n%s\n", path, actor, content_type, request.body);
104
104 if secret and not verify_signature(secret, request.body, request.headers.x_hub_signature) then 105 if secret and not verify_signature(secret, request.body, request.headers.x_hub_signature) then
106 module:log("debug", "Signature validation failed");
105 return 401; 107 return 401;
106 end 108 end
107 109
108 if not actor then 110 if not actor then
109 return 401; 111 return 401;