This plugin implements a Prosody authentication provider that verifies a client connection based on a JWT token described in RFC7519. It allows use of an external form of authentication with lib-jitsi-meet. Once your user authenticates you need to generate the JWT token as described in the RFC and pass it to your client app. Once it connects with a valid token it is considered authenticated by the jitsi-meet system.
During configuration you will need to provide the application ID that identifies the client and a secret shared by both server and JWT token generator. Like described in the RFC, the secret is used to compute a HMAC hash value which allows authentication of the generated token. There are many existing libraries which can be used to implement token generation. More info can be found here: http://jwt.io/#libraries-io
JWT token authentication only currently works with BOSH connections.
The following JWT claims are used in the authentication token:
The secret is used to compute the HMAC hash value and verify the token for HS256 tokens.
Alternately the token may be signed by a private key and authorized via a public keyserver using RS256 tokens. In this mode, the ‘kid’ header of the JWT must be set to the name of the public key. The backend server must be configured to fetch and confirm keys from a pre-configured public keyserver.
In addition to the basic claims used in authentication, the token can also provide user display information in the ‘context’ field within the JWT payload. None of the information in the context field is used for token validation:
null
will generate an exception.To access the data in lib-jitsi-meet you have to enable the prosody module mod_presence_identity
in your config.
VirtualHost "jitmeet.example.com"
modules_enabled = { "presence_identity" }
The data is now available in the identity in the JitsiParticipant class. You can access them by e.g. listening to the USER_JOINED
event.
NOTE: The values in the token shall always be valid values. If you define e.g. the avatar as null
it will throw an error.
{
"kid": "jitsi/custom_key_name",
"typ": "JWT",
"alg": "RS256"
}
{
"context": {
"user": {
"avatar": "https:/gravatar.com/avatar/abc123",
"name": "John Doe",
"email": "jdoe@example.com",
"id": "abcd:a1b2c3-d4e5f6-0abc1-23de-abcdef01fedcba"
},
"group": "a123-123-456-789"
},
"aud": "jitsi",
"iss": "my_client",
"sub": "meet.jit.si",
"room": "*",
"exp": 1500006923
}
JWT token is currently checked in 2 places:
When JWT authentication is used with lib-jitsi-meet the token is passed to the JitsiConference constructor:
var token = {token is provided by your application possibly after some authentication}
JitsiMeetJS.init(initOptions).then(function(){
connection = new JitsiMeetJS.JitsiConnection(APP_ID, token, options);
...
connection.connect();
});
In order to start a jitsi-meet conference with a token you need to specify the token as an URL param:
https://example.com/angrywhalesgrowhigh?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ
At the current level of integration every user that joins the conference has to provide the token and not just the one who creates the room. It should be possible to change that by using a second anonymous domain, but that hasn’t been tested yet.
Token authentication can be integrated automatically using a Debian package install. Once you have jitsi-meet installed just install ‘jitsi-meet-tokens’ on top of it. In order to have it configured automatically at least version 779 of jitsi-meet is required which comes with a special Prosody config template.
apt-get install jitsi-meet-tokens
Check the “Prosody Version” that is used in the deployment.
JWT tokens requires prosody 0.11.6 or higher.
Make sure that /etc/prosody/prosody.cfg.lua contains the line below at the end to include meet host config. That’s because Prosody nightly may come with slightly different default config:
Include "conf.d/*.cfg.lua"
Also check if client to server encryption is enforced. If not then token authentication won’t work:
c2s_require_encryption=false
Restart the service to take the changes into account
sudo /etc/init.d/prosody restart
Modify your Prosody config with these three steps:
\1. Adjust plugin_paths to contain the path pointing to the jitsi meet Prosody plugins location. That’s where plugins are copied on jitsi-meet-token package installation. This should be included in the global config section (possibly at the beginning of your host config file).
plugin_paths = { "/usr/share/jitsi-meet/prosody-plugins/" }
Also, you need to set the global settings for key authorization. Both these options used to default to the ‘*’ parameter which means accept any issuer or audience string in incoming tokens, but that is no longer the case.
asap_accepted_issuers = { "*" }
asap_accepted_audiences = { "*" }
\2. Under your domain config change authentication to “token” and provide the application ID, secret and optionally the token lifetime:
VirtualHost "jitmeet.example.com"
authentication = "token";
app_id = "example_app_id"; -- application identifier
app_secret = "example_app_secret"; -- application secret known only to your token
-- generator and the plugin
allow_empty_token = false; -- tokens are verified only if they are supplied by the client
Alternately instead of using a shared secret you can set an asap_key_server to the base URL where valid/accepted public keys can be found by taking a sha256() of the ‘kid’ field in the JWT token header, and appending .pem to the end
VirtualHost "jitmeet.example.com"
authentication = "token";
app_id = "example_app_id"; -- application identifier
asap_key_server = "https://keyserver.example.com/asap"; -- URL for public keyserver storing keys by kid
allow_empty_token = false; -- tokens are verified only if they are supplied
\3. Enable the room name token verification plugin in your MUC component config section:
Component "conference.jitmeet.example.com" "muc"
modules_enabled = { "token_verification" }