浏览代码

Improve token error reporting in Prosody JWT plugin

master
paweldomas 9 年前
父节点
当前提交
5a95edbdcd
共有 2 个文件被更改,包括 5 次插入2 次删除
  1. 3
    0
      prosody-plugins/mod_auth_token.lua
  2. 2
    2
      prosody-plugins/token/util.lib.lua

+ 3
- 0
prosody-plugins/mod_auth_token.lua 查看文件

80
 		-- here we check if 'room' claim exists
80
 		-- here we check if 'room' claim exists
81
 		local room, roomErr = token_util.get_room_name(token, appSecret);
81
 		local room, roomErr = token_util.get_room_name(token, appSecret);
82
 		if room == nil then
82
 		if room == nil then
83
+            if roomErr == nil then
84
+                roomErr = "'room' claim is missing";
85
+            end
83
 			return false, "not-allowed", roomErr;
86
 			return false, "not-allowed", roomErr;
84
 		end
87
 		end
85
 
88
 

+ 2
- 2
prosody-plugins/token/util.lib.lua 查看文件

23
 
23
 
24
 	local issClaim = claims["iss"];
24
 	local issClaim = claims["iss"];
25
 	if issClaim == nil then
25
 	if issClaim == nil then
26
-		return nil, "Issuer field is missing";
26
+		return nil, "'iss' claim is missing";
27
 	end
27
 	end
28
 	if issClaim ~= appId then
28
 	if issClaim ~= appId then
29
 		return nil, "Invalid application ID('iss' claim)";
29
 		return nil, "Invalid application ID('iss' claim)";
31
 
31
 
32
 	local roomClaim = claims["room"];
32
 	local roomClaim = claims["room"];
33
 	if roomClaim == nil then
33
 	if roomClaim == nil then
34
-		return nil, "Room field is missing";
34
+		return nil, "'room' claim is missing";
35
 	end
35
 	end
36
 	if roomName ~= nil and roomName ~= roomClaim then
36
 	if roomName ~= nil and roomName ~= roomClaim then
37
 		return nil, "Invalid room name('room' claim)";
37
 		return nil, "Invalid room name('room' claim)";

正在加载...
取消
保存