Browse Source

Populate the token cache

j8
Sam Whited 9 years ago
parent
commit
3128628d09
1 changed files with 5 additions and 2 deletions
  1. 5
    2
      prosody-plugins/mod_auth_token.lua

+ 5
- 2
prosody-plugins/mod_auth_token.lua View File

@@ -94,12 +94,15 @@ function get_public_key(keyId)
94 94
 		local wait, done = async.waiter();
95 95
 		local function cb(content_, code_, response_, request_)
96 96
 			content, code = content_, code_;
97
+			if code == 200 or code == 204 then
98
+				cache:set(keyId, content);
99
+			end
97 100
 			done();
98 101
 		end
99 102
 		module:log("debug", "Fetching public key from: "..asapKeyServer..keyId);
100 103
 
101
-		-- We hash the key ID to work around some legacy behavior in the original
102
-		-- deployment and make deployment easier. It also helps prevent directory
104
+		-- We hash the key ID to work around some legacy behavior and make
105
+		-- deployment easier. It also helps prevent directory
103 106
 		-- traversal attacks (although path cleaning could have done this too).
104 107
 		local request = http.request(asapKeyServer..sha256(keyId)..'.pem', {
105 108
 			headers = http_headers or {},

Loading…
Cancel
Save