<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:12pt"><div>Sorry Bogdan, my snippet was a bit wrong there, I put that challenge and exit in later on just to get it to work temporarily, everything after that was actually commented out.<br><br>Here is the right code with your suggested var lines added:<br><br> if (!www_authorize("", "subscriber"))<br> {<br> $var(reg) = $retcode;<br> if ($var(reg) < 0) <br> {<br> xlog("L_INFO","$var(reg)");<br> switch ($retcode) <br>
{<br> case -5:<br> xlog("L_INFO","Error");<br> break;<br> case -4:<br> xlog("L_INFO","Please send new Register with auth info");<br> www_challenge("", "0");<br> exit;<br> case -2:<br>
xlog("L_INFO","Wrong password");<br> break;<br> case -1:<br> xlog("L_INFO","User doesnt exist");<br> break;<br> default:<br> xlog("L_INFO","Default");<br> }<br> sl_send_reply("403","Forbidden");<br> exit;<br>
}<br> }<br><br>And this is what I see in logs:<br><br>Jul 7 07:19:11 rambo /usr/sbin/opensips[20498]: DBG:auth:pre_auth: credentials with given realm not found<br>Jul 7 07:19:11 rambo /usr/sbin/opensips[20498]: DBG:core:comp_scriptvar: int 26 : -4 / 0<br>Jul 7 07:19:11 rambo /usr/sbin/opensips[20498]: -4<br>Jul 7 07:19:11 rambo /usr/sbin/opensips[20498]: DBG:core:do_action: switch: running default statement<br>Jul 7 07:19:11 rambo /usr/sbin/opensips[20498]: Default<br><br>So I guess -4 is being returned but it is still using default for some reason..?<br><br>Thanks again Bogdan.<br><br>Regards,<br>Bruce<br></div><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><br><br><br><br><br><br><div style="font-family: arial,helvetica,sans-serif; font-size: 13px;"><font size="2" face="Tahoma"><hr size="1"><b><span
style="font-weight: bold;">From:</span></b> Bogdan-Andrei Iancu <bogdan@voice-system.ro><br><b><span style="font-weight: bold;">To:</span></b> OpenSIPS users mailling list <users@lists.opensips.org><br><b><span style="font-weight: bold;">Sent:</span></b> Tue, 6 July, 2010 22:40:45<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [OpenSIPS-Users] www_authorize return codes<br></font><br>The script is a bit buggy....<br><br>just before the "Switch" you have an "exit;", so the switch will never <br>be executed..... Try:<br><br> www_authorize("", "subscriber");<br> $var(x) = $retcode;<br> if ($var(x) < 0) {<br> switch ($retcode) {<br> case -5:<br> xlog("L_INFO","Error");<br>
break;<br> case -4:<br> xlog("L_INFO","Please send new Register with auth <br>info");<br> www_challenge("", "0");<br> exit;<br> case -2:<br> xlog("L_INFO","Wrong password");<br> break;<br> case -1:<br> xlog("L_INFO","User doesnt exist");<br> break;<br>
default:<br> xlog("L_INFO","Default");<br> }<br> sl_send_reply("403","Forbidden");<br> exit;<br> }<br><br>Regards,<br>Bogdan<br><br>Bruce Borrett wrote:<br>> Hi Bogdan<br>><br>> Here is the www_auth block from my config:<br>><br>> if (!www_authorize("", "subscriber"))<br>> {<br>> www_challenge("", "0");<br>> exit;<br>> switch ($retcode)<br>> {<br>> case -5:<br>>
xlog("L_INFO","Error");<br>> break;<br>> case -4:<br>> xlog("L_INFO","Please send new Register with auth <br>> info");<br>> www_challenge("", "0");<br>> exit;<br>> case -2:<br>> xlog("L_INFO","Wrong password");<br>> break;<br>> case -1:<br>>
xlog("L_INFO","User doesnt exist");<br>> break;<br>> default:<br>> xlog("L_INFO","Default");<br>> }<br>> }<br>><br>> Thanks,<br>> Bruce<br>><br>> ------------------------------------------------------------------------<br>> *From:* Bogdan-Andrei Iancu <<a ymailto="mailto:bogdan@voice-system.ro" href="mailto:bogdan@voice-system.ro">bogdan@voice-system.ro</a>><br>> *To:* OpenSIPS users mailling list <<a ymailto="mailto:users@lists.opensips.org" href="mailto:users@lists.opensips.org">users@lists.opensips.org</a>><br>> *Sent:* Tue, 6 July, 2010 20:13:03<br>> *Subject:* Re: [OpenSIPS-Users] www_authorize return
codes<br>><br>> Hi Bruce,<br>><br>> no, they did not change. Post your switch to see if correct or not.<br>><br>> Regards,<br>> Bogdan<br>><br>> Bruce Borrett wrote:<br>> > Hi all<br>> ><br>> > I cant get switch to catch any return codes for www_authorize. The<br>> > default catch works, but -5 through -1 as stated in the docs do not<br>> > work, I also tried positive 1 through 5... Have these codes changed?<br>> ><br>> > Thanks in advance..<br>> ><br>> > Regards,<br>> > Bruce<br>> ><br>> > ------------------------------------------------------------------------<br>> ><br>> > _______________________________________________<br>> > Users mailing list<br>> > <a ymailto="mailto:Users@lists.opensips.org" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a> <mailto:<a ymailto="mailto:Users@lists.opensips.org"
href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a>><br>> > <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>> > <br>><br>><br>> -- <br>> Bogdan-Andrei Iancu<br>> OpenSIPS Bootcamp<br>> 20 - 24 September 2010, Frankfurt, Germany<br>> www.voice-system.ro<br>><br>><br>> _______________________________________________<br>> Users mailing list<br>> <a ymailto="mailto:Users@lists.opensips.org" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a> <mailto:<a ymailto="mailto:Users@lists.opensips.org" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a>><br>> <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>><br>>
------------------------------------------------------------------------<br>><br>> _______________________________________________<br>> Users mailing list<br>> <a ymailto="mailto:Users@lists.opensips.org" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a><br>> <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>> <br><br><br>-- <br>Bogdan-Andrei Iancu<br>OpenSIPS Bootcamp<br>20 - 24 September 2010, Frankfurt, Germany<br>www.voice-system.ro<br><br><br>_______________________________________________<br>Users mailing list<br><a ymailto="mailto:Users@lists.opensips.org" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a><br><a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br></div></div>
</div><br>
</body></html>