OpenSIPS and REDIS

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

OpenSIPS and REDIS

Michele Pinassi
Hi all,

i'm trying to setup a REDIS cache to share register data with my two
OpenSIPS server, to have some redundancy.

On opensips.cfg:

#### AUTHentication modules
loadmodule "auth.so"
modparam("auth", "username_spec", "$var(username)")
modparam("auth", "password_spec", "$avp(password)")
modparam("auth", "disable_nonce_check", 1)

loadmodule "auth_db.so"
modparam("auth_db", "calculate_ha1", 1)
modparam("auth_db", "password_column", "password")
modparam("auth_db", "load_credentials", "$avp(password)=password")

[...]

#### Redis module
loadmodule "cachedb_redis.so"
modparam("cachedb_redis", "cachedb_url", "redis:voip://192.168.1.1:6379/")

[...]

### REGISTER
        if (is_method("REGISTER")) {
            # Check for cache...
           if(cache_fetch("redis:voip","passwd_$tU",$avp(password))) {
               $var(username) = $tU;
               $var(rc) = pv_www_authorize("");
           } else {
               # or authenticate the REGISTER requests...
                $var(rc) = www_authorize("","subscriber");
           }

            switch($var(rc)) {
                case 1 :
                   xlog("L_INFO", "Registration SUCCESS $fu\n");
                    # Save credentials to REDIS cache
                   
cache_store("redis:voip","passwd_$tU","$avp(password)",128000);
                    break;
                case -1:
                    xlog("L_ERR","Auth error for $fU@$fd from $si:
INVALID USER");
                    break;
                case -2:
                    xlog("L_ERR","Auth error for $fU@$fd from $si:
INVALID PASSWORD");
                    break;
                case -3: # Stale nonce - This is not an error, so don't
print anything
                    break;
                case -4:
                    www_challenge("", "0");
                    break;
                default:
                    xlog("L_ERR","Auth error for $fU@$fd from $si cause
$var(rc)");
            }

but i got an INVALID PASSWORD for all account stored in REDIS cache.
What's wrong ?

Thanks, Michele


--
Michele Pinassi
Responsabile Telefonia di Ateneo
Servizio Reti, Sistemi e Sicurezza Informatica - Università degli Studi di Siena
tel: 0577.(23)5000 - [hidden email]

Per trovare una soluzione rapida ai tuoi problemi tecnici consulta le FAQ di Ateneo, http://www.faq.unisi.it 



_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users

signature.asc (188 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: OpenSIPS and REDIS

Bogdan-Andrei Iancu-2
Hi Michele,

What you fetch from REDIS is the plain-text password, right ? Have you checked if the loaded pwd is correct ?

Best regards,
Bogdan-Andrei Iancu
  OpenSIPS Founder and Developer
  http://www.opensips-solutions.com

OpenSIPS Bootcamp 2017, Houston, US
  http://opensips.org/training/OpenSIPS_Bootcamp_2017.html
On 06/14/2017 10:45 AM, Michele Pinassi wrote:
Hi all,

i'm trying to setup a REDIS cache to share register data with my two
OpenSIPS server, to have some redundancy.

On opensips.cfg:

#### AUTHentication modules
loadmodule "auth.so"
modparam("auth", "username_spec", "$var(username)")
modparam("auth", "password_spec", "$avp(password)")
modparam("auth", "disable_nonce_check", 1)

loadmodule "auth_db.so"
modparam("auth_db", "calculate_ha1", 1)
modparam("auth_db", "password_column", "password")
modparam("auth_db", "load_credentials", "$avp(password)=password")

[...]

#### Redis module
loadmodule "cachedb_redis.so"
modparam("cachedb_redis", "cachedb_url", "redis:voip://192.168.1.1:6379/")

[...]

### REGISTER
        if (is_method("REGISTER")) {
            # Check for cache...
           if(cache_fetch("redis:voip","passwd_$tU",$avp(password))) {
               $var(username) = $tU;
               $var(rc) = pv_www_authorize("");
           } else {
               # or authenticate the REGISTER requests...
                $var(rc) = www_authorize("","subscriber");
           }

            switch($var(rc)) {
                case 1 :
                   xlog("L_INFO", "Registration SUCCESS $fu\n");
                    # Save credentials to REDIS cache
                   
cache_store("redis:voip","passwd_$tU","$avp(password)",128000);
                    break;
                case -1:
                    xlog("L_ERR","Auth error for $fU@$fd from $si:
INVALID USER");
                    break;
                case -2:
                    xlog("L_ERR","Auth error for $fU@$fd from $si:
INVALID PASSWORD");
                    break;
                case -3: # Stale nonce - This is not an error, so don't
print anything
                    break;
                case -4:
                    www_challenge("", "0");
                    break;
                default:
                    xlog("L_ERR","Auth error for $fU@$fd from $si cause
$var(rc)");
            }

but i got an INVALID PASSWORD for all account stored in REDIS cache.
What's wrong ?

Thanks, Michele




_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users