You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

util.lib.lua 958B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. -- Token authentication
  2. -- Copyright (C) 2015 Atlassian
  3. local jwt = require "luajwtjitsi";
  4. local _M = {};
  5. local function _verify_token(token, appId, appSecret, disableRoomNameConstraints)
  6. local claims, err = jwt.decode(token, appSecret, true);
  7. if claims == nil then
  8. return nil, err;
  9. end
  10. local alg = claims["alg"];
  11. if alg ~= nil and (alg == "none" or alg == "") then
  12. return nil, "'alg' claim must not be empty";
  13. end
  14. local issClaim = claims["iss"];
  15. if issClaim == nil then
  16. return nil, "'iss' claim is missing";
  17. end
  18. if issClaim ~= appId then
  19. return nil, "Invalid application ID('iss' claim)";
  20. end
  21. local roomClaim = claims["room"];
  22. if roomClaim == nil and disableRoomNameConstraints ~= true then
  23. return nil, "'room' claim is missing";
  24. end
  25. return claims;
  26. end
  27. function _M.verify_token(token, appId, appSecret, disableRoomNameConstraints)
  28. return _verify_token(token, appId, appSecret, disableRoomNameConstraints);
  29. end
  30. return _M;