|
@@ -159,9 +159,10 @@ end
|
159
|
159
|
|
160
|
160
|
--- Verifies issuer part of token
|
161
|
161
|
-- @param 'iss' claim from the token to verify
|
|
162
|
+-- @param 'acceptedIssuers' list of issuers to check
|
162
|
163
|
-- @return nil and error string or true for accepted claim
|
163
|
|
-function Util:verify_issuer(issClaim)
|
164
|
|
- for i, iss in ipairs(self.acceptedIssuers) do
|
|
164
|
+function Util:verify_issuer(issClaim, acceptedIssuers)
|
|
165
|
+ for i, iss in ipairs(acceptedIssuers) do
|
165
|
166
|
if issClaim == iss then
|
166
|
167
|
--claim matches an accepted issuer so return success
|
167
|
168
|
return true;
|
|
@@ -192,8 +193,9 @@ end
|
192
|
193
|
--- Verifies token
|
193
|
194
|
-- @param token the token to verify
|
194
|
195
|
-- @param secret the secret to use to verify token
|
|
196
|
+-- @param acceptedIssuers the list of accepted issuers to check
|
195
|
197
|
-- @return nil and error or the extracted claims from the token
|
196
|
|
-function Util:verify_token(token, secret)
|
|
198
|
+function Util:verify_token(token, secret, acceptedIssuers)
|
197
|
199
|
local claims, err = jwt.decode(token, secret, true);
|
198
|
200
|
if claims == nil then
|
199
|
201
|
return nil, err;
|
|
@@ -209,7 +211,7 @@ function Util:verify_token(token, secret)
|
209
|
211
|
return nil, "'iss' claim is missing";
|
210
|
212
|
end
|
211
|
213
|
--check the issuer against the accepted list
|
212
|
|
- local issCheck, issCheckErr = self:verify_issuer(issClaim);
|
|
214
|
+ local issCheck, issCheckErr = self:verify_issuer(issClaim, acceptedIssuers);
|
213
|
215
|
if issCheck == nil then
|
214
|
216
|
return nil, issCheckErr;
|
215
|
217
|
end
|
|
@@ -241,8 +243,13 @@ end
|
241
|
243
|
-- session.jitsi_meet_context_group - the group value from the token
|
242
|
244
|
-- session.jitsi_meet_context_features - the features value from the token
|
243
|
245
|
-- @param session the current session
|
|
246
|
+-- @param acceptedIssuers optional list of accepted issuers to check
|
244
|
247
|
-- @return false and error
|
245
|
|
-function Util:process_and_verify_token(session)
|
|
248
|
+function Util:process_and_verify_token(session, acceptedIssuers)
|
|
249
|
+ if not acceptedIssuers then
|
|
250
|
+ acceptedIssuers = self.acceptedIssuers;
|
|
251
|
+ end
|
|
252
|
+
|
246
|
253
|
if session.auth_token == nil then
|
247
|
254
|
if self.allowEmptyToken then
|
248
|
255
|
return true;
|
|
@@ -272,9 +279,9 @@ function Util:process_and_verify_token(session)
|
272
|
279
|
-- now verify the whole token
|
273
|
280
|
local claims, msg;
|
274
|
281
|
if self.asapKeyServer then
|
275
|
|
- claims, msg = self:verify_token(session.auth_token, pubKey);
|
|
282
|
+ claims, msg = self:verify_token(session.auth_token, pubKey, acceptedIssuers);
|
276
|
283
|
else
|
277
|
|
- claims, msg = self:verify_token(session.auth_token, self.appSecret);
|
|
284
|
+ claims, msg = self:verify_token(session.auth_token, self.appSecret, acceptedIssuers);
|
278
|
285
|
end
|
279
|
286
|
if claims ~= nil then
|
280
|
287
|
-- Binds room name to the session which is later checked on MUC join
|
|
@@ -401,4 +408,4 @@ function Util:verify_room(session, room_address)
|
401
|
408
|
end
|
402
|
409
|
end
|
403
|
410
|
|
404
|
|
-return Util;
|
|
411
|
+return Util;
|