Login to reil.com

REIL.com uses digest authentication. I am using perl to pull down the data so first I need to login to the reil.com server with proper authorization. I was unable to find a lot of documentation on how this process works. The usual method for exposing web services is via SOAP, but this service uses HTTP Digest Authentication. I have not used it much but it appears that the main benefit is not sending the password in clear text over a non-ssl connection. It is not as secure as SSL by any means but is better than a clear text transmission of the password.

The process appeared daunting at first, due to the lack of examples and documentation. The process was clear, attempt login to the server, the server rejects the login and requires login and finally the user sends validation. There are fields in the response header sent by the server that are used in the last step authentication.

What was not clear to me is how LWP::UserAgent to perform this feat. I could see that the mechanism was in LWP::Authen::Digest – authenticate, but i wasn’t sure how to access it. The docs mentioned overriding LWP:UserAgent’s get_basic_credentials sub to supply a password.


#!/usr/bin/perl
package RequestAgent;
@ISA = qw(LWP::UserAgent);
use strict;
use LWP::UserAgent;
sub new {
my $self = LWP::UserAgent::new(@_);
$self->agent("lwp-request/$main::VERSION");
$self;
}
sub get_basic_credentials{
my($self, $realm, $uri) = @_;
return('myUsername','myPassword');
}
So once this module was created, I just used the following code and everything worked as it was supposed to.

Leave a Reply

You must be logged in to post a comment.