Bläddra i källkod

feat: Jaas example that uses local jitsi-meet (#13350)

* feat: Adds an example to convert a deployment to use jaas.

* squash: Generates the daily asap token with expiration of 1 day.

The default is 1 hour.

* squash: Use local deployment UI with jaas, not 8x8.vc one.

- We load config.js from 8x8.vc with the tenant, to allow release pinning to work.

- We sed the vpass_cookie in the custom nginx conf as variables are not allowed in location matching.

- The jaas-vars need to be global as it will overwrite config.js location and index html.

* squash: Enables e2ee for the meetings.

* squash: Bump node version check.

* squash: Fix filename.

* squash: Updates the readme.

* squash: Checks whether node is installed.

* squash: Fixes initial configuration.

The jaas-vars is required to reload nginx, done by update-asap-daily script.

* squash: More fixes of misspelled config file.

* squash: Fixes serving the pub key.
factor2
Дамян Минков 2 år sedan
förälder
incheckning
d8c7f8de81
Inget konto är kopplat till bidragsgivarens mejladress

+ 2
- 0
.eslintignore Visa fil

@@ -1,6 +1,8 @@
1 1
 # The build artifacts of the jitsi-meet project.
2 2
 build/*
3 3
 
4
+doc/*
5
+
4 6
 # Third-party source code which we (1) do not want to modify or (2) try to
5 7
 # modify as little as possible.
6 8
 libs/*

+ 3
- 0
debian/jitsi-meet-web-config.install Visa fil

@@ -1,3 +1,6 @@
1 1
 doc/debian/jitsi-meet/jitsi-meet.example        /usr/share/jitsi-meet-web-config/
2 2
 doc/debian/jitsi-meet/jitsi-meet.example-apache /usr/share/jitsi-meet-web-config/
3 3
 config.js                                       /usr/share/jitsi-meet-web-config/
4
+doc/jaas/nginx-jaas.conf                        /usr/share/jitsi-meet-web-config/
5
+doc/jaas/index-jaas.html                        /usr/share/jitsi-meet-web-config/
6
+doc/jaas/8x8.vc-config.js                        /usr/share/jitsi-meet-web-config/

+ 2
- 0
debian/jitsi-meet-web.install Visa fil

@@ -12,3 +12,5 @@ resources/robots.txt	/usr/share/jitsi-meet/
12 12
 resources/*.sh			/usr/share/jitsi-meet/scripts/
13 13
 pwa-worker.js			/usr/share/jitsi-meet/
14 14
 manifest.json			/usr/share/jitsi-meet/
15
+doc/jaas/move-to-jaas.sh        /usr/share/jitsi-meet/scripts/
16
+doc/jaas/update-asap-daily.sh   /usr/share/jitsi-meet/scripts/

+ 13
- 3
doc/debian/jitsi-meet/jitsi-meet.example Visa fil

@@ -58,6 +58,8 @@ server {
58 58
 
59 59
     add_header Strict-Transport-Security "max-age=63072000" always;
60 60
     set $prefix "";
61
+    set $custom_index "";
62
+    set $config_js_location /etc/jitsi/meet/jitsi-meet.example.com-config.js;
61 63
 
62 64
     ssl_certificate /etc/jitsi/meet/jitsi-meet.example.com.crt;
63 65
     ssl_certificate_key /etc/jitsi/meet/jitsi-meet.example.com.key;
@@ -77,8 +79,10 @@ server {
77 79
     gzip_proxied no-cache no-store private expired auth;
78 80
     gzip_min_length 512;
79 81
 
82
+    include /etc/jitsi/meet/jaas/*.conf;
83
+
80 84
     location = /config.js {
81
-        alias /etc/jitsi/meet/jitsi-meet.example.com-config.js;
85
+        alias $config_js_location;
82 86
     }
83 87
 
84 88
     location = /external_api.js {
@@ -92,6 +96,11 @@ server {
92 96
         proxy_set_header Host $http_host;
93 97
     }
94 98
 
99
+    location ~ ^/_api/public/(.*)$ {
100
+        autoindex off;
101
+        alias /etc/jitsi/meet/public/$1;
102
+    }
103
+
95 104
     # ensure all static content can always be found first
96 105
     location ~ ^/(libs|css|static|images|fonts|lang|sounds|.well-known)/(.*)$
97 106
     {
@@ -142,11 +151,12 @@ server {
142 151
     #}
143 152
 
144 153
     location ~ ^/([^/?&:'"]+)$ {
154
+        set $roomname "$1";
145 155
         try_files $uri @root_path;
146 156
     }
147 157
 
148 158
     location @root_path {
149
-        rewrite ^/(.*)$ / break;
159
+        rewrite ^/(.*)$ /$custom_index break;
150 160
     }
151 161
 
152 162
     location ~ ^/([^/?&:'"]+)/config.js$
@@ -154,7 +164,7 @@ server {
154 164
         set $subdomain "$1.";
155 165
         set $subdir "$1/";
156 166
 
157
-        alias /etc/jitsi/meet/jitsi-meet.example.com-config.js;
167
+        alias $config_js_location;
158 168
     }
159 169
 
160 170
     # Matches /(TENANT)/pwa-worker.js or /(TENANT)/manifest.json to rewrite to / and look for file

+ 7
- 0
doc/jaas/8x8.vc-config.js Visa fil

@@ -0,0 +1,7 @@
1
+</script>
2
+<script src="https://8x8.vc/<!--# echo var="subdir" default="" -->config.js" onload="{
3
+config.p2p.disabledCodec='VP9';
4
+config.videoQuality.disabledCodec='VP9';
5
+config.e2ee = { externallyManagedKey: true };
6
+}"/>
7
+<script>

+ 22
- 0
doc/jaas/README.md Visa fil

@@ -0,0 +1,22 @@
1
+## How to switch your deployment to [JaaS](https://jaas.8x8.vc) in one easy step
2
+
3
+Note: By default it will have e2ee(end-to-end) encryption enabled that works only on chromium based browsers (Chrome, Edge, ...). If a participant joins from another browser or mobile the e2ee is turned off. 
4
+
5
+In order to use your deployment with JaaS you first need to login to your [JaaS Developer console](https://jaas.8x8.vc/#/apikeys) and generate a key pair.
6
+Use `Add API key` button and then `Generate API key pair`. Make sure you download the generated private key from:
7
+
8
+<img src="generated_key_dialog.png" height="250">
9
+
10
+Make sure you transfer this downloaded private key to your server. Copy the key id from:
11
+
12
+<img src="api_keys_kid.png" height="200">
13
+
14
+Now on your server run the helper script passing the private key file and the key id:
15
+
16
+```
17
+sudo /usr/share/jitsi-meet/scripts/move-to-jaas.sh /my/path/test-key.pk <key_id>
18
+```
19
+
20
+More information about JaaS Api keys at: https://developer.8x8.com/jaas/docs/jaas-console-api-keys
21
+
22
+If you want to adjust the enabled services you can do that in /etc/jits/meet/jaas/nginx-jaas.conf. The part after `proxy_set_body` is the jwt token content that will be used for the client tokens. More info about the JaaS tokens: https://developer.8x8.com/jaas/docs/api-keys-jwt

Binär
doc/jaas/api_keys_kid.png Visa fil


Binär
doc/jaas/generated_key_dialog.png Visa fil


+ 33
- 0
doc/jaas/index-jaas.html Visa fil

@@ -0,0 +1,33 @@
1
+<!DOCTYPE html>
2
+<html>
3
+    <head>
4
+        <script src='external_api.js' async></script>
5
+        <style>html, body, #jaas-container { height: 100%; }</style>
6
+        <script type="text/javascript">
7
+            function getRoomName(pathname) {
8
+                const contextRootEndIndex = pathname.lastIndexOf('/');
9
+
10
+                return pathname.substring(contextRootEndIndex + 1);
11
+            }
12
+            window.onload = () => {
13
+                const jaasJwt = <!--#include virtual="/jaas-jwt" -->;
14
+                const api = new JitsiMeetExternalAPI(
15
+                    window.location.host, {
16
+                        roomName: `${jaasJwt.tenant}/${getRoomName(window.location.pathname)}`,
17
+                        parentNode: document.querySelector('#jaas-container'),
18
+                        jwt: jaasJwt.token,
19
+                        e2eeKey: jaasJwt.e2eeKey
20
+                    });
21
+                api.addListener('videoConferenceJoined', () => {
22
+                    if (jaasJwt.e2eeKey) {
23
+                        console.info('Toggling e2ee on!')
24
+                        api.executeCommand('toggleE2EE', true);
25
+                    }
26
+                });
27
+            }
28
+        </script>
29
+    </head>
30
+    <body>
31
+        <div id="jaas-container" />
32
+    </body>
33
+</html>

+ 59
- 0
doc/jaas/move-to-jaas.sh Visa fil

@@ -0,0 +1,59 @@
1
+#!/bin/bash
2
+
3
+set -e
4
+
5
+PRIVATE_KEY=$1
6
+JAAS_KEY_ID=$2
7
+
8
+if [ ! -f "${PRIVATE_KEY}" ] ; then
9
+  echo "You need to specify a correct path for the private key as a first argument."
10
+  exit 1;
11
+fi
12
+
13
+if [[ ! "${JAAS_KEY_ID}" =~ ^vpaas-magic-cookie-[0-9a-z]+/[0-9a-z]+$ ]]; then
14
+    echo "Invalid key id passed as a second argument."
15
+    exit 2;
16
+fi
17
+
18
+command -v node >/dev/null 2>&1 || { echo >&2 "You must install node first, go to https://nodejs.org. Aborting."; exit 4; }
19
+
20
+NODE_VER=$(node -v);
21
+NODE_MAJOR_VER=$(echo ${NODE_VER:1} |  cut -d. -f1);
22
+
23
+if [ "$NODE_MAJOR_VER" -lt "18" ]; then
24
+    echo "Please install latest LTS version of node (18+)";
25
+    exit 3;
26
+fi
27
+
28
+# we need this util for debconf-set-selections
29
+sudo apt install debconf-utils
30
+
31
+# Let's pre-set some settings for token-generator
32
+cat << EOF | sudo debconf-set-selections
33
+token-generator token-generator/private-key string ${PRIVATE_KEY}
34
+token-generator token-generator/kid  string ${JAAS_KEY_ID}
35
+EOF
36
+
37
+apt install token-generator
38
+
39
+mkdir -p /etc/jitsi/meet/jaas
40
+
41
+VPASS_COOKIE=$(echo -n ${JAAS_KEY_ID}| cut -d/ -f1)
42
+cp /usr/share/jitsi-meet-web-config/nginx-jaas.conf /etc/jitsi/meet/jaas
43
+sed -i "s/jaas_magic_cookie/${VPASS_COOKIE}/g" /etc/jitsi/meet/jaas/nginx-jaas.conf
44
+
45
+cp /usr/share/jitsi-meet-web-config/8x8.vc-config.js /etc/jitsi/meet/jaas/
46
+echo "set \$config_js_location /etc/jitsi/meet/jaas/8x8.vc-config.js;" >> /etc/jitsi/meet/jaas/jaas-vars
47
+echo "set \$custom_index index-jaas.html;" >> /etc/jitsi/meet/jaas/jaas-vars
48
+
49
+ln -s /usr/share/jitsi-meet-web-config/index-jaas.html /usr/share/jitsi-meet/index-jaas.html
50
+
51
+# let's create the daily key now
52
+/usr/share/jitsi-meet/scripts/update-asap-daily.sh
53
+
54
+# let's add to cron daily the update of the asap key
55
+if [ -d /etc/cron.daily ]; then
56
+  ln -s /usr/share/jitsi-meet/scripts/update-asap-daily.sh /etc/cron.daily/update-jaas-asap.sh
57
+else
58
+  echo "No /etc/cron.daily. Please add to your cron jobs to execute as root daily the script: /usr/share/jitsi-meet/scripts/update-asap-daily.sh"
59
+fi

+ 23
- 0
doc/jaas/nginx-jaas.conf Visa fil

@@ -0,0 +1,23 @@
1
+include /etc/jitsi/meet/jaas/jaas-vars;
2
+location = /jaas-jwt {
3
+  include /etc/jitsi/token-generator/daily-key;
4
+  ssi on;
5
+  proxy_method POST;
6
+  proxy_set_header content-type "application/json";
7
+  proxy_set_header Accept-Encoding "";
8
+  proxy_set_header Authorization "Bearer $jaas_asap_key";
9
+  proxy_pass_request_body off;
10
+  proxy_set_body '{"sub":"jaas_magic_cookie","context":{"features":{"livestreaming":false,"outbound-call":false,"sip-outbound-call":false,"transcription":false,"recording":false},"user":{"moderator":true}},"room": "$roomname"}';
11
+  proxy_pass http://127.0.0.1:8017/generate/client?e2eeKey=true;
12
+}
13
+
14
+location @magic_root_path {
15
+    rewrite ^/(.*)$ /index.html break;
16
+}
17
+
18
+# Anything that didn't match above, and isn't a real file, assume it's a room name and redirect to /
19
+location ~ ^/jaas_magic_cookie/(.*)$ {
20
+    set $subdomain "jaas_magic_cookie.";
21
+    set $subdir "jaas_magic_cookie/";
22
+    try_files $1 @magic_root_path;
23
+}

+ 9
- 0
doc/jaas/update-asap-daily.sh Visa fil

@@ -0,0 +1,9 @@
1
+JWT_KID=$(cat /etc/jitsi/token-generator/config | grep  SYSTEM_ASAP_BASE_URL_MAPPINGS | cut -d= -f2- | jq -r .[].kid)
2
+JWT_DATE=$(echo -n $JWT_KID | cut -d/ -f2-)
3
+JWT_DATE=${JWT_DATE#jwt-}
4
+KEY_FILE=/etc/jitsi/token-generator/daily-key
5
+echo -n "set \$jaas_asap_key " > ${KEY_FILE}
6
+ASAP_KEY=$(ASAP_SIGNING_KEY_FILE=/etc/jitsi/token-generator/asap-${JWT_DATE}.key ASAP_JWT_KID="${JWT_KID}" ASAP_EXPIRES_IN="1 day" node /usr/share/token-generator/jwt.js| tail -n1)
7
+echo -n "${ASAP_KEY};" >> ${KEY_FILE}
8
+
9
+service nginx reload

+ 16
- 2
modules/API/external/external_api.js Visa fil

@@ -36,7 +36,6 @@ const commands = {
36 36
     cancelPrivateChat: 'cancel-private-chat',
37 37
     closeBreakoutRoom: 'close-breakout-room',
38 38
     displayName: 'display-name',
39
-    e2eeKey: 'e2ee-key',
40 39
     endConference: 'end-conference',
41 40
     email: 'email',
42 41
     grantModerator: 'grant-moderator',
@@ -561,7 +560,22 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
561 560
             switch (name) {
562 561
             case 'video-conference-joined': {
563 562
                 if (typeof this._tmpE2EEKey !== 'undefined') {
564
-                    this.executeCommand(commands.e2eeKey, this._tmpE2EEKey);
563
+
564
+                    const hexToBytes = hex => {
565
+                        const bytes = [];
566
+
567
+                        for (let c = 0; c < hex.length; c += 2) {
568
+                            bytes.push(parseInt(hex.substring(c, c + 2), 16));
569
+                        }
570
+
571
+                        return bytes;
572
+                    };
573
+
574
+                    this.executeCommand('setMediaEncryptionKey', JSON.stringify({
575
+                        exportedKey: hexToBytes(this._tmpE2EEKey),
576
+                        index: 0
577
+                    }));
578
+
565 579
                     this._tmpE2EEKey = undefined;
566 580
                 }
567 581
 

Laddar…
Avbryt
Spara