Get the vhost info in auth module
Martin Atkins
mart at degeneration.co.uk
Tue Jul 28 15:44:35 UTC 2009
Rohan Almeida wrote:
>
> In My/Auth.pm
>
> sub check_cleartext {
> my ($self, $cb, %args) = @_;
> my $username = $args{username};
> my $password = $args{password};
> my $conn = $args{conn};
>
> }
>
> So I get the username, password and the $conn ISA
> DJabberd::Connection::ClientIn
>
> I can see that I get all the vhosts using:
>
> my $vhosts = $conn->server->vhosts;
>
> but how I do know which vhost is currently connecting?
>
Although it's not passed into the check methods, the vhost is passed
into the "register" method, so you could override that and stash the
result in your plugin object like this:
sub register {
my ($self, $vhost) = @_;
$self->SUPER::register($vhost);
$self->{__my_auth_vhost} = $vhost;
}
Since you get a separate instance of a plugin for each <Plugin>
declaration in the config file it's okay to tie your instance to the
vhost like this, as long as you make it an instance property rather than
a global.
More information about the Djabberd
mailing list