I am working with cross-domain AJAX in jquery, using a local forwarding script in the middle, and I need to pass Basic Authentication information through to the second domain.
In PHP, I know I have access to $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW'] variables which are simple plaintext, so my forwarding script can use this information with no difficulty.
For reasons beyond my control, though, I have to perform this task with Perl CGI. I know there is $ENV{REMOTE_USER}, but I can not for the life of me figure out how to find the password. I’ve tried $ENV{HTTP_AUTHORIZATION} but that always comes out blank.
How, in Perl, can I read the Basic Authentication password? Or, at least, is there a way for my CGI to directly read the Authorization header so I can base64-decode and split the string myself?
Thanks!
Check out this article: http://www.besthostratings.com/articles/http-auth-php-cgi.html .
It uses ModReWrite to write the Http Authorization header to an environment variable. You can then access and decode this in your CGI script.