[OpenSIPS-Users] Authentication using Username, Password, IP address or Just IP address
Bogdan-Andrei Iancu
bogdan at opensips.org
Tue Feb 11 13:34:59 CET 2014
Hello Alec,
I'm happy you managed to make it work.
Regards,
Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
http://www.opensips-solutions.com
On 11.02.2014 06:18, Alec Doran-Twyford wrote:
> Hi Bogdan,
>
> Thanks for the help it working a charm now the code look like this for
> anyone else who is interested:
>
> if(check_source_address("0")) {
> xlog("IP Allow Routing");
> } else {
> xlog("authentication required for call from $si");
> if (!is_method("REGISTER")) {
> # EC - auth
> if (!proxy_authorize("", "subscriber")) {
> xlog("proxy challenge!");
> proxy_challenge("", "0"); # Realm
> will be autogenerated
> exit;
> }
> if (!db_check_from()) {
> xlog("forbidden!");
> sl_send_reply("403","Forbidden auth ID");
> exit;
> }
> consume_credentials();
> }
> else {
> if (!www_authorize("", "subscriber")) {
> xlog("www challenge!");
> www_challenge("", "0"); # Realm will
> be autogenerated
> exit;
> }
>
> if (!db_check_from()) {
> xlog("forbidden!");
> sl_send_reply("403","Forbidden auth ID");
> exit;
> }
>
> if (!save("location")) {
> xlog("failed to save location!");
> sl_reply_error();
> }
>
>
> xlog("registered - $from");
> exit;
> }
> }
>
>
> and currently add IP like this in to the database
> insert into opensips.address (ip, port) VALUES ("192.168.168.55", 5060);
>
> and then use the command to refresh the current cache of entries
> opensipsctl fifo address_reload
>
> Alec Doran-Twyford
>
> | Junior Support Enginner for IVSTel
> | E-mail: a.dorantwyford at ivstel.com <mailto:a.dorantwyford at ivstel.com>
> | Phone: +61 2 9288 8890 |
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20140211/5b7e9d84/attachment.htm>
More information about the Users
mailing list