Passing Credentials through PHP

Hello,

I am trying to make a CURL call from PHP to Kibana. The call is simple

$URL = “http://xxxxxxxxxxxxxxxxxxxxx/api/saved_objects/visualization/a37d6730-578d-11e8-8a7f-17adcb8f2388”;

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $URL);

curl_setopt($ch, CURLOPT_TIMEOUT, 30); //timeout after 30 seconds

curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);

curl_setopt($ch, CURLOPT_USERPWD, “$user:$pass”);

$result=curl_exec ($ch);

$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); //get status code

curl_close ($ch);

However searchguard wants to redirect the page and thats not handled well in the call. Any ideas how I can pass the credentials in the request?

Adwait

BUMP

···

On Wednesday, September 26, 2018 at 1:59:07 PM UTC-4, Adwait Joshi wrote:

Hello,

I am trying to make a CURL call from PHP to Kibana. The call is simple

$URL = “http://xxxxxxxxxxxxxxxxxxxxx/api/saved_objects/visualization/a37d6730-578d-11e8-8a7f-17adcb8f2388”;

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $URL);

curl_setopt($ch, CURLOPT_TIMEOUT, 30); //timeout after 30 seconds

curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);

curl_setopt($ch, CURLOPT_USERPWD, “$user:$pass”);

$result=curl_exec ($ch);

$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); //get status code

curl_close ($ch);

However searchguard wants to redirect the page and thats not handled well in the call. Any ideas how I can pass the credentials in the request?

Adwait

I’m not familiar with PHP, but a simple (non-PHP) curl call works like a charm:

curl -k -u admin:admin -XGET “http://kibana.example.com:5601/api/saved_objects/visualization/a37d6730-578d-11e8-8a7f-17adcb8f2388

Please try a plain curl call first, and then make sure the PHP options are correct. Please also make sure to use the latest version of the Kibana plugin.

···

On Monday, October 1, 2018 at 1:46:11 PM UTC+2, Adwait Joshi wrote:

BUMP

On Wednesday, September 26, 2018 at 1:59:07 PM UTC-4, Adwait Joshi wrote:

Hello,

I am trying to make a CURL call from PHP to Kibana. The call is simple

$URL = “http://xxxxxxxxxxxxxxxxxxxxx/api/saved_objects/visualization/a37d6730-578d-11e8-8a7f-17adcb8f2388”;

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $URL);

curl_setopt($ch, CURLOPT_TIMEOUT, 30); //timeout after 30 seconds

curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);

curl_setopt($ch, CURLOPT_USERPWD, “$user:$pass”);

$result=curl_exec ($ch);

$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); //get status code

curl_close ($ch);

However searchguard wants to redirect the page and thats not handled well in the call. Any ideas how I can pass the credentials in the request?

Adwait

I was able to get past the PHP error by setting some headers! Thanks for your help.

···

On Tuesday, October 2, 2018 at 4:53:59 AM UTC-4, Jochen Kressin wrote:

I’m not familiar with PHP, but a simple (non-PHP) curl call works like a charm:

curl -k -u admin:admin -XGET “http://kibana.example.com:5601/api/saved_objects/visualization/a37d6730-578d-11e8-8a7f-17adcb8f2388

Please try a plain curl call first, and then make sure the PHP options are correct. Please also make sure to use the latest version of the Kibana plugin.

On Monday, October 1, 2018 at 1:46:11 PM UTC+2, Adwait Joshi wrote:

BUMP

On Wednesday, September 26, 2018 at 1:59:07 PM UTC-4, Adwait Joshi wrote:

Hello,

I am trying to make a CURL call from PHP to Kibana. The call is simple

$URL = “http://xxxxxxxxxxxxxxxxxxxxx/api/saved_objects/visualization/a37d6730-578d-11e8-8a7f-17adcb8f2388”;

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $URL);

curl_setopt($ch, CURLOPT_TIMEOUT, 30); //timeout after 30 seconds

curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);

curl_setopt($ch, CURLOPT_USERPWD, “$user:$pass”);

$result=curl_exec ($ch);

$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); //get status code

curl_close ($ch);

However searchguard wants to redirect the page and thats not handled well in the call. Any ideas how I can pass the credentials in the request?

Adwait