How to redirect headers in Perl?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Crazy Monkey

    How to redirect headers in Perl?

    Hi:

    I am new to Perl. I need to write a Perl page on the server that
    will do an auto login to a site. I have got the following code. It
    works for the first page, but on subsequent page, user is prompted for
    credential again. I suspected the issue has something to do with
    cookies. I want to pass the header from the secure site to the
    client, but I don't know how to do it. May be I approached the
    problem the wrong way. Thanks for the help.


    use LWP;
    use CGI;

    # get input parameters
    my $user = "user1";
    my $password = "password1" ;
    my $url = 'http://pages_need_auth entication';

    my $ua = new LWP::UserAgent;
    my $req = new HTTP::Request (GET => $url);

    $req->authorization_ basic ($user, $password);
    my $request = $ua->request ($req);

    my $page = $request->content;

    # I generate a new header here, because I don't know how to grab the
    header from request.
    print "Content-type: text/plain\n\n";
    print $page;






    Crazy Monkey
  • Crazy Monkey

    #2
    Re: How to redirect headers in Perl?

    Well. I was able to "jam" the cookie setting into the header and it
    did not solve my problem. I used a tool to look at the request and
    the responses. I see that the cookie is set properly. What I lack is
    the the authorization line? When I hit the secure site directly and
    login properly, I see the following line been sent to the server in
    the header on almost all of the my requests. By the way, the login is
    not a web page login, but a Realm login (Windows Pop-up box).

    Authorization: Basic xxxxxxxxxxxxxxx xxxxxxxx

    I used the authorization_b asic( $user, $password ) in my Perl code,
    but the authentication is not sticking. It works for the page that I
    am fetching through the Perl. By the way, the Perl page is located on
    a web server. It is not on the client machine.

    Thanks.


    Crazy Monkey

    Comment

    • Crazy Monkey

      #3
      Re: How to redirect headers in Perl?

      > Authorization: Basic xxxxxxxxxxxxxxx xxxxxxxx[color=blue]
      >
      > I used the authorization_b asic( $user, $password ) in my Perl code,
      > but the authentication is not sticking. It works for the page that I
      > am fetching through the Perl. By the way, the Perl page is located on
      > a web server. It is not on the client machine.[/color]


      There are times, you have to cut your losses. After spent two days on
      this, we decided NOT to use the autologin feature. Instead, we are
      going to let user authenticate themselves.

      If someone has an idea on how to do windows Basic authentication on a
      server and make it stick on a client, I am still interested for future
      reference.



      Crazy Monkey

      Comment

      Working...