Repository navigation
Add anonymous_username option for SASL ANONYMOUS usernames - #120
Open
annelinlol wants to merge 1 commit into
Open
annelinlol wants to merge 1 commit into
annelinlol wants to merge 1 commit into
Conversation
The username assigned by SASL ANONYMOUS is a random number followed by a
unique integer, so it can't be told apart from a registered account
with a numeric name. The new option, set with xmpp:set_config/1:
{anonymous_username, {Prefix, Hex}}
makes the username Prefix followed by Hex random lowercase hex
characters (crypto:strong_rand_bytes/1), for example
guest-7fa598d93c1e04b2 for {<<"guest-">>, 16}. The default, undefined,
keeps the current format. xmpp:get_config/0 reports the option, so
callers can tell whether the library supports it.
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.
SASL ANONYMOUS currently assigns a username made of a random number followed by a unique integer (digits only). Such a name can't be told apart from a registered account with a numeric username, so an ACL can only match anonymous users by the shape of the digits, and a registered account with a long enough number can look like one.
This adds an optional setting, passed through
xmpp:set_config/1likefqdn:With it set,
xmpp_sasl_anonymousassignsPrefixfollowed byHexrandom lowercase hex characters (fromcrypto:strong_rand_bytes/1), for exampleguest-7fa598d93c1e04b2.xmpp_config:anonymous_username/1returns the setting,xmpp:get_config/0reports it.badarg, like the other options.xmpp_sasl_anonymous(run byrebar3 eunit).Compatibility: the default is
undefined, which keeps the current username format unchanged. Sinceget_config/0includes the key, a caller can check whether the library supports the option before setting it.The ejabberd side (a top-level
anonymous_usernameoption) is in processone/ejabberd#4670.