Trying to fetch Basic Auth header in Mason

Trying to fetch Basic Auth header in Mason

am 22.04.2008 22:01:41 von Steve

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!