Implement pluggable SASL handlers in strophe
olemis opened this issue · comments
After reviewing strophe.js
(within the body of _connect_cb
function) I've found that vars do_sasl_digest_md5
,
do_sasl_plain
and do_sasl_anonymous
are used to select the SASL auth
mechanism that should be used .
Since it's possible to have custom auth mechanisms, IMO it would
be nice to have methods like PyXMPP's challenge
which would make
strophe more flexible & easy-to-extend . I mean , the actual code
looks like a well known anti-pattern , and it would be nice to be able
to register «auth handlers» and select the correct match considering
the value of mech
var .
IOW do something like
auth_mechs = {
'DIGEST-MD5' : handle_DIGEST_MD5,
'PLAIN' : handle_PLAIN,
'ANOMYNOUS' : handle_ANONYMOUS,
}
auth_handler = auth_mechs[mech] || handle_no_auth_mech;
something = auth_handler(...)
... in that case it would be possible to add custom auth without
patching strophe.js by executing auth_mechs['MY_METHOD'] = handle_MY_METHOD
similar to what is possible in PyXMPP by
implementing and registering ClientAuthenticator
subclasses .
please be so kind and make a pull request :)