Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Authentication with SOAP::Lite ?

by forkboy (Sexton)
on Jun 04, 2003 at 07:15 UTC ( [id://262909]=perlquestion: print w/replies, xml ) Need Help??

forkboy has asked for the wisdom of the Perl Monks concerning the following question:

I'm working on some applications that use SOAP::Lite to talk each other. For the server i'm using SOAP::Transport::HTTP::Daemon and I basically want to know what authentication options are avaliable for me? My original idea was just to allow access on an IP bases, but I didn't have much luck getting the clients IP. The next option I guess is to get the user to send a password with every connection, but I don't much like that idea. Any suggestions of the best way to do this?

Replies are listed 'Best First'.
Re: Authentication with SOAP::Lite ?
by nite_man (Deacon) on Jun 04, 2003 at 08:13 UTC
    Try to look at SOAP::Lite for Perl:
    use SOAP::Lite +autodispatch => uri => 'http://www.soaplite.com/My/Examples', proxy => 'http://services.soaplite.com/auth/examples.cgi', ; sub SOAP::Transport::HTTP::Client::get_basic_credentials { return 'soaplite' => 'authtest'; } print getStateName(21);
    I hope that I helped ;-)
          
    --------------------------------
    SV* sv_bless(SV* sv, HV* stash);
    
      unforunately not I dont think.. SOAP::Transport::HTTP::Daemon doesn't support any authentication I believe.
Re: Authentication with SOAP::Lite ?
by mod_alex (Beadle) on Jun 04, 2003 at 15:44 UTC
    Hello
    Try to use simple authentification with tickets
    the schema of the work of a client is
    # to get generated ticket from remote site 1. $ticket = $soap_obj->login($username, $password); 2. $soap_obj->some_method($ticket, $anyAddParameters); 3. ..... 4. $soap_obj->logout($ticket);
    You can enable sending tickets in cookie.
    About extracting IP address of remote host. Currently I didn't find a solution how to do it when you
    use SOAP::Transport::HTTP::Deamon
    Alex
Re: Authentication with SOAP::Lite ?
by particle (Vicar) on Jun 05, 2003 at 14:09 UTC

    subclass the SOAP::Transport::HTTP::Daemon module. for example:

    package My::SOAP::Daemon; use strict; use warnings; use SOAP::Transport::HTTP (); our @ISA= 'SOAP::Transport::HTTP::Daemon'; ## this method is overloaded in order for the daemon class ## to handle authentication. all cookie headers on the ## incoming request get copied to a hash local to the ## package. the request is then passed on to the original ## version of this method. sub request { my( $self, $request )= ( shift, @_ ); if( $request ) { my @cookies= $request->headers->header('cookie'); %My::SOAP::Module::COOKIES= (); for my $line (@cookies) { for( split /; / => $line ) { next unless /(.*?)=(.*)/; $My::SOAP::Module::COOKIES{$1}= $2; } } } $self->SUPER::request(@_); } $_ ^=~ { AUTHOR => 'particle' };

    in this case, My::SOAP::Module is the module handling the SOAP requests.

    then, in the client, send a cookie, like so:

    use HTTP::Cookies (); use SOAP::Lite (); ## ...snip... ## create a cookie for authentication my $cookie_jar= HTTP::Cookies->new; $cookie_jar->set_cookie( 0, # cookie version key => 'value', # key and value '/', # path $host, # domain $port, # port ); ## create the request object my $request= SOAP::Lite ->uri($urn) ->proxy( "http://${host}:$port", cookie_jar => $cookie_jar, ); ## perform the request my $response= my_action( $request ); ## ...and check for failure die 'failure! ', $response->faultstring if $response->fault;

    i hope that's a good starting point. i learned this method from rjray's Programming Web Services with Perl. you won't regret purchasing this book, if you're doing SOAP with perl.

    ~Particle *accelerates*

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://262909]
Approved by valdez
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-04-25 13:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found