[Rt-commit] rt branch 5.0/serialize-custom-role-acl created. rt-5.0.2-87-gacad789dc0
BPS Git Server
git at git.bestpractical.com
Fri Feb 25 22:45:43 UTC 2022
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".
The branch, 5.0/serialize-custom-role-acl has been created
at acad789dc01d0340e043fc6caba0cffe6d524aed (commit)
- Log -----------------------------------------------------------------
commit acad789dc01d0340e043fc6caba0cffe6d524aed
Author: sunnavy <sunnavy at bestpractical.com>
Date: Sat Feb 26 05:47:41 2022 +0800
Use name for custom role groups in ACL
Otherwise the custom role ACL wouldn't be portable enough since id
varies in different RT.
diff --git a/lib/RT/Handle.pm b/lib/RT/Handle.pm
index ad15dae8b6..5690ec9a59 100644
--- a/lib/RT/Handle.pm
+++ b/lib/RT/Handle.pm
@@ -1555,7 +1555,18 @@ sub InsertData {
} elsif ( $item->{'GroupDomain'} eq 'SystemInternal' ) {
$princ->LoadSystemInternalGroup( $item->{'GroupType'} );
} elsif ( $item->{'GroupDomain'} =~ /-Role$/ ) {
- $princ->LoadRoleGroup( Object => $object, Name => $item->{'GroupType'} );
+ my $name;
+ if ( $item->{'GroupType'} =~ /^RT::CustomRole-(.+)/ ) {
+ my $custom_role = RT::CustomRole->new( RT->SystemUser );
+ $custom_role->Load($1);
+ if ( $custom_role->Id ) {
+ $name = 'RT::CustomRole-' . $custom_role->Id;
+ }
+ else {
+ RT->Logger->error("Unable to load CustomRole $1");
+ }
+ }
+ $princ->LoadRoleGroup( Object => $object, Name => $name || $item->{'GroupType'} );
} else {
$princ->Load( $item->{'GroupId'} );
}
diff --git a/lib/RT/Migrate/Serializer/JSON.pm b/lib/RT/Migrate/Serializer/JSON.pm
index 99fb6e2fe4..f666525fd5 100644
--- a/lib/RT/Migrate/Serializer/JSON.pm
+++ b/lib/RT/Migrate/Serializer/JSON.pm
@@ -318,7 +318,18 @@ sub CanonicalizeACLs {
$ace->{GroupId} = $group->Name;
}
if ($domain eq 'SystemInternal' || $domain =~ /-Role$/) {
- $ace->{GroupType} = $group->Name;
+ my $group_type;
+ if ( $group->Name =~ /^RT::CustomRole-(\d+)/ ) {
+ my $custom_role = RT::CustomRole->new( RT->SystemUser );
+ $custom_role->Load($1);
+ if ( $custom_role->Id ) {
+ $group_type = 'RT::CustomRole-' . $custom_role->Name;
+ }
+ else {
+ RT->Logger->error("Could not load custom role: $1");
+ }
+ }
+ $ace->{GroupType} = $group_type || $group->Name;
}
}
}
commit 4d57de6ca66996433755c1110744a1bc3b77a83c
Author: sunnavy <sunnavy at bestpractical.com>
Date: Sat Feb 26 06:01:38 2022 +0800
Treat RT::System-Role the same as other roles in ACL initialdata
This is to reduce code duplication, as the following block for /-Role$/
also covers "RT::System-Role".
diff --git a/lib/RT/Handle.pm b/lib/RT/Handle.pm
index 3f741fa7ff..ad15dae8b6 100644
--- a/lib/RT/Handle.pm
+++ b/lib/RT/Handle.pm
@@ -1554,8 +1554,6 @@ sub InsertData {
$princ->LoadUserDefinedGroup( $item->{'GroupId'} );
} elsif ( $item->{'GroupDomain'} eq 'SystemInternal' ) {
$princ->LoadSystemInternalGroup( $item->{'GroupType'} );
- } elsif ( $item->{'GroupDomain'} eq 'RT::System-Role' ) {
- $princ->LoadRoleGroup( Object => RT->System, Name => $item->{'GroupType'} );
} elsif ( $item->{'GroupDomain'} =~ /-Role$/ ) {
$princ->LoadRoleGroup( Object => $object, Name => $item->{'GroupType'} );
} else {
-----------------------------------------------------------------------
hooks/post-receive
--
rt
More information about the rt-commit
mailing list