[Serusers] check user if authenticated

Rafael J. Risco G.V. rafael.risco at gmail.com
Tue May 10 17:08:32 CEST 2005


Hi 
you can use check_to function from uri module that Check To username against 
URI table or digest credentials, see my example:
  if (method == "REGISTER") {
 
if (!www_authorize("mydomain.com.pe <http://mydomain.com.pe>", 
"subscriber")) {
log(1," ----- Fails to Register \n");
www_challenge("mydomain.com.pe <http://mydomain.com.pe>", "0");
break;
};

# only registered users are allowed 
if (!check_to()) {
log(1, "LOG: Hijack!!!--> unregistered user registration attempt\n");
sl_send_reply("403", "hijack attempt!!!! Only registered users are 
allowed");
break;
};
log(1," Registered!!! \n");
if (!save("location")) {
sl_reply_error();
};
break;
};

if ((method == "INVITE" || method== "CANCEL" || method== "ACK")) {

log(1, "ANALYZING INVITE||CANCEL REQUESTs\n");
if (!proxy_authorize("mydomain.com.pe <http://mydomain.com.pe>", 
"subscriber")) {
proxy_challenge("mydomain.com.pe <http://mydomain.com.pe>", "1");
break;
} else {
if (method == "INVITE" && !check_from()) {
sl_send_reply("403", "Only registered users are allowed"); 
break;
};
};


/* *********** Dial out to Local and PSTN logic ********* */ 

if(uri=~"^sip:001[0-9][0-9][1-9]*@(mydomain\.com\.pe)"){
rewritehostport("IP_Gateway:5060");
log(1,"digit expression match - pstn 001\n");
if(!t_relay()){
sl_reply_error();
};
break;
};
.
.
.
.

hope it helps, 

rafael

   
 On 5/10/05, Edgardo O. Gonzales II <edgardo.g at pacific.net.ph> wrote: 
> 
> 
> Hi!
> 
> How will I check if user is authenticated or not before I permit him to
> make a call.
> 
> thanks,
> ed
> 
> _______________________________________________
> Serusers mailing list
> serusers at lists.iptel.org
> http://lists.iptel.org/mailman/listinfo/serusers
> 



-- 

rrgv
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20050510/bc0e5ec0/attachment.htm>


More information about the sr-users mailing list