Bug #20770

[t3lib_div::getURL][curl] CURLOPT_HTTPAUTH missing

Added by Amar Bouchibane almost 4 years ago. Updated almost 2 years ago.

Status:Needs Feedback Start date:2009-07-19
Priority:Could have Due date:
Assignee:Amar Bouchibane % Done:

0%

Category:-
Target version:-
TYPO3 Version:4.6 Complexity:hard
PHP Version:5.2
Votes: 0

Description

When using a basic authentication (Apache) on site curl won't get the content because of missing CURLOPT_HTTPAUTH/CURLOPT_USERPWD setopts.

I have attached a patch of t3lib_div which requires a "curl" user with a password generated from data "curl" hashed with the "encryptionKey" (see getURL). I don't know if this is very handy.

(issue imported from #M11559)

class.t3lib_div.php (192.4 kB) Administrator Admin, 2009-07-19 22:55


Related issues

related to Core - Feature #28344: Include HTTP Request2 for better HTTP handling Closed 2011-07-20 2011-07-25

History

Updated by Marcus Krause almost 4 years ago

The general idea is nice. However, username and password being hardcoded isn't handy at all and this patch won't make it to TYPO3 Core as such.

Updated by Philipp Gampe almost 2 years ago

  • Target version deleted (0)

I think t3lib_http_request handles this as well.

This should be set to feedback for a month and then be closed.

Updated by Thorsten Kahler almost 2 years ago

  • Status changed from New to Needs Feedback
  • Assignee set to Amar Bouchibane
  • Priority changed from Should have to Could have
  • TYPO3 Version changed from 4.2 to 4.6
  • Complexity set to hard

Hi Amar, could you please give some more details on this issue? Perhaps you could also provide the patch as unified diff?

Updated by Amar Bouchibane almost 2 years ago

Hi Thorsten,

I had (and still have) turned into a portal where Apaches' Basic Authentication is activated. My site uses the "mnogosearch" extension (and thus the "pagepath" extension).

I can still reproduce the problem when I change and then save one record in the TYPO3 BE that has to be indexed.

The mnogosearch extension calls (via tx_mnogosearch_tcemain::processDatamap_afterDatabaseOperations) the tx_pagepath_api::getPagePath method. Within this method t3lib_div::getURL will be called. When I debug the code, I notice that the return value of getURL (= curl_exec) is always FALSE:

When I use the "$report" in getURL, I get back this array:

$report : array (
error: 22,
message: "The requested URL returned error: 401",
lib: "CURL)

The two lines I've added (which worked then on a simple HTTP server without proxy) were these:

modified t3lib_div::getURL:
--------------------------
...
curl_setopt($ch, CURLOPT_FAILONERROR, 1);

// Added: Amar --- begin
curl_setopt($ch, CURLOPT_USERPWD, 'curl:'.hash_hmac('md5', 'curl', $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']));
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
// Added: Amar --- end

// May fail (PHP 5.2.0 + and 5.1.5 +) when open_basedir or safe_mode are enabled
$followLocation = @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
...

On the other hand the "Retrieve/Update" in the ExtManager although uses getURL(), but works perfectly... even with a "curlProxyServer".

Anyway my workaround doesn't work for me anymore (in TYPO3 4.4.7). I got to admit that I use SSL and a curl-Proxy now.
But it worked for me at that time with a simple HTTP-Server without a curl-Proxy.

Also available in: Atom PDF