470,638 Members | 1,577 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,638 developers. It's quick & easy.

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_authentication';

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
Jul 19 '05 #1
2 4722
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 xxxxxxxxxxxxxxxxxxxxxxx

I used the authorization_basic( $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
Jul 19 '05 #2
> Authorization: Basic xxxxxxxxxxxxxxxxxxxxxxx

I used the authorization_basic( $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.

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
Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Damo | last post: by
5 posts views Thread by Simon | last post: by
6 posts views Thread by Omid | last post: by
6 posts views Thread by Sam | last post: by
8 posts views Thread by Andreas Klemt | last post: by
22 posts views Thread by Platero | last post: by
12 posts views Thread by gigi | last post: by
18 posts views Thread by Paul Lautman | last post: by
1 post views Thread by Korara | last post: by
???
1 post views Thread by Stoney L | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.