Trying to fetch Basic Auth header in Mason

Discussion in 'Perl Misc' started by Steve, Apr 22, 2008.

  1. Steve

    Steve Guest

    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!
    Steve, Apr 22, 2008
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Q2hyaXMgTW9oYW4=?=

    Configuring Windows Auth & Forms Auth in Asp.Net

    =?Utf-8?B?Q2hyaXMgTW9oYW4=?=, Apr 28, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    686
    =?Utf-8?B?Q2hyaXMgTW9oYW4=?=
    Apr 28, 2004
  2. =?Utf-8?B?ZGhucml2ZXJzaWRl?=

    Windows Auth, but Forms Auth for one page?

    =?Utf-8?B?ZGhucml2ZXJzaWRl?=, Jan 8, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    543
    Elton Wang
    Jan 8, 2005
  3. Mark Chai
    Replies:
    1
    Views:
    738
    Christophe Vanfleteren
    Oct 1, 2003
  4. Steve
    Replies:
    0
    Views:
    647
    Steve
    Jun 22, 2005
  5. Replies:
    3
    Views:
    311
    Siddharta .
    Jun 12, 2007
Loading...

Share This Page