Parcourir la source

Merge pull request #815 from SamWhited/mod_auth_token_tweaks

mod_auth_token: Misc minor fixes
j8
Paweł Domas il y a 9 ans
Parent
révision
ad68d535b4
1 fichiers modifiés avec 9 ajouts et 10 suppressions
  1. 9
    10
      prosody-plugins/mod_auth_token.lua

+ 9
- 10
prosody-plugins/mod_auth_token.lua Voir le fichier

1
 -- Token authentication
1
 -- Token authentication
2
 -- Copyright (C) 2015 Atlassian
2
 -- Copyright (C) 2015 Atlassian
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 formdecode = require "util.http".formdecode;
6
 local formdecode = require "util.http".formdecode;
7
 local generate_uuid = require "util.uuid".generate;
7
 local generate_uuid = require "util.uuid".generate;
8
 local http = require "net.http";
8
 local http = require "net.http";
9
-local json = require 'cjson'
10
-json.encode_empty_table('array')
9
+local json = require "cjson";
11
 local new_sasl = require "util.sasl".new;
10
 local new_sasl = require "util.sasl".new;
12
 local sasl = require "util.sasl";
11
 local sasl = require "util.sasl";
13
 local timer = require "util.timer";
12
 local timer = require "util.timer";
54
 	if query ~= nil then
53
 	if query ~= nil then
55
 		session.auth_token = query and formdecode(query).token or nil;
54
 		session.auth_token = query and formdecode(query).token or nil;
56
 	end
55
 	end
57
-end)
56
+end);
58
 
57
 
59
 function provider.test_password(username, password)
58
 function provider.test_password(username, password)
60
 	return nil, "Password based auth not supported";
59
 	return nil, "Password based auth not supported";
142
 
141
 
143
 		local pubKey;
142
 		local pubKey;
144
 		if asapKeyServer and session.auth_token ~= nil then
143
 		if asapKeyServer and session.auth_token ~= nil then
145
-			local dotFirst = session.auth_token:find("%.")
144
+			local dotFirst = session.auth_token:find("%.");
146
 			if not dotFirst then return nil, "Invalid token" end
145
 			if not dotFirst then return nil, "Invalid token" end
147
-			local header = json.decode(basexx.from_url64(session.auth_token:sub(1,dotFirst-1)))
148
-			local kid = header["kid"]
146
+			local header = json.decode(basexx.from_url64(session.auth_token:sub(1,dotFirst-1)));
147
+			local kid = header["kid"];
149
 			if kid == nil then
148
 			if kid == nil then
150
 				return false, "not-allowed", "'kid' claim is missing";
149
 				return false, "not-allowed", "'kid' claim is missing";
151
 			end
150
 			end
167
 			session.jitsi_meet_room = claims["room"];
166
 			session.jitsi_meet_room = claims["room"];
168
 			return true;
167
 			return true;
169
 		else
168
 		else
170
-			return false, "not-allowed", msg
169
+			return false, "not-allowed", msg;
171
 		end
170
 		end
172
 	end
171
 	end
173
 
172
 
186
 	self.username = username;
185
 	self.username = username;
187
 
186
 
188
 	if result == true then
187
 	if result == true then
189
-		return "success"
188
+		return "success";
190
 	else
189
 	else
191
 
190
 
192
-		return "failure", err, msg
191
+		return "failure", err, msg;
193
 	end
192
 	end
194
 end
193
 end
195
 
194
 

Chargement…
Annuler
Enregistrer