[SR-Users] Group module

Igor Olhovskiy igorolhovskiy at gmail.com
Wed Nov 6 19:15:42 CET 2019


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 <hw at 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-bounces at lists.kamailio.org> On Behalf Of Igor Olhovskiy
> Sent: Wednesday, November 6, 2019 6:05 PM
> To: Kamailio (SER) - Users Mailing List <sr-users at 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:61388140395 at 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:61388140395 at 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!
>
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20191106/9809039d/attachment.html>


More information about the sr-users mailing list