瀏覽代碼

Populate the token cache

j8
Sam Whited 9 年之前
父節點
當前提交
3128628d09
共有 1 個檔案被更改,包括 5 行新增2 行删除
  1. 5
    2
      prosody-plugins/mod_auth_token.lua

+ 5
- 2
prosody-plugins/mod_auth_token.lua 查看文件

94
 		local wait, done = async.waiter();
94
 		local wait, done = async.waiter();
95
 		local function cb(content_, code_, response_, request_)
95
 		local function cb(content_, code_, response_, request_)
96
 			content, code = content_, code_;
96
 			content, code = content_, code_;
97
+			if code == 200 or code == 204 then
98
+				cache:set(keyId, content);
99
+			end
97
 			done();
100
 			done();
98
 		end
101
 		end
99
 		module:log("debug", "Fetching public key from: "..asapKeyServer..keyId);
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
 		-- traversal attacks (although path cleaning could have done this too).
106
 		-- traversal attacks (although path cleaning could have done this too).
104
 		local request = http.request(asapKeyServer..sha256(keyId)..'.pem', {
107
 		local request = http.request(asapKeyServer..sha256(keyId)..'.pem', {
105
 			headers = http_headers or {},
108
 			headers = http_headers or {},

Loading…
取消
儲存