[OpenSIPS-Users] www_authorize return codes
Bogdan-Andrei Iancu
bogdan at voice-system.ro
Wed Jul 7 09:35:46 CEST 2010
Hi Bruce,
There is a small typo in the script (also the one I sent you). In the
switch statement, use $var(reg) and not $retcode (retcode will change
during the code execution).
Regards,
Bogdan
Bruce Borrett wrote:
> 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.
>
> Here is the right code with your suggested var lines added:
>
> if (!www_authorize("", "subscriber"))
> {
> $var(reg) = $retcode;
> if ($var(reg) < 0)
> {
> xlog("L_INFO","$var(reg)");
> switch ($retcode)
> {
> case -5:
> xlog("L_INFO","Error");
> break;
> case -4:
> xlog("L_INFO","Please send new Register with auth
> info");
> www_challenge("", "0");
> exit;
> case -2:
> xlog("L_INFO","Wrong password");
> break;
> case -1:
> xlog("L_INFO","User doesnt exist");
> break;
> default:
> xlog("L_INFO","Default");
> }
> sl_send_reply("403","Forbidden");
> exit;
> }
> }
>
> And this is what I see in logs:
>
> Jul 7 07:19:11 rambo /usr/sbin/opensips[20498]: DBG:auth:pre_auth:
> credentials with given realm not found
> Jul 7 07:19:11 rambo /usr/sbin/opensips[20498]:
> DBG:core:comp_scriptvar: int 26 : -4 / 0
> Jul 7 07:19:11 rambo /usr/sbin/opensips[20498]: -4
> Jul 7 07:19:11 rambo /usr/sbin/opensips[20498]: DBG:core:do_action:
> switch: running default statement
> Jul 7 07:19:11 rambo /usr/sbin/opensips[20498]: Default
>
> So I guess -4 is being returned but it is still using default for some
> reason..?
>
> Thanks again Bogdan.
>
> Regards,
> Bruce
>
>
>
>
>
>
> ------------------------------------------------------------------------
> *From:* Bogdan-Andrei Iancu <bogdan at voice-system.ro>
> *To:* OpenSIPS users mailling list <users at lists.opensips.org>
> *Sent:* Tue, 6 July, 2010 22:40:45
> *Subject:* Re: [OpenSIPS-Users] www_authorize return codes
>
> The script is a bit buggy....
>
> just before the "Switch" you have an "exit;", so the switch will never
> be executed..... Try:
>
> www_authorize("", "subscriber");
> $var(x) = $retcode;
> if ($var(x) < 0) {
> switch ($retcode) {
> case -5:
> xlog("L_INFO","Error");
> break;
> case -4:
> xlog("L_INFO","Please send new Register with auth
> info");
> www_challenge("", "0");
> exit;
> case -2:
> xlog("L_INFO","Wrong password");
> break;
> case -1:
> xlog("L_INFO","User doesnt exist");
> break;
> default:
> xlog("L_INFO","Default");
> }
> sl_send_reply("403","Forbidden");
> exit;
> }
>
> Regards,
> Bogdan
>
> Bruce Borrett wrote:
> > Hi Bogdan
> >
> > Here is the www_auth block from my config:
> >
> > if (!www_authorize("", "subscriber"))
> > {
> > www_challenge("", "0");
> > exit;
> > switch ($retcode)
> > {
> > case -5:
> > xlog("L_INFO","Error");
> > break;
> > case -4:
> > xlog("L_INFO","Please send new Register with auth
> > info");
> > www_challenge("", "0");
> > exit;
> > case -2:
> > xlog("L_INFO","Wrong password");
> > break;
> > case -1:
> > xlog("L_INFO","User doesnt exist");
> > break;
> > default:
> > xlog("L_INFO","Default");
> > }
> > }
> >
> > Thanks,
> > Bruce
> >
> > ------------------------------------------------------------------------
> > *From:* Bogdan-Andrei Iancu <bogdan at voice-system.ro
> <mailto:bogdan at voice-system.ro>>
> > *To:* OpenSIPS users mailling list <users at lists.opensips.org
> <mailto:users at lists.opensips.org>>
> > *Sent:* Tue, 6 July, 2010 20:13:03
> > *Subject:* Re: [OpenSIPS-Users] www_authorize return codes
> >
> > Hi Bruce,
> >
> > no, they did not change. Post your switch to see if correct or not.
> >
> > Regards,
> > Bogdan
> >
> > Bruce Borrett wrote:
> > > Hi all
> > >
> > > I cant get switch to catch any return codes for www_authorize. The
> > > default catch works, but -5 through -1 as stated in the docs do not
> > > work, I also tried positive 1 through 5... Have these codes changed?
> > >
> > > Thanks in advance..
> > >
> > > Regards,
> > > Bruce
> > >
> > >
> ------------------------------------------------------------------------
> > >
> > > _______________________________________________
> > > Users mailing list
> > > Users at lists.opensips.org <mailto:Users at lists.opensips.org>
> <mailto:Users at lists.opensips.org <mailto:Users at lists.opensips.org>>
> > > http://lists.opensips.org/cgi-bin/mailman/listinfo/users
> > >
> >
> >
> > --
> > Bogdan-Andrei Iancu
> > OpenSIPS Bootcamp
> > 20 - 24 September 2010, Frankfurt, Germany
> > www.voice-system.ro
> >
> >
> > _______________________________________________
> > Users mailing list
> > Users at lists.opensips.org <mailto:Users at lists.opensips.org>
> <mailto:Users at lists.opensips.org <mailto:Users at lists.opensips.org>>
> > http://lists.opensips.org/cgi-bin/mailman/listinfo/users
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Users mailing list
> > Users at lists.opensips.org <mailto:Users at lists.opensips.org>
> > http://lists.opensips.org/cgi-bin/mailman/listinfo/users
> >
>
>
> --
> Bogdan-Andrei Iancu
> OpenSIPS Bootcamp
> 20 - 24 September 2010, Frankfurt, Germany
> www.voice-system.ro
>
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org <mailto:Users at lists.opensips.org>
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
--
Bogdan-Andrei Iancu
OpenSIPS Bootcamp
20 - 24 September 2010, Frankfurt, Germany
www.voice-system.ro
More information about the Users
mailing list