Repository navigation
xmpp_stream_in: Offer SASL2 to a client stream that names no user - #121
Merged
Merged
Conversation
SASL2 was offered only when the stream header names a user in its 'from', since the mechanisms are picked for that user's stored credentials. A client that logs in anonymously has no user to name, so it could not use SASL2 nor bind inline with Bind2, and had to fall back to SASL and resource binding. XEP-0388 says that without 'from' the server SHOULD offer only the mechanisms it can provide independently of the JID. Offer SASL2 to such a stream with ANONYMOUS only, when the callback module lists it, and no FAST mechanisms. As the user comes from the mechanism, there is no user named in the header to compare it with. When ANONYMOUS isn't available the stream gets no SASL2 feature, as before. Streams that name a user are not changed.
…is named A client stream whose header names no user was offered SASL2 with ANONYMOUS alone, while SASL offered it the password mechanisms too. A client that prefers SASL2, as Gajim does, then saw no mechanism for its password and gave up, where before it fell back to SASL and logged in. Offer such a stream the mechanisms of SASL, and look up the password of the user the mechanism names, as SASL does, rather than that of a user named in the header. Channel binding is as in SASL. FAST mechanisms stay out, since FAST needs a user named in the header.
Member
|
Look ok, i was sure when i was making initial implementation xep did mention that it should be only offered when client sent from attribute, i must have misread this, or that was latter addition. After merge could you please update ejabberd pull counterpart making rebar.config/mix.exs pointint to xmpp commit that includes this? |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
SASL2 (XEP-0388) is offered only when the client's stream header names a user
in
from, because the mechanisms are picked for that user's storedcredentials. A client that logs in anonymously has no user to name, so it can't
use SASL2 and can't bind inline with Bind2 (XEP-0386). It has to fall back to
RFC 6120 SASL and resource binding. Naming some made-up user doesn't help:
process_sasl2_successrejects any identity other than the named user, and theanonymous identity is random.
XEP-0388 §3 (1.0.4) covers this case: "When the from attribute is absent, the
server SHOULD only offer mechanisms it can provide independently of the JID."
An earlier revision of this PR offered only ANONYMOUS there. That broke clients
that prefer SASL2 and don't send
from(Gajim): they saw SASL2 with no passwordmechanism and gave up instead of falling back to SASL. So such a stream now gets
in SASL2 the same mechanisms legacy SASL offers it, which is what the server
can provide without knowing the user in advance: legacy SASL does exactly that.
What changes, only for a client stream whose header names no user (no
from,or a
fromwith no local part):sasl2_stream_fromis set toundefinedrather than left unset, so SASL2can be offered.
sasl_mechanismscallback, the same channel-binding and downgrade handling).The password is looked up through the
get_password_funcallback for theuser the mechanism names, as legacy SASL does.
fast_mechanismscallback) are neither offered nor acceptedon such a stream.
compare it with.
<success/>carries the<authorization-identifier/>,which is the full JID when Bind2 bound a resource, as on any SASL2 success.
Streams that name a user behave as before. One small side effect: if a
send_featurescall for SASL2 produces no<authentication/>(an alreadyauthenticated stream), the stream's SASL2 marker is now dropped instead of
kept.
Tests:
rebar3 dialyzerandrebar3 eunitpass. ejabberd's CT suite was runagainst this branch through
_checkouts(see the companion ejabberd PR). Ithas new cases for anonymous SASL2 + Bind2 and for "no SASL2 when there's no
anonymous login".
The ejabberd side (hooks and tests) is processone/ejabberd#4671.