Agent Events Push, get2post.php & authentication

Discussions about development of VICIDIAL and astGUIclient

Moderators: gerski, enjay, williamconley, Op3r, Staydog, gardo, mflorell, MJCoate, mcargile, Kumba, Michael_N

Agent Events Push, get2post.php & authentication

Postby vicinewman » Wed May 16, 2018 9:34 am

Making integration of our CRM with Vicidial. Trying to use HTTP Push events to an external server thought the script get2post.php.
As we see get2post.php doesn't have any authentication.

On the external server we have an API with a basic authentication, so how to make an authentication on Vicidial side before making callbacks, any suggestions?
To modify get2post.php or there is any other build in functions ?
vicinewman
 
Posts: 16
Joined: Tue Feb 20, 2018 1:33 pm

Re: Agent Events Push, get2post.php & authentication

Postby mflorell » Wed May 16, 2018 9:47 am

Please explain in more detail what you mean by "authentication", since this could mean many different things.
mflorell
Site Admin
 
Posts: 18335
Joined: Wed Jun 07, 2006 2:45 pm
Location: Florida

Re: Agent Events Push, get2post.php & authentication

Postby vicinewman » Fri May 18, 2018 9:31 am

Hi Matt !

Will try to be more clear.
Our API, on the external server side, has HTTP/HTTPS Basic access authentication (RFC 7617) to preven "from being used" any others except Vicidial.
So, right now when Vicidial sends some Agent's Events through the script get2post.php to the external server it can't pass the data through the API.
As get2post.php doesn't support Basic access authentication needed to handshake with the API on the external server over HTTP/HTTPS.

Any suggestions how to solve this issue ?

Thanks!
vicinewman
 
Posts: 16
Joined: Tue Feb 20, 2018 1:33 pm

Re: Agent Events Push, get2post.php & authentication

Postby blackbird2306 » Fri May 18, 2018 12:28 pm

You should be able to use basic authentication with setting the "headers" in your url or you need to alter the code in get2post.php and add curl options "CURLOPT_HTTPAUTH" and "CURLOPT_USERPWD".
Solution 1 (without any changes in code):
1. First you need to base64 encode the username and password in this format: username:password
e.g. try https://www.base64encode.org/ --> user1:pass1 would be "dXNlcjE6cGFzczE=" base64 encoded
2. Then your header should be like this: "Authorization: Basic dXNlcjE6cGFzczE="
3. Set you push event url (replace "dXNlcjE6cGFzczE=" with your base64 encoded string):
Code: Select all
get2post.php?uniqueid=--A--epoch--B--.--A--agent_log_id--B--&type=event&&headers=Authorization---Basic dXNlcjE6cGFzczE=&HTTPURLTOPOST=192.168.1.3/agc/vdc_call_url_test.php?user=--A--user--B--&lead_id=--A--lead_id--B--&event=--A--event--B--&message=--A--message--B--


Solution 2:
1. Change get2post.php (curl part starting at line 158 in revision from 2017-05-31):
Code: Select all
      curl_setopt_array($curl, array(
        // add next 2 lines and change user and pass with your real user credentials
         CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
         CURLOPT_USERPWD => 'user:pass',
         CURLOPT_RETURNTRANSFER => 1,
         CURLOPT_POST => 1,
         CURLOPT_URL => $post_page,
         CURLOPT_POSTFIELDS => $post_vars,
         CURLOPT_HTTPHEADER => $HTTPheader,
         CURLOPT_USERAGENT => 'VICIdial get2post'
      ))
Vicibox 6.0.2 from Vicibox_v.6.0.x86_64-6.0.2.iso | Vicidial 2.12-560a build: 160617-1427 | Asterisk 1.8.32.3
blackbird2306
 
Posts: 409
Joined: Mon Jun 23, 2014 5:31 pm

Re: Agent Events Push, get2post.php & authentication

Postby vicinewman » Fri May 18, 2018 1:34 pm

blackbird2306 wrote:You should be able to use basic authentication with setting the "headers" in your url or you need to alter the code in get2post.php and add curl options "CURLOPT_HTTPAUTH" and "CURLOPT_USERPWD".


Thanks, we will try it
vicinewman
 
Posts: 16
Joined: Tue Feb 20, 2018 1:33 pm


Return to Development

Who is online

Users browsing this forum: No registered users and 41 guests