<div dir="ltr">Hello group,<div><br></div><div><br></div><div>I am attempting to add memcache auth validation in opensips 2.1. I was using http db which returns a string of the user password password. This was working prior to utilizing pv_www_authorize. I used this document as a guideline <a href="http://www.opensips.org/Documentation/Tutorials-MemoryCaching">http://www.opensips.org/Documentation/Tutorials-MemoryCaching</a></div><div><br></div><div>Here is my auth mod param config</div><div><div>loadmodule "cachedb_local.so"</div><div>loadmodule "auth.so"</div><div>loadmodule "auth_db.so"</div><div>modparam("auth","username_spec","$avp(i:54)")</div><div>modparam("auth","password_spec","$avp(i:55)")</div><div>modparam("auth","calculate_ha1",1)</div><div><br></div><div>modparam("auth_db", "calculate_ha1", yes)</div><div><br></div><div>modparam("auth_db", "password_column", "password")</div><div>#modparam("auth_db", "db_url",</div><div>modparam("auth_db", "db_url",<br></div><div>     "<a href="http://mysubscriberdatabase.com">http://mysubscriberdatabase.com</a>")</div><div><br></div><div>modparam("auth_db", "load_credentials", "$avp(i:55)=password")</div></div><div><br></div><div><br></div><div><span class="" style="white-space:pre"> </span>if (is_method("REGISTER")) {</div><div><br></div><div><span class="" style="white-space:pre"> </span># indicate that the client supports DTLS</div><div><span class="" style="white-space:pre"> </span># so we know when he is called</div><div><span class="" style="white-space:pre"> </span>if (isflagset(SRC_WS))</div><div><span class="" style="white-space:pre"> </span>setbflag(DST_WS);</div><div><br></div><div><span class="" style="white-space:pre"> </span>if ( isflagset(uac_ws) ) {</div><div><span class="" style="white-space:pre"> </span>     xlog("setting avp attribute in register for websocket \n");</div><div><br></div><div> $avp(attr)="websocket"; <span class="" style="white-space:pre"> </span></div><div>}</div><div><span class="" style="white-space:pre"> </span></div><div><span class="" style="white-space:pre"> </span></div><div><span class="" style="white-space:pre"> </span>if(cache_fetch("local","passwd_$tu",$avp(i:55))) {</div><div><span class="" style="white-space:pre"> </span>xlog("$tU 's credentials are stored in local cache using it for this register request \n"); </div><div><span class="" style="white-space:pre"> </span>$avp(i:54) = $tU;</div><div><span class="" style="white-space:pre"> </span>xlog("SCRIPT: stored password is $avp(i:55)\n");</div><div><span class="" style="white-space:pre"> </span># perform auth from variables</div><div><span class="" style="white-space:pre"> </span># $avp(i:54) contains the username</div><div><span class="" style="white-space:pre"> </span># $avp(i:55) contains the password</div><div><span class="" style="white-space:pre"> </span>if (!pv_www_authorize("")) {</div><div><span class="" style="white-space:pre"> </span>$var(rc2) = pv_www_authorize("");</div><div><span class="" style="white-space:pre"> </span>        #  $var(rc2) = www_authorize("", "subscriber");</div><div><span class="" style="white-space:pre"> </span>     xlog("Return code is $var(rc2) \n");</div><div><span class="" style="white-space:pre"> </span>         switch ( $var(rc2) ) {</div><div>  case 1 :</div><div>      # if ( proto==TCP ||  0 ) {</div><div>      #       setflag(TCP_PERSISTENT); </div><div>      #           setflag(6);</div><div>       #  }</div><div>       </div><div><br></div><div>        if (!save("location","f"))</div><div>            sl_reply_error();</div><div><br></div><div>        exit;</div><div><br></div><div><br></div><div>    # success</div><div>    break;</div><div>  case -1:</div><div>    sl_send_reply("404","User not found");</div><div>    exit;</div><div>    break;</div><div>  case -2:</div><div>    sl_send_reply("403","Forbidden (Bad auth)");</div><div>        exit;</div><div>    break;</div><div>     case -3:</div><div>                        www_challenge("", "0");</div><div>    exit;</div><div>    #sl_send_reply("403","Forbidden auth ID");</div><div>    #break;</div><div>  default:</div><div>                www_challenge("", "0");</div><div>        exit;</div><div><br></div><div>}</div><div><br></div><div><span class="" style="white-space:pre"> </span>};</div><div><br></div><div><span class="" style="white-space:pre"> </span></div><div>     if (!save("location","f"))</div><div>            sl_reply_error();</div><div><br></div><div>        exit;</div><div><span class="" style="white-space:pre"> </span></div><div><span class="" style="white-space:pre"> </span>}else{<span class="" style="white-space:pre"> </span></div><div><span class="" style="white-space:pre"> </span></div><div><span class="" style="white-space:pre"> </span>xlog("could not find the auth info in local cache for $tU\n"); <span class="" style="white-space:pre"> </span> </div><div><span class="" style="white-space:pre"> </span>xlog("accessing the external db for auth info");</div><div><span class="" style="white-space:pre"> </span>  # authenticate the REGISTER requests</div><div>        if (!www_authorize("", "subscriber"))</div><div>        {</div><div>                        xlog("new challenger  $tU\n");</div><div><br></div><div><br></div><div>        #    www_challenge("", "0");</div><div><br></div><div><br></div><div><br></div><div>        $var(rc) = www_authorize("", "subscriber");</div><div>    xlog("Return code is $var(rc) \n");</div><div><br></div><div>    switch ( $var(rc) ) {</div><div>  case 1 :</div><div>      # if ( proto==TCP ||  0 ) {</div><div>      #       setflag(TCP_PERSISTENT); </div><div>      #           setflag(6);</div><div>       #  }</div><div>                    #     $avp(me) = $(tU{s.tolower});</div><div><br></div><div>        cache_store("local","passwd_$tu","$avp(i:55)",1200);</div><div><br></div><div>        if (!save("location","f"))</div><div>            sl_reply_error();</div><div><br></div><div>        exit;</div><div><br></div><div><br></div><div>    # success</div><div>    break;</div><div>  case -1:</div><div>    sl_send_reply("404","User not found");</div><div>    exit;</div><div>    break;</div><div>  case -2:</div><div>    sl_send_reply("403","Forbidden (Bad auth)");</div><div>        exit;</div><div>    break;</div><div>     case -3:</div><div>                        www_challenge("", "0");</div><div>    exit;</div><div>    #sl_send_reply("403","Forbidden auth ID");</div><div>    #break;</div><div>  default:</div><div>                www_challenge("", "0");</div><div>        exit;</div><div><br></div><div>} </div><div>}</div><div><br></div><div><span class="" style="white-space:pre"> </span>xlog("should be storing local now that it has been authorized\n");</div><div><span class="" style="white-space:pre"> </span>             cache_store("local","passwd_$tu","$avp(i:55)",1200);</div><div><span class="" style="white-space:pre"> </span>}</div><div><br></div><div>if (!save("location","f"))</div><div><span class="" style="white-space:pre"> </span>sl_reply_error();</div><div><br></div><div><span class="" style="white-space:pre"> </span>exit;</div><div><span class="" style="white-space:pre"> </span></div><div>}  </div><div><br></div><div><br></div><div><br></div><div>The issue is the pv__www_authorize method after the verification wether the password is stored locally always returns -2 which means the password is incorrect. Can anyone provide any guidence as to why this is ?</div><div><br></div><div><br></div><div>Thanks,<br>Tito</div></div>