DJabberd/SASL/AuthenSASL.pm untested

filter: Statementstmt 0.0% 0 / 31 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 4 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 50 CC 4 SCAR 23.0
CC
4
Cov
0%
register
20.0
set_config_mechanisms
2.0
mechanisms
2.0
CRAP 10.0
1 package DJabberd::SASL::AuthenSASL;
2  
3 use strict;
4 use warnings;
5 use base qw/DJabberd::SASL/;
6  
7 sub set_config_mechanisms {
8 my ($self, $val) = @_;
9 $self->{mechanisms} = { map { uc $_ => 1 } split /\s+/, ($val || "") };
10 }
11  
12 sub mechanisms {
13 my $plugin = shift;
14 return $plugin->{mechanisms} || {};
15 }
16  
17 sub register {
18 my ($plugin, $vhost) = @_;
19 $plugin->SUPER::register($vhost);
20  
21 $vhost->register_hook("SendFeatures", sub {
22 my ($vh, $cb, $conn) = @_;
23 if (my $sasl_conn = $conn->sasl) {
24 if ($sasl_conn->is_success) {
25 return;
26 }
27 }
28 my @mech = $plugin->mechanisms_list;
29 my $xml_mechanisms =
30 "<mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>";
31 $xml_mechanisms .= join "", map { "<mechanism>$_</mechanism>" } @mech;
32 $xml_mechanisms .= "<optional/>" if $plugin->is_optional;
33 $xml_mechanisms .= "</mechanisms>";
34 $cb->stanza($xml_mechanisms);
35 });
36 }
37  
38 1;
39  
40 __END__
41  
42 =head1 NAME
43  
44 DJabberd::SASL::AuthenSASL - SASL Negotiation using Authen::SASL
45  
46 =head1 DESCRIPTION
47  
48 This plugin provides straightforward support for SASL negotiations inside
49 DJabberd using L<Authen::SASL> (Authen::SASL::Perl, for now). It compliments
50 the now deprecated I<iq-auth> authentication (XEP-0078).
51  
52 The recommended usage is to use STARTTLS and SASL-PLAIN.
53  
54 =head1 SYNOPSIS
55  
56 <VHost yann.cyberion.net>
57 <Plugin DJabberd::SASL::AuthenSASL>
58 Optional yes
59 Mechanisms PLAIN LOGIN DIGEST-MD5
60 </Plugin>
61 </VHost>
62  
63 =head1 DESCRIPTION
64  
65 Only PLAIN LOGIN and DIGEST-MD5 mechanisms are supported for now (same than
66 in L<Authen::SASL>. DIGEST-MD5 only supports C<auth> qop (quality of
67 protection), so it's strongly advised to throw TLS into the mix, and not
68 solely rely on DIGEST-MD5 (as opposed to C<auth-int> and C<auth-conf>).
69  
70 =head1 COPYRIGHT
71  
72 (c) 2009 Yann Kerherve
73  
74 This module is part of the DJabberd distribution and is covered by the
75 distribution's overall licence.
76  
77 =cut
78  
79 # Local Variables:
80 # mode: perl
81 # c-basic-indent: 4
82 # indent-tabs-mode: nil
83 # End: