Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi
I like to create a hyperlink on my website that takes the user to another website, logging automatically.

So I like to make 'http://mysite/goto.pl?url=http://otherwebsite/deeplink.html'. Now, the otherwebsite needs username/password, which I have and like to control in 'goto.pl'. I do not want to show username/password openly. Encrypted version may be ok. How do I accomplish this?

Thank you.

Replies are listed 'Best First'.
Re: Go to Website that requires Login
by bart (Canon) on Nov 20, 2006 at 19:40 UTC
    I don't think you can. You could provide a proxy on your site, that does the actual request on the other site and passes the result back to your browser.

    There has been a user here, ant9000, who did something for Perlmonks, for a Ajax based Chatterbox client. The proxy is still alive: http://www.netwise.it/xml/perlmonks/.

    Since then, this user has disappeared.

Re: Go to Website that requires Login
by nedals (Deacon) on Nov 21, 2006 at 00:26 UTC

    If I understand your question correctly, sounds like LWP will solve your problem.

    ## http://mysite/goto.pl ## use strict; use LWP::UserAgent; my $url = 'http://otherwebsite/deeplink.html'; my $ua = LWP::UserAgent->new; my $response = $ua->post( $url, [username=>'username', password=>'password'], ); if ($response->is_success) { my $deeplink = $response->content; print $deeplink; } else { my $errmsg = $response->status_line; .... }
      I like to have user goto other site, rather than print the cotent of that site even in frames. Such is the case, because othersite want to do something with user login.
Re: Go to Website that requires Login
by jonadab (Parson) on Nov 20, 2006 at 22:38 UTC
    I do not want to show username/password openly.

    Define "openly".

    If you need the user's web browser to retrieve the password-protected content from the password-protected site, then the user's web browser has to have the username and password, so ipso facto the user has the ability to see it as well.

    There are various cheap tricks you can pull to (try to) conceal this fact from users who don't understand computer networks very well, but fundamentally the information will be _available_ to the user, and any user who knows the difference between an HTTP header and a document head element is going to be able to figure it out. If that's good enough for your purposes, say so, because otherwise most people on here are going to assume it's probably not.

    If you need the user to see the password-protected content but _not_ be able to see the username and password, then the content needs to be retrieved from the password-protected server not by the user's web browser but by a system beyond the user's control, such as your website.


    Sanity? Oh, yeah, I've got all kinds of sanity. In fact, I've developed whole new kinds of sanity. You can just call me "Mister Sanity". Why, I've got so much sanity it's driving me crazy.
Re: Go to Website that requires Login
by sgifford (Prior) on Nov 21, 2006 at 05:27 UTC
    As others have said, with no special support on the other site, the only way to do exactly what you describe is to use a proxy. This is actually pretty easy with a little bit of mod_perl.

    It's possible the other Web site implements a special way of doing this, such as passing along an encrypted string or temporary authentication token. You could ask the site's maintainer if there are any options for that. If you are the maintainer of both sites, you could implement something special you can pass instead of a password that will be enough for authentication.

Re: Go to Website that requires Login
by madbombX (Hermit) on Nov 20, 2006 at 18:55 UTC
    Have you considered CGI and using a POST method instead of a GET method to send your variables?

    You may want to check out ovid's tutorial Web Programming Using Perl.