ejabberd - Comments for "Issue with registration of users over BOSH" https://www.ejabberd.im/forum/25450/issue-registration-users-over-bosh en Thanks, works like a charm! https://www.ejabberd.im/forum/25450/issue-registration-users-over-bosh#comment-66867 <p>Thanks, works like a charm! </p> <p>Now I have hit a further blocker and have started a new thread for that. The problem being, as it seems, BOSH is still using default authentication, whereas I have used SCRAM in other modules.</p> <p>So does BOSH support SCRAM authentication, and if it does want changes do I need to make?</p> <p>Thanks.</p> Mon, 18 Apr 2016 20:02:24 +0000 prasadv comment 66867 at https://www.ejabberd.im Right, it expects a new https://www.ejabberd.im/forum/25450/issue-registration-users-over-bosh#comment-66865 <p>Right, it expects a new argument called AuthzId, so let's accept it even if it isn't used:</p> <pre> diff --git a/ejabberd_auth_http/src/ejabberd_auth_http.erl b/ejabberd_auth_http/src/ejabberd_auth_http.erl index ba24194..85c59a1 100644 --- a/ejabberd_auth_http/src/ejabberd_auth_http.erl +++ b/ejabberd_auth_http/src/ejabberd_auth_http.erl @@ -15,8 +15,8 @@ %% External exports -export([start/1, set_password/3, - check_password/3, - check_password/5, + check_password/4, + check_password/6, try_register/3, dirty_get_registered_users/0, get_vh_registered_users/1, @@ -69,8 +69,8 @@ plain_password_required() -&gt; store_type() -&gt; ejabberd_auth_odbc:store_type(). --spec check_password(ejabberd:luser(), ejabberd:lserver(), binary()) -&gt; boolean(). -check_password(LUser, LServer, Password) -&gt; +-spec check_password(ejabberd:luser(), binary(), ejabberd:lserver(), binary()) -&gt; boolean(). +check_password(LUser, _AuthzId, LServer, Password) -&gt; case scram2:enabled(LServer) of false -&gt; case make_req(get, &lt;&lt;"check_password"&gt;&gt;, LUser, LServer, Password) of @@ -81,8 +81,8 @@ check_password(LUser, LServer, Password) -&gt; {ok, true} =:= verify_scram_password(LUser, LServer, Password) end. --spec check_password(ejabberd:luser(), ejabberd:lserver(), binary(), binary(), fun()) -&gt; boolean(). -check_password(LUser, LServer, Password, Digest, DigestGen) -&gt; +-spec check_password(ejabberd:luser(), binary(), ejabberd:lserver(), binary(), binary(), fun()) -&gt; boolean(). +check_password(LUser, _AuthzId, LServer, Password, Digest, DigestGen) -&gt; case make_req(get, &lt;&lt;"get_password"&gt;&gt;, LUser, LServer, &lt;&lt;""&gt;&gt;) of {error, _} -&gt; false; diff --git a/ejabberd_auth_http/src/scram2.erl b/ejabberd_auth_http/src/scram2.erl index 065cef0..fda4771 100644 --- a/ejabberd_auth_http/src/scram2.erl +++ b/ejabberd_auth_http/src/scram2.erl @@ -179,8 +179,15 @@ scram_to_tuple(Scram) -&gt; -spec check_digest(scram(), binary(), fun(), binary()) -&gt; boolean(). check_digest(#scram{storedkey = StoredKey}, Digest, DigestGen, Password) -&gt; - Passwd = base64:decode(StoredKey), - ejabberd_auth:check_digest(Digest, DigestGen, Password, Passwd). + Passwd = jlib:decode_base64(StoredKey), + DigRes = if Digest /= &lt;&lt;""&gt;&gt; -&gt; + Digest == DigestGen(Passwd); + true -&gt; false + end, + if DigRes -&gt; true; + true -&gt; (Passwd == Password) and (Password /= &lt;&lt;""&gt;&gt;) + end. + -ifdef(no_crypto_hmac). crypto_hmac(sha, Key, Data) -&gt; </pre><p> Well, remember to compile and copy the beam file to the "proper place".</p> Mon, 18 Apr 2016 16:41:55 +0000 badlop comment 66865 at https://www.ejabberd.im Hi Badlop, Thank you for this https://www.ejabberd.im/forum/25450/issue-registration-users-over-bosh#comment-66862 <p>Hi Badlop,</p> <p>Thank you for this patch, now further it appears that the API methods check_password/3 and check_password/5 have been changed to check_password/4 and check_password/6 respectively in auth modules, so encountering below error:</p> <p>gen_fsm &lt;0.580.0&gt; in state wait_for_sasl_response terminated with reason: call to undefined function ejabberd_auth_http:check_password(&lt;&lt;"user"&gt;&gt;, &lt;&lt;"password"&gt;&gt;, &lt;&lt;"server"&gt;&gt;, &lt;&lt;&gt;&gt;, &lt;&lt;"8021545d530d14a388d17f094d195a7b"&gt;&gt;, #Fun)</p> <p>If you have a patch for this as well it would be helpful.<br /> Else please help me understand the new argument "AuthzId".</p> <p>UPDATE: The changes made in the ejabberd_auth_http file to implement check_password methods with 4 and 6 arguments are not reflected even after successful compilation of this module. Why could this be? </p> <p>Thanks.</p> Fri, 15 Apr 2016 22:09:23 +0000 prasadv comment 66862 at https://www.ejabberd.im Try with this patch: --- https://www.ejabberd.im/forum/25450/issue-registration-users-over-bosh#comment-66858 <p>Try with this patch:</p> <pre> --- a/ejabberd_auth_http/src/scram2.erl +++ b/ejabberd_auth_http/src/scram2.erl @@ -179,8 +179,15 @@ scram_to_tuple(Scram) -&gt; -spec check_digest(scram(), binary(), fun(), binary()) -&gt; boolean(). check_digest(#scram{storedkey = StoredKey}, Digest, DigestGen, Password) -&gt; - Passwd = base64:decode(StoredKey), - ejabberd_auth:check_digest(Digest, DigestGen, Password, Passwd). + Passwd = jlib:decode_base64(StoredKey), + DigRes = if Digest /= &lt;&lt;""&gt;&gt; -&gt; + Digest == DigestGen(Passwd); + true -&gt; false + end, + if DigRes -&gt; true; + true -&gt; (Passwd == Password) and (Password /= &lt;&lt;""&gt;&gt;) + end. + -ifdef(no_crypto_hmac). crypto_hmac(sha, Key, Data) -&gt; </pre> Wed, 13 Apr 2016 13:29:25 +0000 badlop comment 66858 at https://www.ejabberd.im