-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
XEP-0198 SASL2 / Bind2 integration work #3417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
dwd
wants to merge
55
commits into
igniterealtime:main
Choose a base branch
from
dwd:sm-s2-b2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
55 commits
Select commit
Hold shift + click to select a range
d1023f4
First crack at SASL2 (XEP-0388)
b63bbdf
Bit more SASL2 WIP
dwd 8ba37af
SASL2 WIP - compiling/passing existing tests
dwd a7d75ab
Add basic tests
dwd 58144a0
Features tests
dwd bcb12be
Auth tests (failing)
dwd 492503b
Auth tests (passing)
dwd edceb2d
Add tests for additional data, initial responses, and multistep
dwd fb88fec
Add back null vs empty processing
dwd 135a6b7
Typoish in comment
dwd 15b5279
Disable SASL2 by default, support it on S2S
dwd 17e99a9
Base UserAgentInfo class
dwd 51b6e79
UserAgentInfo tests
dwd 857f9a5
Wire in UserAgentInfo extraction and storage
dwd 9eebbe3
Tests for wiring in UserAgentInfo extraction and storage
dwd 906a979
Move the tests
dwd 891ec87
Linty winty
dwd cb8ba05
Fix feature name
dwd d16c803
SASL2 working, Bind2 ignored.
dwd e40f725
Address copilot review points
dwd 97a14f9
Rework addSASLMechanisms to getSASLMechanisms and add more javadoc
dwd ada6969
Guus comments
dwd 247d93f
Coderabbit comments
dwd fe34e73
Post-rebase deconficting
dwd 383a716
Conflict: Don't add mechanisms twice!
dwd b044354
Potential fix for pull request finding
dwd 620bc04
Copilot Things
dwd b4a969b
Add DOAP support for XEP-0388
dwd b57da8f
Refactor features a bit, ensure non-PLUS are added
dwd 03bfa8d
Move channel binding filter into getAvailableMechanismsForClientSession
dwd d173088
Introduce requiresChannelBinding() helper to replace endsWith("-PLUS"…
dwd 5b46cb7
Fix SASLAuthenticationTest: mock Connection for channel binding
dwd b6d4ddb
Add SASL2 Conversations test
Fishbowler f639cda
Add openfire logs as artifacts for debugging
Fishbowler df8d8bc
Enable SASL2 in the test-specific Openfire config
Fishbowler ed098be
Expand SASL2 test to include Channel Binding
Fishbowler 5a3407c
Initial bind2 request
dwd d1ee007
Wire in Bind2 (no tests)
dwd 9a0248d
Hide client id, refactor
dwd f7c6293
Add tests. Make tests pass.
dwd b07a85d
Add SASL2/Bind2 test
dwd 920b135
Fix SASL2/Bind2 test
dwd 9c01433
Advertise Bind2
dwd eca1e77
Add bound element
dwd 0dd7fa8
Bind2 subfeature support
dwd 26e492d
Bind2 handler tests
dwd 25ecb36
Make SCRAM generic
dwd a5bf142
SASL2 working, Bind2 ignored.
dwd 2930ca4
Bind2 working, including carbons
dwd a97635b
CSI Bind2 support
dwd fa49f18
Fix tests
dwd 34deb85
Fix carbons bind element name, add more tests
dwd 05e366d
Fix processFeatureRequests call and update Bind2 test for async Sessi…
dwd 3d8b5f6
Integrate XEP-0198 Stream Management with SASL2 (XEP-0388) and Bind2 …
dwd 96766cd
Defer SM stanza redelivery until after stream features on SASL2 resume
dwd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
xmppserver/src/main/java/org/jivesoftware/openfire/csi/CsiModule.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| package org.jivesoftware.openfire.csi; | ||
|
|
||
| import org.dom4j.Element; | ||
| import org.jivesoftware.openfire.container.BasicModule; | ||
| import org.jivesoftware.openfire.net.Bind2InlineHandler; | ||
| import org.jivesoftware.openfire.net.Bind2Request; | ||
| import org.jivesoftware.openfire.session.LocalClientSession; | ||
|
|
||
| public class CsiModule extends BasicModule { | ||
| static class Bind2CSIHandler implements Bind2InlineHandler { | ||
|
|
||
| @Override | ||
| public String getNamespace() { | ||
| return CsiManager.NAMESPACE; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean handleElement(LocalClientSession session, Element bound, Element element) { | ||
| if (element.getName().equals("active")) { | ||
| session.getCsiManager().activate(); | ||
| } | ||
| return true; | ||
| } | ||
| } | ||
| private static final Bind2CSIHandler handler = new Bind2CSIHandler(); | ||
| /** | ||
| * <p>Create a basic module with the given name.</p> | ||
| * | ||
| * @param moduleName The name for the module or null to use the default | ||
| */ | ||
| public CsiModule(String moduleName) { | ||
| super(moduleName); | ||
| } | ||
|
|
||
| @Override | ||
| public void start() throws IllegalStateException { | ||
| super.start(); | ||
| Bind2Request.registerElementHandler(handler); | ||
| } | ||
|
|
||
| @Override | ||
| public void stop() { | ||
| Bind2Request.unregisterElementHandler(handler.getNamespace()); | ||
| super.stop(); | ||
| } | ||
| } |
18 changes: 18 additions & 0 deletions
18
xmppserver/src/main/java/org/jivesoftware/openfire/handler/Bind2CarbonsHandler.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package org.jivesoftware.openfire.handler; | ||
|
|
||
| import org.dom4j.Element; | ||
| import org.jivesoftware.openfire.net.Bind2InlineHandler; | ||
| import org.jivesoftware.openfire.session.LocalClientSession; | ||
|
|
||
| public class Bind2CarbonsHandler implements Bind2InlineHandler { | ||
| @Override | ||
| public String getNamespace() { | ||
| return "urn:xmpp:carbons:2"; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean handleElement(LocalClientSession session, Element bound, Element element) { | ||
| session.setMessageCarbonsEnabled(element.getName().equals("enable")); | ||
| return true; | ||
| } | ||
| } | ||
79 changes: 79 additions & 0 deletions
79
xmppserver/src/main/java/org/jivesoftware/openfire/handler/Bind2StreamManagementHandler.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| /* | ||
| * Copyright (C) 2024-2026 Ignite Realtime Foundation. All rights reserved. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.jivesoftware.openfire.handler; | ||
|
|
||
| import org.dom4j.Element; | ||
| import org.jivesoftware.openfire.net.Bind2InlineHandler; | ||
| import org.jivesoftware.openfire.session.LocalClientSession; | ||
| import org.jivesoftware.openfire.streammanagement.StreamManager; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| /** | ||
| * A {@link Bind2InlineHandler} that processes XEP-0198 Stream Management {@code <enable/>} elements | ||
| * sent inline within a SASL2 Bind2 request (XEP-0388 / XEP-0386). | ||
| * | ||
| * <p>When a client includes an {@code <enable/>} element in the {@code urn:xmpp:sm:3} namespace | ||
| * inside its Bind2 {@code <bind/>} element, this handler delegates to the session's | ||
| * {@link StreamManager} to enable stream management (and optionally resumption) immediately | ||
| * after resource binding, without requiring a separate round-trip.</p> | ||
| * | ||
| * <p>The {@code <enabled/>} response from the server is added as a child of the {@code <bound/>} | ||
| * element in the SASL2 {@code <success/>} stanza.</p> | ||
| * | ||
| * @see <a href="https://xmpp.org/extensions/xep-0198.html">XEP-0198: Stream Management</a> | ||
| * @see <a href="https://xmpp.org/extensions/xep-0388.html">XEP-0388: Extensible SASL Profile</a> | ||
| */ | ||
| public class Bind2StreamManagementHandler implements Bind2InlineHandler { | ||
|
|
||
| private static final Logger Log = LoggerFactory.getLogger(Bind2StreamManagementHandler.class); | ||
|
|
||
| @Override | ||
| public String getNamespace() { | ||
| return StreamManager.NAMESPACE_V3; | ||
| } | ||
|
|
||
| /** | ||
| * Handles an {@code <enable/>} element from a Bind2 inline feature request by enabling | ||
| * XEP-0198 stream management on the session. The {@code <enabled/>} response element | ||
| * produced by the stream manager is added as a child of the provided {@code bound} element. | ||
| * | ||
| * <p>Only {@code <enable/>} elements are processed; any other element name is ignored.</p> | ||
| * | ||
| * @param session the client session on which stream management should be enabled | ||
| * @param bound the {@code <bound/>} element to which the {@code <enabled/>} response is added | ||
| * @param element the inline element from the Bind2 request (expected to be {@code <enable/>}) | ||
| * @return {@code true} if the element was an {@code <enable/>} and was processed; | ||
| * {@code false} if the element was not an {@code <enable/>} or processing failed | ||
| */ | ||
| @Override | ||
| public boolean handleElement(LocalClientSession session, Element bound, Element element) { | ||
| if (!"enable".equals(element.getName())) { | ||
| Log.debug("Bind2StreamManagementHandler received unexpected element '{}'; ignoring.", element.getName()); | ||
| return false; | ||
| } | ||
| Log.debug("Processing inline SM <enable/> for session {}", session.getAddress()); | ||
| final String namespace = element.getNamespaceURI(); | ||
| final String resumeAttr = element.attributeValue("resume"); | ||
| final boolean resume = "true".equalsIgnoreCase(resumeAttr) || "1".equals(resumeAttr) || "yes".equalsIgnoreCase(resumeAttr); | ||
| final Element enabled = session.getStreamManager().enableAndBuildElement(namespace, resume); | ||
| if (enabled != null) { | ||
| bound.add(enabled); | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Validate element name instead of treating anything non-"enable" as "disable".
Unlike
IQMessageCarbonsHandler.handleIQ, which rejects unrecognized element names withbad_request, this inline handler silently maps any element other than<enable/>to "disable" and always reports success. Malformed/unexpected client input goes unnoticed.🛡️ Proposed fix
public boolean handleElement(LocalClientSession session, Element bound, Element element) { - session.setMessageCarbonsEnabled(element.getName().equals("enable")); - return true; + final String name = element.getName(); + if (!"enable".equals(name) && !"disable".equals(name)) { + return false; + } + session.setMessageCarbonsEnabled("enable".equals(name)); + return true; }📝 Committable suggestion
🤖 Prompt for AI Agents