From 7fc4e776bc06b9e10107f19144f0fef13820f973 Mon Sep 17 00:00:00 2001 From: Marco Capetta Date: Thu, 24 Jun 2021 09:12:32 +0200 Subject: [PATCH] TT#82409 Add support of 'peer_auth_hf_user' preference in createRegistration Change-Id: I86bd04d19f12604cd64981ba07651526298b2b5f --- lib/NGCP/Panel/Utils/Preferences.pm | 2 +- lib/NGCP/Panel/Utils/Sems.pm | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/NGCP/Panel/Utils/Preferences.pm b/lib/NGCP/Panel/Utils/Preferences.pm index 9ada4534f0..0b4d8fa51e 100644 --- a/lib/NGCP/Panel/Utils/Preferences.pm +++ b/lib/NGCP/Panel/Utils/Preferences.pm @@ -2575,7 +2575,7 @@ sub update_sems_peer_auth { sub get_peer_auth_params { my ($c, $prov_subscriber, $prefs) = @_; - foreach my $attribute (qw/peer_auth_user peer_auth_realm peer_auth_pass peer_auth_register/){ + foreach my $attribute (qw/peer_auth_user peer_auth_hf_user peer_auth_realm peer_auth_pass peer_auth_register/){ my $rs; $rs = get_usr_preference_rs( c => $c, diff --git a/lib/NGCP/Panel/Utils/Sems.pm b/lib/NGCP/Panel/Utils/Sems.pm index 50ce765c86..24082ff044 100644 --- a/lib/NGCP/Panel/Utils/Sems.pm +++ b/lib/NGCP/Panel/Utils/Sems.pm @@ -50,6 +50,10 @@ sub create_peer_registration { $transport = $outbound_sock->{transport}; } + # if no specific username defined for the Authorization header + # use the value of the peer_auth_user instead + my $authorization_username = $$prefs{peer_auth_hf_user} // $$prefs{peer_auth_user}; + my @ret = NGCP::Panel::Utils::XMLDispatcher::dispatch($c, "appserver", $all, 1, < @@ -60,6 +64,7 @@ sub create_peer_registration { $$prefs{peer_auth_pass} $$prefs{peer_auth_realm} sip:$$prefs{peer_auth_user}\@$contact;uuid=$uuid$transport + $authorization_username EOF @@ -122,6 +127,10 @@ sub update_peer_registration { $c->log->debug("+++++++++++++++++++ uuid=$uuid"); $c->log->debug("+++++++++++++++++++ contact=$contact"); + # if no specific username defined for the Authorization header + # use the value of the peer_auth_user instead + my $authorization_username = $$prefs{peer_auth_hf_user} // $$prefs{peer_auth_user}; + my @ret = NGCP::Panel::Utils::XMLDispatcher::dispatch($c, "appserver", $all, 1, < @@ -132,6 +141,7 @@ sub update_peer_registration { $$prefs{peer_auth_pass} $$prefs{peer_auth_realm} sip:$$prefs{peer_auth_user}\@$contact;uuid=$uuid$transport + $authorization_username EOF @@ -140,6 +150,10 @@ EOF return 1; } + # if no specific username defined for the Authorization header + # use the value of the peer_auth_user instead + my $old_authorization_username = $$oldprefs{peer_auth_hf_user} // $$oldprefs{peer_auth_user}; + if(grep { $$_[1] == 0 or $$_[2] !~ m#OK# } @ret) { # error $c->log->error("Failed XML-RPC call to appserver: ". Dumper \@ret); @@ -155,6 +169,7 @@ EOF $$oldprefs{peer_auth_pass} $$oldprefs{peer_auth_realm} sip:$$oldprefs{peer_auth_user}\@$contact;uuid=$uuid + $old_authorization_username EOF @@ -198,6 +213,10 @@ EOF return 1; } + # if no specific username defined for the Authorization header + # use the value of the peer_auth_user instead + my $old_authorization_username = $$oldprefs{peer_auth_hf_user} // $$oldprefs{peer_auth_user}; + if(grep { $$_[1] == 0 or $$_[2] !~ m#OK# } @ret) { # error $c->log->error("Failed XML-RPC call to appserver: ". Dumper \@ret); @@ -213,6 +232,7 @@ EOF $$oldprefs{peer_auth_pass} $$oldprefs{peer_auth_realm} sip:$$oldprefs{peer_auth_user}\@$contact;uuid=$uuid + $old_authorization_username EOF