Event-RPC
view release on metacpan or search on metacpan
lib/Event/RPC/Server.pm view on Meta::CPAN
SSL encryption is fine, now it's really hard for an attacker to
listen or modify your network communication. But without any further
configuration any user on your network is able to connect to your
server. To prevent this users resp. connections to your server
needs to be authenticated somehow.
Since version 0.87 Event::RPC has an API to delegate authentication
tasks to a module, which can be implemented outside Event::RPC.
To be compatible with prior releases it ships the module
Event::RPC::AuthPasswdHash which implements the old behaviour
transparently.
This default implementation is a simple user/password based model. For now
this controls just the right to connect to your server, so knowing
one valid user/password pair is enough to access all exported methods
of your server. Probably a more differentiated model will be added later
which allows granting access to a subset of exported methods only
for each user who is allowed to connect.
The following options control the authentication:
=over 4
=item B<auth_required>
Set this to 1 to enable authentication and nobody can connect your server
until he passes a valid user/password pair.
=item B<auth_passwd_href>
If you like to use the builtin Event::RPC::AuthPasswdHash module
simply set this attribute. If you decide to use B<auth_module>
(explained beyound) it's not necessary.
B<auth_passwd_href> is a hash of valid user/password pairs. The password
stored here needs to be encrypted using Perl's crypt() function, using
the username as the salt.
Event::RPC has a convenience function for generating such a crypted
password, although it's currently just a 1:1 wrapper around Perl's
builtin crypt() function, but probably this changes someday, so better
use this method:
$crypted_pass = Event::RPC->crypt($user, $pass);
This is a simple example of setting up a proper B<auth_passwd_href> with
two users:
auth_passwd_href => {
fred => Event::RPC->crypt("fred", $freds_password),
nick => Event::RPC->crypt("nick", $nicks_password),
},
=item B<auth_module>
If you like to implement a more complex authentication method yourself
you may set the B<auth_module> attribute to an instance of your class.
For now your implementation just needs to have this method:
$auth_module->check_credentials($user, $pass)
Aware that $pass is encrypted as explained above, so your original
password needs to by crypted using Event::RPC->crypt as well, at
least for the comparison itself.
=back
B<Note:> you can use the authentication module without SSL but aware that
an attacker listening to the network connection will be able to grab
the encrypted password token and authenticate himself with it to the
server (replay attack). Probably a more sophisticated challenge/response
mechanism will be added to Event::RPC to prevent this. But you definitely
should use SSL encryption in a critical environment anyway, which renders
grabbing the password from the net impossible.
=head2 LOGGING OPTIONS
Event::RPC has some logging abilities, primarily for debugging purposes.
It uses a B<logger> for this, which is an object implementing the
Event::RPC::Logger interface. The documentation of Event::RPC::Logger
describes this interface and Event::RPC's logging facilities in general.
=over 4
=item B<logger>
To enable logging just pass such an Event::RPC::Logger object to the
constructor.
=item B<start_log_listener>
Additionally Event::RPC can start a log listener on the server's port
number incremented by 1. All clients connected to this port (e.g. by
using telnet) get the server's log output.
Note: currently the logging port supports neither SSL nor authentication,
so be careful enabling the log listener in critical environments.
=back
=head2 MAINLOOP OPTIONS
Event::RPC derived it's name from the fact that it follows the event
driven paradigm. There are several toolkits for Perl which allow
event driven software development. Event::RPC has an abstraction layer
for this and thus should be able to work with any toolkit.
=over 4
=item B<loop>
This option takes an object of the loop abstraction layer you
want to use. Currently the following modules are implemented:
Event::RPC::Loop::AnyEvent Use the AnyEvent module
Event::RPC::Loop::Event Use the Event module
Event::RPC::Loop::Glib Use the Glib module
If B<loop> isn't set, Event::RPC::Server tries all supported modules
in a row and aborts the program, if no module was found.
( run in 1.390 second using v1.01-cache-2.11-cpan-5623c5533a1 )