Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   Trying to fetch Basic Auth header in Mason (http://www.velocityreviews.com/forums/t907192-trying-to-fetch-basic-auth-header-in-mason.html)

Steve 04-22-2008 08:01 PM

Trying to fetch Basic Auth header in Mason
 
I have a very simple internal web application "protected" (more or
less) by HTTP Basic Auth. The app is written using Mason, and I'm
trying to have it fetch the username of the current user from the HTTP
headers. At a high-level, one could do this by fetching the value of
the header "Authorization", which looks like this:

Authorization: Basic sdfSDFssdfsdfSDF=

... where the value consists of the word "Basic", followed by a space,
followed by the username and password encoded with Base64.


My little helper subroutine on my Mason page is straightforward enough:

sub getHeader {
my $name = shift;
my %headers = $r->headers_in;
return $headers{$name};
}

... as is calling it:

my $authorizationHeader = &getHeader( 'Authorization' );


However, the value that I'm getting for "$authorizationHeader" in the
example above is always the string "Basic". Mason stops at the space,
and won't return the Base64-encoded portion of the header value
following that space. I've played around with trying to return the
value as an array rather than a scalar, but it hasn't made any difference.

Is this an actual bug with Mason, or can anyone spot anything really
stupid that I'm missing? Thanks in advance!


All times are GMT. The time now is 12:34 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.