[Catalyst] XML RPC : Authentication and Session

Nicolas Raspail nicolas at whisperingvault.net
Fri Aug 24 14:11:23 GMT 2007


I'm new in the Catalyst World and I'm trying to make my first app with  
it. But I have a
problem with the session.

I'm building an XML RPC server, and I want the users to be  
authenticated before using
some commands. So I have created a controller (XMLRPC.pm) with the  
script and I have
specified some commands iwth XMLRPCGlobal.

At the beginning, the user must issue an RPC command named host_login,  
sending the
username and the password. If the user exists, the function returns  
the sessionid that
have been created after the authentification. this sessionid will be  
passed in argument
in the next commands. But, that doesn't seem to work like this.

Here is how I have implemented my RPC command :

sub host_login : XMLRPCGlobal {
         my ($self, $c, @args) = @_;

         my $username = $args[0];
         my $password = $args[1];

         if ($c->authenticate({username => $username, password =>  
$password})) {
                 $c->stash->{xmlrpc} = $c->sessionid;
         } else {
                 $c->stash->{xmlrpc} = 'KO';

But I don't know how to use this sessionid. If in an another RPC  
command, I call
$c->session, it creates a new session, as if there is no more any  
session present.

So, my question is how I can return a sessionid (or anything else)  
from a fisrt rpc
command that authenticate the users, and use it in other commands to  
avoid sending again
the username/password.




More information about the Catalyst mailing list