Discussion:
LWP::UserAgent credentials netloc and realm
(too old to reply)
John Stumbles
2005-05-27 17:56:17 UTC
Permalink
Googling for how to get this to work I found that I'm not the only one to
have difficulties. I eventually found the answer at
http://groups-beta.google.com/group/comp.lang.perl.misc/browse_frm/thread/5cf8c33182974059/

Summary: you have to include the port no in the 'netloc' variable e.g.
credentials("http://abc.com:80", "realm", "uname", "passwd");

The other thing that threw a lot of people, including me, was what exactly
'netloc' and 'realm' are. 'realm' is whatever the server is configured to
ask you e.g. "Enter username and password for foo at abc.com".

It would be nice to have this explained in the docs but as a 2nd best I hope
this will come up closer to the top of a google search for anyone asking in
future.
J. Gleixner
2005-05-27 18:50:02 UTC
Permalink
Post by John Stumbles
Googling for how to get this to work I found that I'm not the only one to
have difficulties. I eventually found the answer at
http://groups-beta.google.com/group/comp.lang.perl.misc/browse_frm/thread/5cf8c33182974059/
Summary: you have to include the port no in the 'netloc' variable e.g.
Port no, no. Port number, yes. :-)
Post by John Stumbles
credentials("http://abc.com:80", "realm", "uname", "passwd");
The other thing that threw a lot of people, including me, was what exactly
'netloc' and 'realm' are. 'realm' is whatever the server is configured to
ask you e.g. "Enter username and password for foo at abc.com".
FYI:

The realm is only the "foo" part, in your example, and is typically
(always?) displayed in the authentication window enclosed by double quotes.

Take a look at the server's response header. The realm information is
returned as WWW-Authenticate. e.g.

WWW-Authenticate: Basic realm="realm info here"

The authentication window would then read:

Enter username and password for "realm info here" at my.host.com.
Post by John Stumbles
It would be nice to have this explained in the docs but as a 2nd best I hope
this will come up closer to the top of a google search for anyone asking in
future.
John Stumbles
2005-05-28 16:04:21 UTC
Permalink
---8<---
snip info on authentication (and ditto Alan J. Flavell's post, for which
many thanks).

The point I'm trying to make is that I'm sure I'm not the only person for
whom Life Is Too Short(tm) to get into deep understanding of all the
protocols and specifications involved, which is one reason I like Perl and
Perl modules, because they let me get things done quickly and easily
without having to understand, let alone code, all the tricky stuff.

Don't get me wrong, I agree that the docs should have pointers to the
reference info such as RFCs, but it's also very helpful to have useful
examples of how, typically, to do the sorts of things one might want to do
with the module. In my case I just wanted to get my IP address from my DSL
router, and I needed to get past its authentication mechanism to do so. I
don't _want_ to know any more about authentication (right now: I might in
the future and I'll come back to your informative posts for info when and
if I need that).

regards

Alan J. Flavell
2005-05-27 19:15:02 UTC
Permalink
Post by John Stumbles
The other thing that threw a lot of people, including me, was what
exactly 'netloc' and 'realm' are.
"realm" is a technical term defined in the Basic Authentication
specification. What you're providing here is Basic Authentication.
I'd say that fits the requirements.
Post by John Stumbles
'realm' is whatever the server is configured to
ask you e.g. "Enter username and password for foo at abc.com".
*If* that's what the realm was configured to be at the server.
Post by John Stumbles
It would be nice to have this explained in the docs
The trouble with providing alternative specifications is that they
risk coming out inaccurately. I'd prefer a reference to the relevant
RFC, which currently would be 2617 I think.

There's a reasonable presentation of the server-side issues at the
Apache server web site.
Loading...