Hello Igor,

to make it clearer – if you want to use the regular expression matching, have a 
look to the module documentation. There is e.g. a regular expression column 
that you need to fill, not the one that you quoted below in your select.

If you want to use the quoted table, use the β€œis_user_in” function.

Cheers,

Henning

--
Henning Westerholt - https://skalatan.de/blog/
Kamailio services - https://skalatan.de/services

From: sr-users <sr-users-boun...@lists.kamailio.org> On Behalf Of Igor Olhovskiy
Sent: Wednesday, November 6, 2019 7:16 PM
To: Kamailio (SER) - Users Mailing List <sr-users@lists.kamailio.org>
Subject: Re: [SR-Users] Group module


Hm... Maybe there is other module to achieve such functions?

Best if it would be with cache :)

But if no - regex also fine.
On Nov 6 2019, at 6:18 pm, Henning Westerholt 
<h...@skalatan.de<mailto:h...@skalatan.de>> wrote:

Hello Igor,



the module is old, but should work. 😊 It is used a lot.



The function get_user_group(..) is used for regular expression matching. You 
want to change this probably for is_user_in(..). This function works, I just 
used it.



Cheers,



Henning



--

Henning Westerholt - https://skalatan.de/blog/

Kamailio services - https://skalatan.de/services



From: sr-users 
<sr-users-boun...@lists.kamailio.org<mailto:sr-users-boun...@lists.kamailio.org>>
 On Behalf Of Igor Olhovskiy
Sent: Wednesday, November 6, 2019 6:05 PM
To: Kamailio (SER) - Users Mailing List 
<sr-users@lists.kamailio.org<mailto:sr-users@lists.kamailio.org>>
Subject: [SR-Users] Group module



Hi!


I'm trying to solve quite simple task and want to solve it as simple as 
possible.
Idea is to have restriction to allow register certain username/domain only from 
certain subnets.


So, I decided to use group and permissions modules.


But stuck on group one.
Code is fairly simple


modparam("group", "db_url", DBURL)
modparam("group", "use_domain", 1)
...
    if (get_user_group("From", "$avp(user_groups)")) {
        xlog("$fu from $si:$sp is matched group $avp(user_groups)\n");
        if (allow_source_address("$avp(user_groups)")) {
            ...allow furter
        }
    } else {
        xlog("$fu from $si:$sp is not matched any groups\n");
    }


grp table is looks like
kamctl db exec 'select * from grp'
+----+-------------+-------------------+-----+---------------------+
| id | username    | domain            | grp | last_modified       |
+----+-------------+-------------------+-----+---------------------+
|  1 | 61388140395 | sip.localhost.net | 5   | 2000-01-01 00:00:01 |
+----+-------------+-------------------+-----+---------------------+


But actual line of debug in logs saying this


kamailio_1    | 10(18) exec: {1 1 REGISTER 4oQTNaaVlEWQC2VMK6YAKg..} *** 
cfgtrace:request_route=[PERMISSIONS] c=[/etc/kamailio/kamailio.cfg] l=720 a=26 
n=get_user_group
kamailio_1    | 10(18) DEBUG: {1 1 REGISTER 4oQTNaaVlEWQC2VMK6YAKg..} group 
[re_group.c:188]: get_user_group(): getting groups for 
<sip:61388140...@sip.localhost.net>
kamailio_1    | 10(18) exec: {1 1 REGISTER 4oQTNaaVlEWQC2VMK6YAKg..} *** 
cfgtrace:request_route=[PERMISSIONS] c=[/etc/kamailio/kamailio.cfg] l=727 a=25 
n=xlog
kamailio_1    | 10(18) ERROR: {1 1 REGISTER 4oQTNaaVlEWQC2VMK6YAKg..} <script>: 
sip:61388140...@sip.localhost.net;transport=UDP from 172.21.0.1:56787 is not 
matched any groups


What am I missing here? Or module is too old?


Thanks!

_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users

Reply via email to