| DJabberd documentation | Contained in the DJabberd distribution. |
DJabberd::SASL::AuthenSASL - SASL Negotiation using Authen::SASL
This plugin provides straightforward support for SASL negotiations inside DJabberd using Authen::SASL (Authen::SASL::Perl, for now). It compliments the now deprecated iq-auth authentication (XEP-0078).
The recommended usage is to use STARTTLS and SASL-PLAIN.
<VHost yann.cyberion.net>
<Plugin DJabberd::SASL::AuthenSASL>
Optional yes
Mechanisms PLAIN LOGIN DIGEST-MD5
</Plugin>
</VHost>
Only PLAIN LOGIN and DIGEST-MD5 mechanisms are supported for now (same than
in Authen::SASL. DIGEST-MD5 only supports auth qop (quality of
protection), so it's strongly advised to throw TLS into the mix, and not
solely rely on DIGEST-MD5 (as opposed to auth-int and auth-conf).
(c) 2009 Yann Kerherve
This module is part of the DJabberd distribution and is covered by the distribution's overall licence.
| DJabberd documentation | Contained in the DJabberd distribution. |
package DJabberd::SASL::AuthenSASL; use strict; use warnings; use base qw/DJabberd::SASL/; sub set_config_mechanisms { my ($self, $val) = @_; $self->{mechanisms} = { map { uc $_ => 1 } split /\s+/, ($val || "") }; } sub mechanisms { my $plugin = shift; return $plugin->{mechanisms} || {}; } sub register { my ($plugin, $vhost) = @_; $plugin->SUPER::register($vhost); $vhost->register_hook("SendFeatures", sub { my ($vh, $cb, $conn) = @_; if (my $sasl_conn = $conn->sasl) { if ($sasl_conn->is_success) { return; } } my @mech = $plugin->mechanisms_list; my $xml_mechanisms = "<mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>"; $xml_mechanisms .= join "", map { "<mechanism>$_</mechanism>" } @mech; $xml_mechanisms .= "<optional/>" if $plugin->is_optional; $xml_mechanisms .= "</mechanisms>"; $cb->stanza($xml_mechanisms); }); } 1; __END__
# Local Variables: # mode: perl # c-basic-indent: 4 # indent-tabs-mode: nil # End: