mode/jwt.sh: renable jwt setup on QJI #125
			
				
			
		
		
		
	
							
								
								
									
										48
									
								
								mode/jwt.sh
								
								
								
								
							
							
						
						
									
										48
									
								
								mode/jwt.sh
								
								
								
								
							| 
						 | 
					@ -27,31 +27,25 @@ SECRET_APP="$(tr -dc "a-zA-Z0-9" < /dev/urandom | fold -w 64 | head -n1)"
 | 
				
			||||||
SRP_STR="$(grep -n "VirtualHost \"$DOMAIN\"" "$PROSODY_FILE" | head -n1 | cut -d ":" -f1)"
 | 
					SRP_STR="$(grep -n "VirtualHost \"$DOMAIN\"" "$PROSODY_FILE" | head -n1 | cut -d ":" -f1)"
 | 
				
			||||||
SRP_END="$((SRP_STR + 10))"
 | 
					SRP_END="$((SRP_STR + 10))"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Required  openssl for Focal 20.04
 | 
					# Prosody 0.12 only
 | 
				
			||||||
if [ "$(lsb_release -sc)" = "focal" ]; then
 | 
					if command -v prosodyctl >/dev/null 2>&1; then
 | 
				
			||||||
echo "deb http://ppa.launchpad.net/rael-gc/rvm/ubuntu focal main" | \
 | 
					  PROSODY_VER="$(prosodyctl about 2>/dev/null | sed -n 's/^Prosody //p' | awk '{print $1}')"
 | 
				
			||||||
sudo tee /etc/apt/sources.list.d/rvm.list
 | 
					  case "$PROSODY_VER" in
 | 
				
			||||||
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F4E3FBBE
 | 
					    0.12.*) : ;;
 | 
				
			||||||
apt-get update
 | 
					    *) echo "Prosody $PROSODY_VER NO supported for JWT mode (required 0.12.x)"
 | 
				
			||||||
 | 
					       exit 1 ;;
 | 
				
			||||||
 | 
					  esac
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
apt-get -y install \
 | 
					# Install dependencies
 | 
				
			||||||
                    lua5.2 \
 | 
					apt-get -y install python3-jwt
 | 
				
			||||||
                    liblua5.2 \
 | 
					 | 
				
			||||||
                    luarocks \
 | 
					 | 
				
			||||||
                    libssl1.0-dev \
 | 
					 | 
				
			||||||
                    python3-jwt
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
luarocks install basexx
 | 
					 | 
				
			||||||
luarocks install luacrypto
 | 
					 | 
				
			||||||
luarocks install lua-cjson 2.1.0-1
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
echo "set jitsi-meet-tokens/appid string $APP_ID" | debconf-set-selections
 | 
					echo "set jitsi-meet-tokens/appid string $APP_ID" | debconf-set-selections
 | 
				
			||||||
echo "set jitsi-meet-tokens/appsecret password $SECRET_APP" | debconf-set-selections
 | 
					echo "set jitsi-meet-tokens/appsecret password $SECRET_APP" | debconf-set-selections
 | 
				
			||||||
 | 
					
 | 
				
			||||||
apt-get install -y jitsi-meet-tokens
 | 
					apt-get install -y jitsi-meet-tokens
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#Setting up
 | 
					# Setting up
 | 
				
			||||||
sed -i "s|c2s_require_encryption = true|c2s_require_encryption = false|" "$PROSODY_SYS"
 | 
					sed -i "s|c2s_require_encryption = true|c2s_require_encryption = false|" "$PROSODY_SYS"
 | 
				
			||||||
#-
 | 
					#-
 | 
				
			||||||
sed -i "$SRP_STR,$SRP_END{s|authentication = \"jitsi-anonymous\"|authentication = \"token\"|}" "$PROSODY_FILE"
 | 
					sed -i "$SRP_STR,$SRP_END{s|authentication = \"jitsi-anonymous\"|authentication = \"token\"|}" "$PROSODY_FILE"
 | 
				
			||||||
| 
						 | 
					@ -66,11 +60,12 @@ sed -i "/app_secret/a \\\\" "$PROSODY_FILE"
 | 
				
			||||||
sed -i "s|--allow_empty_token =.*|allow_empty_token = false|" "$PROSODY_FILE"
 | 
					sed -i "s|--allow_empty_token =.*|allow_empty_token = false|" "$PROSODY_FILE"
 | 
				
			||||||
sed -i 's|--"token_verification"|"token_verification"|' "$PROSODY_FILE"
 | 
					sed -i 's|--"token_verification"|"token_verification"|' "$PROSODY_FILE"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#Request auth
 | 
					# Request auth
 | 
				
			||||||
sed -i "s|#org.jitsi.jicofo.auth.URL=EXT_JWT:|org.jitsi.jicofo.auth.URL=EXT_JWT:|" "$JICOFO_SIP"
 | 
					## JWT via Prosody: don't touch Jicofo
 | 
				
			||||||
 | 
					#sed -i "s|#org.jitsi.jicofo.auth.URL=EXT_JWT:|org.jitsi.jicofo.auth.URL=EXT_JWT:|" "$JICOFO_SIP"
 | 
				
			||||||
sed -i "s|// anonymousdomain: 'guest.example.com'|anonymousdomain: \'guest.$DOMAIN\'|" "$MEET_CONF"
 | 
					sed -i "s|// anonymousdomain: 'guest.example.com'|anonymousdomain: \'guest.$DOMAIN\'|" "$MEET_CONF"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#Enable jibri recording
 | 
					# Enable jibri recording
 | 
				
			||||||
cat  << REC-JIBRI >> "$PROSODY_FILE"
 | 
					cat  << REC-JIBRI >> "$PROSODY_FILE"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
VirtualHost "recorder.$DOMAIN"
 | 
					VirtualHost "recorder.$DOMAIN"
 | 
				
			||||||
| 
						 | 
					@ -81,16 +76,12 @@ VirtualHost "recorder.$DOMAIN"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
REC-JIBRI
 | 
					REC-JIBRI
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#Setup guests and lobby
 | 
					# Setup guests and lobby
 | 
				
			||||||
cat << P_SR >> "$PROSODY_FILE"
 | 
					cat << P_SR >> "$PROSODY_FILE"
 | 
				
			||||||
-- #Change back lobby - https://community.jitsi.org/t/64769/136
 | 
					 | 
				
			||||||
VirtualHost "guest.$DOMAIN"
 | 
					VirtualHost "guest.$DOMAIN"
 | 
				
			||||||
    authentication = "token"
 | 
					    authentication = "jitsi-anonymous"
 | 
				
			||||||
    allow_empty_token = true
 | 
					 | 
				
			||||||
    c2s_require_encryption = false
 | 
					    c2s_require_encryption = false
 | 
				
			||||||
    speakerstats_component = "speakerstats.$DOMAIN"
 | 
					    speakerstats_component = "speakerstats.$DOMAIN"
 | 
				
			||||||
    app_id="$APP_ID";
 | 
					 | 
				
			||||||
    app_secret="$SECRET_APP";
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    modules_enabled = {
 | 
					    modules_enabled = {
 | 
				
			||||||
      "speakerstats";
 | 
					      "speakerstats";
 | 
				
			||||||
| 
						 | 
					@ -102,14 +93,15 @@ echo -e "\nUse the following for your App (e.g. Rocket.Chat):\n"
 | 
				
			||||||
echo -e "\nAPP_ID: $APP_ID" && \
 | 
					echo -e "\nAPP_ID: $APP_ID" && \
 | 
				
			||||||
echo -e "SECRET_APP: $SECRET_APP\n"
 | 
					echo -e "SECRET_APP: $SECRET_APP\n"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
echo -e "You can test JWT authentication with the following token:\n"
 | 
					echo -e "You can test JWT authentication with the following token for the next hour:\n"
 | 
				
			||||||
pyjwt3 --key="$SECRET_APP" \
 | 
					pyjwt3 --key="$SECRET_APP" \
 | 
				
			||||||
    encode \
 | 
					    encode \
 | 
				
			||||||
 | 
					    --alg HS256 \
 | 
				
			||||||
    group="Rocket.Chat" \
 | 
					    group="Rocket.Chat" \
 | 
				
			||||||
    aud="$APP_ID" \
 | 
					    aud="$APP_ID" \
 | 
				
			||||||
    iss="$APP_ID" \
 | 
					    iss="$APP_ID" \
 | 
				
			||||||
    sub="$DOMAIN" \
 | 
					    sub="$DOMAIN" \
 | 
				
			||||||
    room="*" \
 | 
					    room="*" \
 | 
				
			||||||
    algorithm="HS256"
 | 
					    exp="$(($(date +%s)+3600))"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
read -n 1 -s -r -p $'\n'"Press any key to continue..."$'\n'
 | 
					read -n 1 -s -r -p $'\n'"Press any key to continue..."$'\n'
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue