Trying to fetch Basic Auth header in Mason

S

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top