Has anyone considered adding support for sites that require basic HTTP authorization?
We enforce HTTP auth on our site using the Secure Site module. If you configure linkchecker to ignore "401 authentication required" responses, the module is still usable. Basically, it still detects URLs which are broken vs. ones which require access; however, our logs are filled with 'access denied' warnings.
I started hacking around a bit. See attached patch.
NOTE: I tried to use drupal_http_request's ability to pass the user name and password prepended to the URL; however, it was failing upon re-tries for redirection. I'm not sure if that is a bug with drupal_http_request() or what.?.? Passing the credentials as part of the header instead seems to work though.
Feedback or thoughts?
| Comment | File | Size | Author |
|---|---|---|---|
| linchecker_httpauth.diff | 4.58 KB | stacysimpson |
Comments
Comment #1
hass commentedComment #2
hass commentedFor getting a better understanding, why are you not adding an exception to Apache to pass localhost/known hosts without auth? However this sounds like a serious security problem... sending the passwords unencrypted on non-SSL sounds like a problem.
I have invalidated this patch with a few changes I made some minutes ago and it need to be done for D7 first.
Comment #3
hass commentedFound this in core
drupal_http_requestthat looks like your patch do not need to handle this:Comment #4
hass commentedThe syntax should be more like the URLs are.
Example:
or:
This way we may just use string replace on urls and fire them with user credentials. However this would be limiting... We also need to handle other password in other directories... In this case root folder credentials (/*) will be used in any other folder except /foo and /bar. I believe we have some re-usable regexes for path matching in core blocks module.
Comment #5
stacysimpson commentedWe haven't looked into the Apache by-pass alternative.
You are correct about security though...our site requires SSL, so it wasn't a big deal for us.
With regard to your suggestion to use the
http://username:password@www.example.com/format. Per my comments in the original submission, that technique doesn't seem to work with redirection due to the use of node aliases created by pathauto.Or, at least I think that is the contributing factor.?.? Adding the HTTP Auth credentials directly to the header without relying on drupal_http_request() to do so does work. Seems like a bug in drupal_http_request() to me.
Comment #6
hass commentedMaybe, but otherwise it may be a critical security problem. It sounds wrong to me if the password get automatically send to the redirected link. Therefore I wonder why it works with the header... additional the drupal_http_request() has the same logic of sending your username/password than you have implemented... that is why I wonder that it does not work.
Only thinking out loud; If I ask your server for
https://username:password@www.example.com/foo/barand it answers with a 301 and urlhttps://username:password@www.passwordsniffingdomain.com/foo.cgiand than you will have a critical security issue... this sounds like a big security hole to me. I think it's not correct way!The redirect rule may need to take care of this password redirection. As you are the owner of your server you can create a redirect rule that also include the username/password... never done this, but it should be possible.
Above feature was just an idea to replace the URL and send the password to a domain... but now after more thinking I think this will add only security holes.
Comment #7
hass commentedhttp://api.drupal.org/api/drupal/includes--common.inc/function/drupal_ht...
Comment #8
stacysimpson commentedThanks for the feedback and I agree the security ramifications are a bit concerning. We used a built-in, internal account for this purpose as not to expose any actual account credentials.
We are using Drupal 6 and in that revision, http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_ht..., the $defaults object is not passed recursively to the drupal_http_request() method when performing re-tries (it only passes the redirected url and the original headers object). In Drupal 7, the $options object seems to be passed recursively, so I could foresee that alternative working. Haven't tried it though.
Comment #9
hass commentedI haven't tried it, but you say - it works in D7? How about backporting the required changes? Maybe core maintainers accept a patch as refactoring/bugfix...? Otherwise patch core and publish the patch... Let me know the case number, please. I guess it should not be difficult to backport the D7 version details and make it api compatible to D6... Maybe there is already a case open...
Comment #10
hass commentedIssue seems to be solved.