[Kamailio-Users] kamailio as registrar server

Rajesh Rajesh.sreedharan at siptech.com
Tue Oct 6 06:56:46 CEST 2009


Dear All,
                I would like my kamailio server to act (only) as a 
Registrar  server. I  have configured my kamilio for performing 
authentication successfully, but this time i find that authentication is 
not being done.Your views on my cfg is greatly appreciated.

# ------------------ module loading ----------------------------------
debug=3
log_stderror=yes
mpath="/usr/local/lib/kamailio/modules/"

loadmodule "db_mysql.so"
loadmodule "mi_fifo.so"
loadmodule "sl.so"
loadmodule "pv.so"
loadmodule "usrloc.so"
loadmodule "registrar.so"
loadmodule "textops.so"
loadmodule "uri_db.so"

loadmodule "auth.so"
loadmodule "auth_db.so"

port=5060
# ----------------- setting module-specific parameters ---------------


# ----- mi_fifo params -----
modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")


# ----- auth_db params -----
/* uncomment the following lines if you want to enable the DB based
   authentication */
modparam("auth_db", "calculate_ha1", yes)
modparam("auth_db", "password_column", "password")
modparam("auth_db", "db_url","mysql://openser:openserrw@localhost/openser")
modparam("auth_db", "load_credentials", "")

# -- usrloc params --
 
modparam("usrloc", "db_url", 
"mysql://openser:openserrw@192.168.64.75/openser")
 

modparam("usrloc", "db_mode", 3)
 
# -------------------------  request routing logic -------------------
 
# main routing logic
 
route{
 
       # initial sanity checks -- too long messages
       if (msg:len >=  2048 ) {
               sl_send_reply("513", "Message too big");
               exit;
       };
 
       if (!uri==myself) {
               sl_send_reply("400", "Bad destination, only register 
messages destined for this server are accepted");
               exit;
       };
 
       # the only valid message for the registrar is the register message
       # other messages are answered with an error message
       if (uri==myself) {

               if (method=="REGISTER") {

                       sl_send_reply("100", "Trying");

                       if(!save("location")) {
                               sl_reply_error();
                       };
                       exit;
               } else {
                       sl_send_reply("403", "Forbidden");
                       exit;
               };
       };

# Authentication route


    if (is_method("REGISTER"))
    {
        # authenticate the REGISTER requests (uncomment to enable auth)
        if (!www_authorize("192.168.64.75", "subscriber"))
        {
            www_challenge("192.168.64.75", "0");
            exit;
        }
            ###the following  lines are uncommented
        if ($au!=$tU)
        {
            sl_send_reply("403","Forbidden auth ID");
            exit;
    }
    }
     else
         {
        # authenticate if from local subscriber (uncomment to enable auth)
        if (from_uri==myself)
        {
              if (!proxy_authorize("", "subscriber"))
             {
                 proxy_challenge("", "0");
                exit;
            }
            if (is_method("PUBLISH"))
            {
            if ($au!=$tU) {
                    sl_send_reply("403","Forbidden auth ID");
                    exit;
                }
             } else {
                if ($au!=$fU) {
                    sl_send_reply("403","Forbidden auth ID");
                    exit;
                }
            }
    
              consume_credentials();
            # caller authenticated
        }
    }
    return;
}



-- 
Regards,
Rajesh  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20091006/99cdfceb/attachment.htm>


More information about the sr-users mailing list