LWP and Digest authentication

LWP and Digest authentication

am 08.02.2007 19:50:08 von earwigtc

Hi all. I must be missing something here. Is LWP supposed to
automatically deal with digest authentication? I run the following
code (used often with basic auth) against a server requiring digest,
and continue to get 401s:

my $ua = new LWP::UserAgent;
my $h = HTTP::Headers->new();
$h->authorization_basic('user','password');
my $req = HTTP::Request->new('GET', 'http://the.website.com',
$h);
my $res = $ua->request($req);

A sniff shows only one attempt to login, and no reaction to the fact
that the server returned a WWW-Authenticate header with the real,
nonce, etc. Do I need to call requests a different way to get the
auto-magical behavior? I'm using htis format because of other needs
(custom headers later).

Since I can't find any discussion or example of digest instead of
basic, I figured it should work. Or do I need to do all the digest
legwork myself?

Thanks.

Re: LWP and Digest authentication

am 09.02.2007 13:42:56 von Peter Scott

On Thu, 08 Feb 2007 10:50:08 -0800, earwigtc wrote:
> Hi all. I must be missing something here. Is LWP supposed to
> automatically deal with digest authentication? I run the following
> code (used often with basic auth) against a server requiring digest,
> and continue to get 401s:
>
> my $ua = new LWP::UserAgent;
> my $h = HTTP::Headers->new();
> $h->authorization_basic('user','password');
> my $req = HTTP::Request->new('GET', 'http://the.website.com',
> $h);
> my $res = $ua->request($req);

I don't know what your problem is here or whether my suggestion will make
any difference, but I will point out that the new credentials() method I
added to WWW::Mechanize (1.20 and later) would make your code considerably
simpler:

my $mech = WWW::Mechanize->new;
$mech->credentials('user', 'password');
$mech->get('https://the.website.com/');

> A sniff shows only one attempt to login, and no reaction to the fact
> that the server returned a WWW-Authenticate header with the real,
> nonce, etc. Do I need to call requests a different way to get the
> auto-magical behavior? I'm using htis format because of other needs
> (custom headers later).

You would be able to do this with $mech->add_header.

> Since I can't find any discussion or example of digest instead of
> basic, I figured it should work. Or do I need to do all the digest
> legwork myself?

--
Peter Scott
http://www.perlmedic.com/
http://www.perldebugged.com/

Re: LWP and Digest authentication

am 09.02.2007 17:39:50 von earwigtc

I like it. I'm saving info (such as headers_as_string) of the request
object for debugging. I see $mech->response, but is there a way to
reference the request object? Never had to do it with just a
LWP::UserAgent object. Aside from that, I can rework using
WWW::Mechanize just fine.

I would still be interested in a working digest authentication example
with LWP directly, if anyone has one.

Earwig


On Feb 9, 7:42 am, Peter Scott wrote:
> On Thu, 08 Feb 2007 10:50:08 -0800, earwigtc wrote:
> > Hi all. I must be missing something here. Is LWP supposed to
> > automatically deal with digest authentication? I run the following
> > code (used often with basic auth) against a server requiring digest,
> > and continue to get 401s:
>
> > my $ua = new LWP::UserAgent;
> > my $h = HTTP::Headers->new();
> > $h->authorization_basic('user','password');
> > my $req = HTTP::Request->new('GET', 'http://the.website.com',
> > $h);
> > my $res = $ua->request($req);
>
> I don't know what your problem is here or whether my suggestion will make
> any difference, but I will point out that the new credentials() method I
> added to WWW::Mechanize (1.20 and later) would make your code considerably
> simpler:
>
> my $mech = WWW::Mechanize->new;
> $mech->credentials('user', 'password');
> $mech->get('https://the.website.com/');
>
> > A sniff shows only one attempt to login, and no reaction to the fact
> > that the server returned a WWW-Authenticate header with the real,
> > nonce, etc. Do I need to call requests a different way to get the
> > auto-magical behavior? I'm using htis format because of other needs
> > (custom headers later).
>
> You would be able to do this with $mech->add_header.
>
> > Since I can't find any discussion or example of digest instead of
> > basic, I figured it should work. Or do I need to do all the digest
> > legwork myself?
>
> --
> Peter Scotthttp://www.perlmedic.com/http://www.perldebugged.com/

Re: LWP and Digest authentication

am 10.02.2007 13:51:14 von Peter Scott

On Fri, 09 Feb 2007 08:39:50 -0800, earwigtc wrote:
> I like it. I'm saving info (such as headers_as_string) of the request
> object for debugging. I see $mech->response, but is there a way to
> reference the request object? Never had to do it with just a
> LWP::UserAgent object. Aside from that, I can rework using
> WWW::Mechanize just fine.

http://search.cpan.org/~gaas/libwww-perl-5.805/lib/HTTP/Resp onse.pm:

$r->request
$r->request( $request )
This is used to get/set the request attribute. The request attribute is a
reference to the the request that caused this response. It does not have
to be the same request passed to the $ua->request() method, because there
might have been redirects and authorization retries in between.

--
Peter Scott
http://www.perlmedic.com/
http://www.perldebugged.com/

newbie PPM question

am 26.02.2007 16:05:50 von Paul Mitchell

Hello,
Not new to using Perl, but new to trying to install it and use it on a
Windows NT platform. Doing this in order to load Andy Duncans Oracle/Perl
modules. Got PPM running and want, basically to do as follows:

ppm install PDBA

According to the instructions, entering "ppm" should give me a
commandline. It doesn't, I get a GUI interface. OK. UNfortunately, search
seems to direct me only to the ActiveState repositories.

How do I get to either the command line PPM, or direct the GUI to look
inthe current directory and not up at ActiveState?

Thanks for any help,

Paul Mitchell

Re: newbie PPM question

am 27.02.2007 04:17:03 von Petr Vileta

"Paul Mitchell" píse v diskusním príspevku
news:Pine.GSO.4.63+UNC.0702261003020.6834@watson.isis.unc.ed u...
> Hello,
> Not new to using Perl, but new to trying to install it and use it on a
> Windows NT platform. Doing this in order to load Andy Duncans Oracle/Perl
> modules. Got PPM running and want, basically to do as follows:
>
> ppm install PDBA
>
> According to the instructions, entering "ppm" should give me a
> commandline. It doesn't, I get a GUI interface. OK. UNfortunately, search
> seems to direct me only to the ActiveState repositories.
>
> How do I get to either the command line PPM, or direct the GUI to look
> inthe current directory and not up at ActiveState?
>
Somewhere in your perl directory you have ppm3.bat so start it and type
help repository

--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)

Re: newbie PPM question

am 01.03.2007 20:30:36 von Paul Mitchell

On Tue, 27 Feb 2007, Petr Vileta wrote:

> Somewhere in your perl directory you have ppm3.bat so start it and type
> help repository

Hello Petr,
I've done some reading on the net an dppm3 looks promising,
unfortunately, the only related files I have to it are both called:

configPPM3.pl

can I generate the programe with this file, or is there some repsository
where I can download it from?

Paul Mitchell

============================================================ ==================
Paul Mitchell
email: pmitchel@email.unc.edu
phone: (919) 962-9778
office: I have an office, room 14, Phillips Hall
============================================================ ==================

Re: newbie PPM question

am 02.03.2007 01:41:35 von Petr Vileta

"Paul Mitchell" píse v diskusním príspevku
news:Pine.GSO.4.63+UNC.0703011424120.6775@sunny...
> On Tue, 27 Feb 2007, Petr Vileta wrote:
>
>> Somewhere in your perl directory you have ppm3.bat so start it and type
>> help repository
>
> Hello Petr,
> I've done some reading on the net an dppm3 looks promising,
> unfortunately, the only related files I have to it are both called:
>
> configPPM3.pl
>
> can I generate the programe with this file, or is there some repsository
> where I can download it from?
>
Sorry I don't know. I use old ActivePerl 5.6.1.

--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)

Re: newbie PPM question

am 02.03.2007 21:37:54 von Paul Mitchell

On Fri, 2 Mar 2007, Petr Vileta wrote:

> Sorry I don't know. I use old ActivePerl 5.6.1.


Hello Petr,
ActiveState was kind enough to get back to me. I was able to get the ppm
module to look locally after mucking with it some, bu I must have the
wrong module:

ppm install failed: The PPD does not provide code to install for this
platform.

which is curious (this is a T60 Running Windows XP):


PDBA
Perl DBA toolkit for Oracle DBA's
Jared Still/Andy Duncan (http://www.oreilly.com/catalog/oracleperl/pdbatoolkit)





















I bet the x86 is for an AMD Opteron environment and not my box.

Paul Mitchell
============================================================ ==================
Paul Mitchell
email: pmitchel@email.unc.edu
phone: (919) 962-9778
office: I have an office, room 14, Phillips Hall
============================================================ ==================


On Thu, 1 Mar 2007, ActiveState Support wrote:

> Hi Paul,
>
> Thanks for your email.
>
> The latest ActivePerl uses PPM version 4, which is just called "ppm" in that
> release. The trick with getting PPM to use a local PPD file is to give the
> path to the PPD file as a URL, for example:
>
> ppm install file:///C:/temp/Acme-Bleach.ppd
>
> Let me know if you have any further questions or comments.
>
> best regards,
>
> Kevin Woolley
> Technical Support Engineer
> ActiveState - Dynamic Tools for Dynamic Languages
> http://www.ActiveState.com
>
> Paul Mitchell wrote:
>
>> I've downloaded the ActiveState ActivePerl in order to load the
>> Oracle/Perl modules from Andy Duncan. I'm a Solaris administrator, but I'm
>> using a windows NT box (which I know little about!^).
>>
>> I have ppm, but it seems unable to access the PDBA.ppd file stored locally
>> on my disk - it seems only to want to go to ActiveState.
>>
>> Various folks (and much documentation) on the net have told me to use
>> ppm3. I can see the documentation for this on your site, but I cannot
>> find this module anywhere!
>>
>> It's not in the ActivePerl which O've downloaded - where can this module
>> be found?
>>
>> Thanks for any advice,
>>
>> Paul Mitchell
>>
>> ============================================================ ==================
>> Paul Mitchell
>> email: pmitchel@email.unc.edu
>> phone: (919) 962-9778
>> office: I have an office, room 14, Phillips Hall
>> ============================================================ ==================
>>
>
>