Authentication and Perl

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Authentication and Perl

Ulrike Schmidt
Does someone have example code for authentication with Perl using the
REST Style API?

I tried the credentials method of LWP::UserAgent, but it did not work. I
put "" als realm, since I could not find one.

Uli





-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|

Re: Authentication and Perl

Michael Beddow-2


> Does someone have example code for authentication with Perl using the
> REST Style API?
>

Ich bin dieser Jemand...

I suspect the realm would be "exist" as it is for WEBDAV, but it shouldn't
be needed (http uses it only to remind a human client of what the
authentication domain is, machines are supposed to know already)

  my $ua = LWP::UserAgent->new();
  my $req = HTTP::Request->new(POST => $URL);
  $req->content_type('text/xml');
  $req->content($QUERY);
  $req->authorization_basic('guest', 'guest');
  my $res = $ua->request($req);

That should have no visible effect, because it apes the defaults eXist
assumes if it sees no basic authentication credentials on the request.

But make that

$req->authorization_basic('worble', 'blort');

and the REST server will answer back

Error: 403 Permission denied: unknown user or password


Michael Beddow



-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|

Re: Authentication and Perl

Ulrike Schmidt
Michael Beddow wrote:

>I suspect the realm would be "exist" as it is for WEBDAV, but it shouldn't
>be needed (http uses it only to remind a human client of what the
>authentication domain is, machines are supposed to know already)
>
I had no luck with the credentials method of LWP::UserAgent using
"exist" as realm.

>  my $ua = LWP::UserAgent->new();
>  my $req = HTTP::Request->new(POST => $URL);
>  $req->content_type('text/xml');
>  $req->content($QUERY);
>  $req->authorization_basic('guest', 'guest');
>  my $res = $ua->request($req);
>
But the authorization_basic method works wonderfully, thanks a lot!

Uli



-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open