I'm forgetting about something, the userpassword field is a plain text password.<br><br>Regards,<br><br><div class="gmail_quote">2010/7/13 Gabriel Bermudez <span dir="ltr"><<a href="mailto:elgabo81@gmail.com">elgabo81@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Hi,<br><br>I need to authenticate and register users that are stored on the opensips db AND a different database. For that I have the following code<br>
<br> if (is_method("REGISTER") && $fu=~"^sip:[0-9]{10}@")<br>
{<br> # authenticate the REGISTER based on a different DB<br> xlog("getting valid credentials for calling card $fu");<br> avp_db_query("select userpass from anothertable where username='$au'", "$avp(s:password)", "1");<br>
$var(username)=$au; <b># line 392</b><br> xlog("credentials for user $var(username) : $avp(s:password)");<br> if(!pv_www_authorize(""))<br> {<br> www_challenge("", "0");<br>
xlog("registration from $fu has been challenged");<br> exit;<br> }<br> xlog("$fu authorized!!!");<br> if (!db_check_to())<br> {<br>
sl_send_reply("403","Forbidden auth ID");<br> exit;<br> }<br><br> if (!save("location"))<br> sl_reply_error();<br><br> xlog("location saved for $fu");<br>
exit;<br> }<br> if (is_method("REGISTER") && $fu=~"^sip:[0-9]{9}@")<br> {<br> # authenticate the REGISTER requests (uncomment to enable auth)<br> if (!www_authorize("", "subscriber"))<br>
{<br> www_challenge("", "0");<br> xlog("registration from $fu has been challenged");<br> exit;<br> }<br> <br> if (!db_check_to()) <br>
{<br> sl_send_reply("403","Forbidden auth ID");<br> exit;<br> }<br><br> if (!save("location"))<br> sl_reply_error();<br><br> xlog("location saved for $fu");<br>
exit;<br> }<br><br>if the username part of the From header has 10 digits the script will try to authenticate against the other DB, but it won't go further than the pv_www_authorize line because on the logs I get the following.<br>
<br>Jul 13 21:28:00 opensips /usr/sbin/opensips[3139]: getting valid credentials for user sip:9999999999@xx.xx.xx.xx<br>Jul 13 21:28:00 opensips /usr/sbin/opensips[3139]: ERROR:core:do_assign: no value in right expression<br>
Jul 13 21:28:00 opensips /usr/sbin/opensips[3139]: ERROR:core:do_assign: error at line: 397<br>Jul 13 21:28:00 opensips /usr/sbin/opensips[3139]: credentials for user 0 : <null><br>Jul 13 21:28:01 opensips /usr/sbin/opensips[3141]: getting valid credentials for user sip:9999999999@xx.xx.xx.xx<br>
Jul 13 21:28:01 opensips /usr/sbin/opensips[3141]: credentials for user 9999999999 : 9999999999<br><br>I don't know if I'm doing something really wrong or maybe the ERROR message has something to do with this auth failure. Please can someone clarify this issue.<br>
Thanks,<br><br><br>Kind regards,<br><br>
</blockquote></div><br>