[Rt-commit] rt branch, 4.4/multiple-reply-to, repushed
? sunnavy
sunnavy at bestpractical.com
Tue Oct 7 12:27:11 EDT 2014
The branch 4.4/multiple-reply-to was deleted and repushed:
was 201968703385a2f6c34a1fe9b2b73c0417fb37bd
now bb9337cdac4aba19b22c0ca00b888993d98707be
1: 15a0c3b = 1: 15a0c3b RT::Interface::Email doesn't need to be an Exporter
2: 9b135a2 = 2: 9b135a2 Reorder functions to more obviously split sending and receiving mail
3: 670a057 = 3: 670a057 Adjust POD headers to reflect split
4: 5dfc009 = 4: 5dfc009 Update MailPlugins to only reference existant modules
5: b9ed3c2 = 5: b9ed3c2 Move MailPlugins documentation out of rt-mailgate, where is is mostly irrelevant
6: e3d18e3 = 6: e3d18e3 Remove duplicate ParseCcAddressesFromHead in RT::EmailParser
7: a93449c = 7: a93449c Use Scope::Upper to allow returns from Gateway from nested subs
8: f993bae = 8: f993bae Add a base email plugin role, which provides TMPFAIL/FAILURE/SUCCESS
9: c2e65a5 = 9: c2e65a5 Check if each named mail plugin DOES the mail plugin role
10: a997949 = 10: a997949 Return values of ApplyBeforeDecode plugins' GetCurrentUser are irrelevant
11: 588a509 = 11: 588a509 Push bounce short-circuiting down into _HandleMachineGeneratedMail
12: 1887b21 = 12: 1887b21 $IsALoop is now unused in Gateway
13: 314ad1b = 13: 314ad1b Stop moving RT-Squelch-Replies-To aside
14: 19607b9 = 14: 19607b9 Simplify _HandleMachineGeneratedMail logic
15: 531b96b = 15: 531b96b Use different method names rather than an ApplyBeforeDecode method
16: 70daad9 = 16: 70daad9 Use FAILURE to abort from GetCurrentUser, rather than a magic -1 value
17: 5a0942b = 17: 5a0942b Remove the unused $error variable
18: 8cabccc = 18: 8cabccc Move $Right to where it is used
19: 52e24c3 = 19: 52e24c3 Move SystemTicket definition to where it is first used
20: 6f62839 = 20: 6f62839 Move NewSubject to where it is used
21: 6d715aa = 21: 6d715aa Remove CreateUser, merging to form a more featureful LoadOrCreateByEmail
22: e9e5e8b = 22: e9e5e8b Always create the user; this simplifies ACL checking greatly
23: e82d433 = 23: e82d433 Split authentication from authorization
24: d1c4c8b = 24: d1c4c8b Remove no-longer-used _NoAuthorizedUserFound
25: afadc73 = 25: afadc73 Remove now-unused $Right variable, previously used by _NoAuthorizedUserFound
26: 73f1c62 = 26: 73f1c62 Fail if the first action is unauthenticated
27: a5fc795 = 27: a5fc795 Notify the owner on common mis-configurations
28: 6163947 = 28: 6163947 Remove extra error in mail-gateway
29: 87b474c = 29: 87b474c Add back a warning that is now lacking
30: c9d8ab4 = 30: c9d8ab4 Stop passing mail plugins around; load them lazily in one Plugins() method
31: 60d8040 = 31: 60d8040 Split action handling into plugin classes
32: b707acb = 32: b707acb It is possible that plugins will alter @actions; ensure that we have a valid action before calling it
33: 82c43c3 = 33: 82c43c3 Split default authentication from default authorization
34: 3430b59 = 34: 3430b59 Local'ize MailErrors to avoid having to pass $ErrorsTo everywhere
35: a3b032a = 35: a3b032a Remove the warning about the deprecated Auth::GnuPG/Auth::SMIME plugins
36: 8127768 = 36: 8127768 Allow lazy adding of Auth::MailFrom if no other GetCurrentUser plugins exist
37: dae5c31 = 37: dae5c31 There is no reason to not always enable Auth::Crypt
38: 3c0d075 = 38: 3c0d075 Make Crypt not an Auth:: plugin, but hardcoded
39: ddd76e6 = 39: ddd76e6 Move RejectOnUnencrypted to being a mail plugin
40: 7df59ef = 40: 7df59ef Merge ParseAddressFromHeader and RT::EmailParser->ParseEmailAddress
41: 0910b6f = 41: 0910b6f Fix callsites of ParseSenderAddressFromHead to be slightly less incomprehensible
42: 6b3c173 = 42: 6b3c173 $MessageId is only used in IsMachineGeneratedMail; move it in there
43: 48a5394 = 43: 48a5394 Merge CheckForSuspiciousSender, CheckForAutoGenerated, and CheckForBounce
44: e211446 = 44: e211446 Reduce repetition by making MailError handle throwing the FAILURE, as well
45: 2f7826f = 45: 2f7826f Move ACL checking for Take and Resolve into their own plugins
46: d4dd6ec = 46: d4dd6ec Update POD for new methods and functionality
47: b020c8f = 47: b020c8f Add pointers to SUCCESS/FAILURE/TMPFAIL in "writing mail plugins" docs
48: bb657e9 = 48: bb657e9 simple test for multiple reply-to addresses
49: 2019687 ! 49: bb9337c take into account multiple sender's addresses
@@ -2,11 +2,111 @@
take into account multiple sender's addresses
- use first address that exists, if none exists then do what we did before
+ use first address that has rights, if none has rights then do what we did
+ before.
diff --git a/lib/RT/Interface/Email.pm b/lib/RT/Interface/Email.pm
--- a/lib/RT/Interface/Email.pm
+++ b/lib/RT/Interface/Email.pm
+@@
+ TMPFAIL("RT couldn't find the queue: " . $args{'queue'})
+ unless $SystemTicket->id || $SystemQueueObj->id;
+
+- my $CurrentUser = GetCurrentUser(
++ my @CurrentUsers = GetCurrentUser(
+ Message => $Message,
+ RawMessageRef => \$args{message},
+ Ticket => $SystemTicket,
+@@
+ CheckACL(
+ Action => $actions[0],
+ Message => $Message,
+- CurrentUser => $CurrentUser,
++ CurrentUser => \@CurrentUsers,
+ Ticket => $SystemTicket,
+ Queue => $SystemQueueObj,
+ );
+
+- my $Ticket = RT::Ticket->new($CurrentUser);
++ my $Ticket = RT::Ticket->new($CurrentUsers[0]);
+ $Ticket->Load( $SystemTicket->Id );
+
+ for my $action (@actions) {
+@@
+
+ Dispatches to the C<@MailPlugins> to find one the provides
+ C<GetCurrentUser> that recognizes the current user. Mail plugins are
+-tried one at a time, and stops after the first to return a current user.
++tried one at a time, and stops after the first to return at least one current user.
+ Anonymous subroutine references found in C<@MailPlugins> are treated as
+ C<GetCurrentUser> methods.
+
+ The default GetCurrentUser authenticator simply looks at the From:
+-address, and loads or creates a user accordingly; see
++address, and loads users or creates a user accordingly; see
+ L<RT::Interface::Email::Auth::MailFrom>.
+
+-Returns the current user; on failure of any plugin to do so, stops
++Returns a current user list; on failure of any plugin to do so, stops
+ processing with a permanent failure and sends a generic "Permission
+ Denied" mail to the user.
+
+@@
+
+ # Since this needs loading, no matter what
+ for my $Code ( Plugins(Code => 1, Method => "GetCurrentUser") ) {
+- my $CurrentUser = $Code->(
++ my @CurrentUsers = $Code->(
+ Message => $args{Message},
+ RawMessageRef => $args{RawMessageRef},
+ Ticket => $args{Ticket},
+ Queue => $args{Queue},
+ );
+- return $CurrentUser if $CurrentUser and $CurrentUser->id;
++ return @CurrentUsers if @CurrentUsers;
+ }
+
+ # None of the GetCurrentUser plugins found a user. This is
+@@
+ );
+ }
+
+-=head3 CheckACL Action => C<action>, CurrentUser => C<user>, Ticket => C<ticket>, Queue => C<queue>
++=head3 CheckACL Action => C<action>, CurrentUser => [C<user>], Ticket => C<ticket>, Queue => C<queue>
+
+-Checks that the currentuser can perform a particular action. While RT's
++Checks that the currentusers can perform a particular action. While RT's
+ standard permission controls apply, this allows a better error message,
+ or more limited restrictions on the email gateway.
+
+@@
+ @_,
+ );
+
+- for my $Code ( Plugins( Method => "CheckACL" ) ) {
+- return if $Code->(
+- Message => $args{Message},
+- CurrentUser => $args{CurrentUser},
+- Action => $args{Action},
+- Ticket => $args{Ticket},
+- Queue => $args{Queue},
+- );
++ while ( @{ $args{CurrentUser} } ) {
++ my $CurrentUser = $args{CurrentUser}->[0];
++ for my $Code ( Plugins( Method => "CheckACL" ) ) {
++ return
++ if $Code->(
++ Message => $args{Message},
++ CurrentUser => $CurrentUser,
++ Action => $args{Action},
++ Ticket => $args{Ticket},
++ Queue => $args{Queue},
++ );
++ }
++ shift @{$args{CurrentUser}};
+ }
+
+ # Nobody said yes, and nobody said FAILURE; fail closed
@@
=cut
@@ -50,6 +150,21 @@
diff --git a/lib/RT/Interface/Email/Auth/MailFrom.pm b/lib/RT/Interface/Email/Auth/MailFrom.pm
--- a/lib/RT/Interface/Email/Auth/MailFrom.pm
+++ b/lib/RT/Interface/Email/Auth/MailFrom.pm
+@@
+ other authentication plugin is found in L<RT_Config/@MailPlugins>, RT
+ will default to this one.
+
+-This plugin reads the first address found in the C<Reply-To>, C<From>,
+-and C<Sender> headers, and loads or creates the user. It performs no
+-checking of the identity of the user, and trusts the headers of the
+-incoming email.
++This plugin reads addresses found in the C<Reply-To>, C<From>, and C<Sender>
++headers, and loads users or creates a new user for the first address. It
++performs no checking of the identity of the user, and trusts the headers of
++the incoming email.
+
+ =cut
+
@@
);
@@ -72,31 +187,45 @@
- if ( $CurrentUser->Id ) {
- $RT::Logger->debug("Mail from user #". $CurrentUser->Id ." ($Address)" );
- return $CurrentUser;
-- }
++ my @CurrentUsers;
+ foreach my $addr ( @$addresses ) {
+ $RT::Logger->debug("Testing $addr as sender");
-
++
+ my $CurrentUser = RT::CurrentUser->new;
+ $CurrentUser->LoadByEmail( $addr->address );
+ $CurrentUser->LoadByName( $addr->address ) unless $CurrentUser->Id;
+ if ( $CurrentUser->Id ) {
+ $RT::Logger->debug("$addr belongs to user #". $CurrentUser->Id );
-+ return $CurrentUser;
++ push @CurrentUsers, $CurrentUser;
+ }
+ }
+
++ unless ( @CurrentUsers ) {
++ my $first_addr = $addresses->[ 0 ];
++ my $user = RT::User->new( RT->SystemUser );
++ $user->LoadOrCreateByEmail(
++ RealName => $first_addr->phrase,
++ EmailAddress => $first_addr->address,
++ Comments => 'Autocreated on ticket submission',
++ );
++
++ my $CurrentUser = RT::CurrentUser->new;
++ $CurrentUser->Load( $user->id );
++ push @CurrentUsers, $CurrentUser;
+ }
-+ my $first_addr = $addresses->[0];
- my $user = RT::User->new( RT->SystemUser );
- $user->LoadOrCreateByEmail(
+- my $user = RT::User->new( RT->SystemUser );
+- $user->LoadOrCreateByEmail(
- RealName => $Name,
- EmailAddress => $Address,
-+ RealName => $first_addr->phrase,
-+ EmailAddress => $first_addr->address,
- Comments => 'Autocreated on ticket submission',
- );
-
+- Comments => 'Autocreated on ticket submission',
+- );
+-
- $CurrentUser = RT::CurrentUser->new;
-+ my $CurrentUser = RT::CurrentUser->new;
- $CurrentUser->Load( $user->id );
-
- return $CurrentUser;
+- $CurrentUser->Load( $user->id );
+-
+- return $CurrentUser;
++ return @CurrentUsers;
+ }
+
+ 1;
More information about the rt-commit
mailing list