Click here to get back home

Trying to fetch Basic Auth header in Mason

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Trying to fetch Basic Auth header in Mason Steve 04-22-2008
Posted by Steve on April 22, 2008, 4:01 pm
Please log in for more thread options
        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;
}

        ... 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!

Similar ThreadsPosted
help with auth dbi May 13, 2008, 4:50 pm
Auth DBI on apache June 5, 2007, 8:53 am
Auth Surfing using Perl March 21, 2005, 3:23 pm
http auth logindialog box May 30, 2005, 9:40 am
htaccess auth question January 13, 2006, 2:17 pm
MIME::Lite and smtp auth June 28, 2007, 4:13 am
HTML::Mason March 7, 2005, 7:45 am
MASON getting arguments. June 21, 2007, 4:05 pm
Mason book available as PDF file? October 18, 2004, 6:36 am
Mason hosting support? February 19, 2005, 12:11 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap