line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::Milter::Authentication::Handler::Auth; |
2
|
27
|
|
|
27
|
|
13505
|
use strict; |
|
27
|
|
|
|
|
82
|
|
|
27
|
|
|
|
|
771
|
|
3
|
27
|
|
|
27
|
|
155
|
use warnings; |
|
27
|
|
|
|
|
70
|
|
|
27
|
|
|
|
|
765
|
|
4
|
27
|
|
|
27
|
|
133
|
use base 'Mail::Milter::Authentication::Handler'; |
|
27
|
|
|
|
|
72
|
|
|
27
|
|
|
|
|
3151
|
|
5
|
|
|
|
|
|
|
our $VERSION = '20191206'; # VERSION |
6
|
|
|
|
|
|
|
|
7
|
27
|
|
|
27
|
|
184
|
use Sys::Syslog qw{:standard :macros}; |
|
27
|
|
|
|
|
69
|
|
|
27
|
|
|
|
|
7564
|
|
8
|
27
|
|
|
27
|
|
207
|
use Mail::AuthenticationResults::Header::Entry; |
|
27
|
|
|
|
|
64
|
|
|
27
|
|
|
|
|
754
|
|
9
|
27
|
|
|
27
|
|
151
|
use Mail::AuthenticationResults::Header::SubEntry; |
|
27
|
|
|
|
|
63
|
|
|
27
|
|
|
|
|
629
|
|
10
|
27
|
|
|
27
|
|
161
|
use Mail::AuthenticationResults::Header::Comment; |
|
27
|
|
|
|
|
64
|
|
|
27
|
|
|
|
|
11062
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub default_config { |
13
|
1
|
|
|
1
|
0
|
1243
|
return {}; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub grafana_rows { |
17
|
1
|
|
|
1
|
0
|
3335
|
my ( $self ) = @_; |
18
|
1
|
|
|
|
|
2
|
my @rows; |
19
|
1
|
|
|
|
|
7
|
push @rows, $self->get_json( 'Auth_metrics' ); |
20
|
1
|
|
|
|
|
4
|
return \@rows; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub register_metrics { |
24
|
|
|
|
|
|
|
return { |
25
|
26
|
|
|
26
|
1
|
135
|
'authenticated_connect_total' => 'The number of connections from an authenticated host', |
26
|
|
|
|
|
|
|
}; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub pre_loop_setup { |
30
|
26
|
|
|
26
|
0
|
74
|
my ( $self ) = @_; |
31
|
26
|
|
|
|
|
105
|
my $protocol = Mail::Milter::Authentication::Config::get_config()->{'protocol'}; |
32
|
26
|
100
|
|
|
|
108
|
if ( $protocol ne 'milter' ) { |
33
|
13
|
|
|
|
|
225
|
warn 'The Auth handler only works with the milter protocol'; |
34
|
|
|
|
|
|
|
} |
35
|
26
|
|
|
|
|
100
|
return; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub get_auth_name { |
39
|
70
|
|
|
70
|
0
|
238
|
my ($self) = @_; |
40
|
70
|
|
|
|
|
414
|
my $name = $self->get_symbol('{auth_authen}'); |
41
|
70
|
|
|
|
|
243
|
return $name; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub connect_callback { |
45
|
70
|
|
|
70
|
0
|
249
|
my ( $self, $hostname, $ip ) = @_; |
46
|
70
|
|
|
|
|
405
|
$self->{'is_authenticated'} = 0; |
47
|
70
|
|
|
|
|
229
|
return; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub envfrom_callback { |
51
|
70
|
|
|
70
|
0
|
240
|
my ( $self, $env_from ) = @_; |
52
|
70
|
|
|
|
|
324
|
my $auth_name = $self->get_auth_name(); |
53
|
70
|
100
|
|
|
|
282
|
if ($auth_name) { |
54
|
1
|
|
|
|
|
8
|
$self->dbgout( 'AuthenticatedAs', $auth_name, LOG_INFO ); |
55
|
|
|
|
|
|
|
# Clear the current auth headers ( iprev and helo may already be added ) |
56
|
|
|
|
|
|
|
# ToDo is this a good idea? |
57
|
1
|
|
|
|
|
3
|
my $top_handler = $self->get_top_handler(); |
58
|
1
|
|
|
|
|
3
|
$top_handler->{'c_auth_headers'} = []; |
59
|
1
|
|
|
|
|
3
|
$top_handler->{'auth_headers'} = []; |
60
|
1
|
|
|
|
|
2
|
$self->{'is_authenticated'} = 1; |
61
|
1
|
|
|
|
|
7
|
$self->metric_count( 'authenticated_connect_total' ); |
62
|
1
|
|
|
|
|
10
|
my $header = Mail::AuthenticationResults::Header::Entry->new()->set_key( 'auth' )->safe_set_value( 'pass' ); |
63
|
1
|
|
|
|
|
78
|
$self->add_auth_header( $header ); |
64
|
|
|
|
|
|
|
} |
65
|
70
|
|
|
|
|
222
|
return; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub close_callback { |
69
|
104
|
|
|
104
|
0
|
309
|
my ( $self ) = @_; |
70
|
104
|
|
|
|
|
297
|
delete $self->{'is_authenticated'}; |
71
|
104
|
|
|
|
|
576
|
return; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__END__ |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=pod |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=encoding UTF-8 |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 NAME |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Mail::Milter::Authentication::Handler::Auth |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 VERSION |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
version 20191206 |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 DESCRIPTION |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Module which identifies email that was sent via an authenticated connection. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 CONFIGURATION |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
No configuration options exist for this handler. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 AUTHOR |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Marc Bradshaw <marc@marcbradshaw.net> |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
This software is copyright (c) 2018 by Marc Bradshaw. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
107
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |