Skip to content

Commit

Permalink
feat: Adds an option to randomize user-id used when client logins. (#501
Browse files Browse the repository at this point in the history
)

* feat: Adds an option to randomize user-id used when client logins.

Updates to latest desktop lib dependency to fix ALWAYS_TRUST_MODE_ENABLED.

* squash: Update jid random part.
  • Loading branch information
damencho authored Sep 27, 2023
1 parent b9e9572 commit 3de47d0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
4 changes: 4 additions & 0 deletions jigasi-home/sip-communicator.properties
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ org.jitsi.jigasi.xmpp.acc.USE_DEFAULT_STUN_SERVER=false
# To fix SSL/TLS required by client but not supported by server
#org.jitsi.jigasi.xmpp.acc.ALLOW_NON_SECURE=true

# Can be used in combination with jitsi-meet module mod_auth_jitsi-shared-secret
# To have jigasi use a random username on every call
#org.jitsi.jigasi.xmpp.acc.UNIQUE_USER_ID=true

# If you want to disconnect jigasi calls automatically when all web users have
# left, you can set the following property to false.
# org.jitsi.jigasi.ALLOW_ONLY_JIGASIS_IN_ROOM=true
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<properties>
<assembly.skipAssembly>true</assembly.skipAssembly>
<jitsi-desktop.version>2.14.113297e05</jitsi-desktop.version>
<jitsi-desktop.version>2.14.77b1f5e65</jitsi-desktop.version>
<jitsi-desktop.groupId>org.jitsi.desktop</jitsi-desktop.groupId>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<slf4j.version>1.7.36</slf4j.version>
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/org/jitsi/jigasi/JvbConference.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ public class JvbConference
Util.createNewThreadPool("xmpp-executor-pool")
);

/**
* Used for randomizing usernames if needed.
*/
private static final Random RANDOM = new Random();

/**
* Adds the features supported by jigasi to a specific
* <tt>OperationSetJitsiMeetTools</tt> instance.
Expand Down Expand Up @@ -1649,6 +1654,26 @@ else if ("org.jitsi.jigasi.xmpp.acc.BOSH_URL_PATTERN".equals(overridenProp))
ctx.setBoshURL(value);
}
}
else if ("org.jitsi.jigasi.xmpp.acc.USER_ID".equals(overridenProp)
&& JigasiBundleActivator.getConfigurationService().getBoolean(overridePrefix + ".UNIQUE_USER_ID", false))
{
try
{
Jid jid = JidCreate.from(value);
long random = RANDOM.nextInt();
Jid newJid = JidCreate.entityBareFrom(
Localpart.from(jid.getLocalpartOrNull() + "-" + String.format("%x", random)),
jid.getDomain());

properties.put(ProtocolProviderFactory.USER_ID, newJid.toString());
}
catch (XmppStringprepException e)
{
logger.error("Error jid in org.jitsi.jigasi.xmpp.acc.USER_ID config", e);

properties.put(ProtocolProviderFactory.USER_ID, value);
}
}
else
{
properties.put(key, value);
Expand Down

0 comments on commit 3de47d0

Please sign in to comment.