I wrote a custom auth handler for apache using Apache2::Access. I had to use Net::SSH::Perl for authentication. It takes a while to authenticate with Net::SSH::Perl so I was hoping to authenticate just once instead of every time.

I have tried using $r->notes->set(Key=>Value) at the beginning of the PerlAthenHandler but there is no data in notes. However other pages can get the hash data after the authentication.

I also tried $r->headers_out->add(Key=Value) and there is also no data. Like above pages after authentication can access this data. Looking at the http headers after auth shows the headers_out I created during the auth stage.

What am I missing to get PerlAutenHandler to read $r->notes or $r->headers_out->get??

Snipplet of code:
sub handler { my $r = shift; my($res, $password) = $r->get_basic_auth_pw; return $res if $res != OK; my $user = $r->user; #EMPTY my $remote_user = $r->notes->get("User"); #EMPTY my $test = $r->headers_out->get("User"); if ($remote_user ne "" || $test ne ""){ return Apache2::Const::OK; } #SSH VALIDATE (NOT ALL THE CODE HERE) eval { $ssh->login($user,$password); }; if ($@){ $r->note_basic_auth_failure; return Apache2::Const::AUTH_REQUIRED; } $r->err_headers_out->add('User') = $user; $r->notes->add("User" => $user); return Apache2::Const::OK; } 1; __END__

In reply to PerlAuthenHandler Problems by yibbiy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.