Selaa lähdekoodia

Merge pull request #828 from SamWhited/mod_token_use_proper_path

Use valid path for HTTP token fetches
master
Paweł Domas 8 vuotta sitten
vanhempi
commit
5ef547d285
1 muutettua tiedostoa jossa 5 lisäystä ja 2 poistoa
  1. 5
    2
      prosody-plugins/mod_auth_token.lua

+ 5
- 2
prosody-plugins/mod_auth_token.lua Näytä tiedosto

3
 
3
 
4
 local basexx = require "basexx";
4
 local basexx = require "basexx";
5
 local have_async, async = pcall(require, "util.async");
5
 local have_async, async = pcall(require, "util.async");
6
+local hex = require "util.hex";
6
 local formdecode = require "util.http".formdecode;
7
 local formdecode = require "util.http".formdecode;
7
 local generate_uuid = require "util.uuid".generate;
8
 local generate_uuid = require "util.uuid".generate;
8
 local http = require "net.http";
9
 local http = require "net.http";
9
 local json = require "cjson";
10
 local json = require "cjson";
10
 local new_sasl = require "util.sasl".new;
11
 local new_sasl = require "util.sasl".new;
12
+local path = require "util.paths";
11
 local sasl = require "util.sasl";
13
 local sasl = require "util.sasl";
12
 local sha256 = require "util.hashes".sha256;
14
 local sha256 = require "util.hashes".sha256;
13
 local timer = require "util.timer";
15
 local timer = require "util.timer";
99
 			end
101
 			end
100
 			done();
102
 			done();
101
 		end
103
 		end
102
-		module:log("debug", "Fetching public key from: "..asapKeyServer..keyId);
104
+		local keyurl = path.join(asapKeyServer, hex.to(sha256(keyId))..'.pem');
105
+		module:log("debug", "Fetching public key from: "..keyurl);
103
 
106
 
104
 		-- We hash the key ID to work around some legacy behavior and make
107
 		-- We hash the key ID to work around some legacy behavior and make
105
 		-- deployment easier. It also helps prevent directory
108
 		-- deployment easier. It also helps prevent directory
106
 		-- traversal attacks (although path cleaning could have done this too).
109
 		-- traversal attacks (although path cleaning could have done this too).
107
-		local request = http.request(asapKeyServer..sha256(keyId)..'.pem', {
110
+		local request = http.request(keyurl, {
108
 			headers = http_headers or {},
111
 			headers = http_headers or {},
109
 			method = "GET"
112
 			method = "GET"
110
 		}, cb);
113
 		}, cb);

Loading…
Peruuta
Tallenna