User Tools

Site Tools


tutorials:auth:auth_db

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
tutorials:auth:auth_db [2014/12/09 22:47]
eschmidbauer [Installation of the Kamailio modules: auth, auth_db, usrloc]
tutorials:auth:auth_db [2014/12/09 22:55]
eschmidbauer
Line 1: Line 1:
 **Note: This document is work in progress and yet unfinished!** **Note: This document is work in progress and yet unfinished!**
 +
 +Written by Emmanuel Schmidbauer (eschmidbauer@gmail.com)
  
 This guide is designed to illustrate how to setup auth_db and usrloc to do digest authentication using a database backend. I will be using a postgresql database in this example.  This guide is designed to illustrate how to setup auth_db and usrloc to do digest authentication using a database backend. I will be using a postgresql database in this example. 
Line 10: Line 12:
 You'll probably want to setup your database and add a few users. I will briefly go over how to setup the tables using the schema provided with kamailio. You'll probably want to setup your database and add a few users. I will briefly go over how to setup the tables using the schema provided with kamailio.
  
-====== Modules: auth, auth_db, usrloc ======+====== Modules: auth, auth_db, usrloc, registrar ======
  
 <code> <code>
-loadmodule "usrloc.so" 
-loadmodule "registrar.so" 
 loadmodule "auth.so" loadmodule "auth.so"
 loadmodule "auth_db.so" loadmodule "auth_db.so"
 +loadmodule "usrloc.so"
 +loadmodule "registrar.so"
 </code> </code>
  
 +<code>
 +modparam("auth_db|usrloc", "db_url", DB_URL)
 +modparam("auth_db", "use_domain", 1)
 +modparam("auth_db", "calculate_ha1", 1)
 +modparam("usrloc", "db_mode", 3 )
 +modparam("usrloc", "desc_time_order", 1 )
 +modparam("usrloc", "nat_bflag", 1 )
 +modparam("usrloc", "timer_interval", 5 )
 +modparam("usrloc", "use_domain", 1)
 +modparam("nathelper|registrar", "received_avp", "$avp(s:rcv)")
 +</code>
  
 +<code>
 +# -------------------------  request routing logic -------------------
 +# main routing logic
  
 +route {
 +        # per request initial checks
 +        route(SANITY_CHECK);
  
 +        # CANCEL processing
 +        if (is_method("CANCEL")) {
 +                if (t_check_trans()) {
 +                        t_relay();
 +                }
 +                exit;
 +        }
  
 +        route(CHECK_SOURCE_IP);
  
 +        ##################################
 +        ### HANDLE SEQUENTIAL REQUESTS ###
 +        route(WITHINDLG);
 +
 +        ###############################
 +        ### HANDLE INITIAL REQUESTS ###
 +        t_check_trans();
 +
 +        route(REGISTER);
 +
 +        route(INVITE);
 +
 +        route(RELAY);
 +}
 +</code>
 +
 +<code>
 +route[REGISTER]
 +{
 +        if (is_method("REGISTER")) {
 +                # auth user/pass
 +                if(!www_authenticate("$fd", "user_extension")) {
 +                        www_challenge("$fd", "1");
 +                }
 +
 +                if (!save("sip_registration")) {
 +                        sl_reply_error();
 +                }
 +                exit;
 +        }
 +
 +}
 +</code>
 +
 +<code>
 +# Handle INVITE + REFER
 +route[INVITE]
 +{
 +        # record routing for dialog forming requests (in case they are routed)
 +        # remove preloaded route headers
 +        remove_hf("Route");
 +        if (is_method("INVITE|REFER")) {
 +                record_route();
 +               # auth user/pass
 +                if (!proxy_authenticate("$fd", "user_extension")) {
 +                        proxy_challenge("$fd", "1");
 +                        exit;
 +                }
 +        }
 +}
 +</code>
tutorials/auth/auth_db.txt ยท Last modified: 2014/12/09 22:55 by eschmidbauer