John Edwards <[EMAIL PROTECTED]> wrote:
> Thomas, I will give this a try, however I am unclear on the
> 'my $realm' declaration --what exactly am I supposed to put here?
> The protected document is protected by Siteminder, where I have
> to put in a username/password, once this is done I can access
> the protect url.

So you don't get the standard login popup window when
you access your protected URL?

In that case my suggestion would not work.

Do you have Firefox on your machine? I would recommend that you
get it if you don't have it already and that you install the 
"Live HTTP Headers" extension for it.

Using that you can try to figure out how your authentication
works.

With the "standard" HTTP Basic Auth you'd see a response header
from the browser looking like this:

        HTTP/1.x 401 Authorization Required
        Date: Fri, 18 Jul 2008 21:45:22 GMT
        Server: Apache/2.2.3 (Debian)
        WWW-Authenticate: Basic realm="Login required"
        Content-Length: 478
        Keep-Alive: timeout=15, max=100
        Connection: Keep-Alive
        Content-Type: text/html; charset=iso-8859-1

Note the result code 401 which prompts the browser to pop up the
password window. "WWW-Authenticate:" defines the authentication
type to use (Basic) and a realm to go with it. The idea is that
the browser sends the same credentials to protected URLS at the
same site that have the same realm. Anyways, this is what $realm
has to match so that LWP sends the credentials you defined.

Now in your case I suspect that Siteminder uses cookies to
authorize users.
        
This means you'll have to accept and send cookies and track
them between program runs. Lucky for you that's rather easily
done by using

  $ua->cookie_jar({ file => "$ENV{HOME}/.cookies.txt" });

where the file argument is something suitable to your purposes.
(Code above is verbatim from the LWP:UserAgent manpage.)

Then you do a HTTP POST request to your siteminder login page.

Looking at HTTP Live Headers will tell you the required field
names you have to fill in, if you can't parse them from the
login page's HTML.

The basic pattern is

  my $login_response = $ua->post( $loginurl, [ name => 'john', password => 
'***' ] );

and then you have to check the response to see wether your login
was successful.

After that you request your protected page.

An advanced implementation would go to the protected page directly
and parse the response to see wether a relogin is required or
wether your site worked or not. If your login cookies had expired,
you would then post your credentials to siteminder and try again.

HTH,
Thomas

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


  • LWP wls . admin
    • RE: LWP Thomas Bätzler
    • RE: LWP Thomas Bätzler

Reply via email to