Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@
}

@Override
public boolean attachLogListener(String jobId, BiConsumer<InstallationLogLevel, String> messageListener, Consumer<Boolean> finishListener) {

Check warning on line 267 in accesscontroltool-bundle/src/main/java/biz/netcentric/cq/tools/actool/impl/AcInstallationServiceImpl.java

View workflow job for this annotation

GitHub Actions / Maven build (ubuntu-latest, JDK 25)

attachLogListener(java.lang.String,java.util.function.BiConsumer<biz.netcentric.cq.tools.actool.api.InstallationLogLevel,java.lang.String>,java.util.function.Consumer<java.lang.Boolean>) in biz.netcentric.cq.tools.actool.api.AcInstallationService has been deprecated and marked for removal

Check warning on line 267 in accesscontroltool-bundle/src/main/java/biz/netcentric/cq/tools/actool/impl/AcInstallationServiceImpl.java

View workflow job for this annotation

GitHub Actions / Maven build (ubuntu-latest, JDK 17)

attachLogListener(java.lang.String,java.util.function.BiConsumer<biz.netcentric.cq.tools.actool.api.InstallationLogLevel,java.lang.String>,java.util.function.Consumer<java.lang.Boolean>) in biz.netcentric.cq.tools.actool.api.AcInstallationService has been deprecated and marked for removal

Check warning on line 267 in accesscontroltool-bundle/src/main/java/biz/netcentric/cq/tools/actool/impl/AcInstallationServiceImpl.java

View workflow job for this annotation

GitHub Actions / Maven build (macOS-latest, JDK 21)

attachLogListener(java.lang.String,java.util.function.BiConsumer<biz.netcentric.cq.tools.actool.api.InstallationLogLevel,java.lang.String>,java.util.function.Consumer<java.lang.Boolean>) in biz.netcentric.cq.tools.actool.api.AcInstallationService has been deprecated and marked for removal

Check warning on line 267 in accesscontroltool-bundle/src/main/java/biz/netcentric/cq/tools/actool/impl/AcInstallationServiceImpl.java

View workflow job for this annotation

GitHub Actions / Maven build (ubuntu-latest, JDK 11)

attachLogListener(java.lang.String,java.util.function.BiConsumer<biz.netcentric.cq.tools.actool.api.InstallationLogLevel,java.lang.String>,java.util.function.Consumer<java.lang.Boolean>) in biz.netcentric.cq.tools.actool.api.AcInstallationService has been deprecated and marked for removal

Check warning on line 267 in accesscontroltool-bundle/src/main/java/biz/netcentric/cq/tools/actool/impl/AcInstallationServiceImpl.java

View workflow job for this annotation

GitHub Actions / Maven build (macOS-latest, JDK 11)

attachLogListener(java.lang.String,java.util.function.BiConsumer<biz.netcentric.cq.tools.actool.api.InstallationLogLevel,java.lang.String>,java.util.function.Consumer<java.lang.Boolean>) in biz.netcentric.cq.tools.actool.api.AcInstallationService has been deprecated and marked for removal

Check warning on line 267 in accesscontroltool-bundle/src/main/java/biz/netcentric/cq/tools/actool/impl/AcInstallationServiceImpl.java

View workflow job for this annotation

GitHub Actions / Maven build (macOS-latest, JDK 17)

attachLogListener(java.lang.String,java.util.function.BiConsumer<biz.netcentric.cq.tools.actool.api.InstallationLogLevel,java.lang.String>,java.util.function.Consumer<java.lang.Boolean>) in biz.netcentric.cq.tools.actool.api.AcInstallationService has been deprecated and marked for removal

Check warning on line 267 in accesscontroltool-bundle/src/main/java/biz/netcentric/cq/tools/actool/impl/AcInstallationServiceImpl.java

View workflow job for this annotation

GitHub Actions / Maven build (macOS-latest, JDK 25)

attachLogListener(java.lang.String,java.util.function.BiConsumer<biz.netcentric.cq.tools.actool.api.InstallationLogLevel,java.lang.String>,java.util.function.Consumer<java.lang.Boolean>) in biz.netcentric.cq.tools.actool.api.AcInstallationService has been deprecated and marked for removal

Check warning on line 267 in accesscontroltool-bundle/src/main/java/biz/netcentric/cq/tools/actool/impl/AcInstallationServiceImpl.java

View workflow job for this annotation

GitHub Actions / Main Maven build (ubuntu-latest, JDK 21)

attachLogListener(java.lang.String,java.util.function.BiConsumer<biz.netcentric.cq.tools.actool.api.InstallationLogLevel,java.lang.String>,java.util.function.Consumer<java.lang.Boolean>) in biz.netcentric.cq.tools.actool.api.AcInstallationService has been deprecated and marked for removal
return false;
}

Expand Down Expand Up @@ -650,6 +650,8 @@
AcConfiguration acConfiguration, Map<String, Set<AceBean>> repositoryDumpAceMap, Session session, InstallationOptions options)
throws Exception {

applyDefaultEveryoneUnmanagedAcePathsRegex(acConfiguration.getAuthorizablesConfig(), installLog);

// --- installation of ACEs from configuration ---
Map<String, Set<AceBean>> pathBasedAceMapFromConfig = AcHelper
.getPathBasedAceMap(acConfiguration.getAceConfig(), AcHelper.ACE_ORDER_ACTOOL_BEST_PRACTICE);
Expand Down Expand Up @@ -738,6 +740,18 @@
+ msHumanReadable(stopWatch.getTime()));
}

static void applyDefaultEveryoneUnmanagedAcePathsRegex(AuthorizablesConfig authorizablesConfig, InstallationLogger installLog) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Only prevent removal of existing ACLs without preventing installation of new ACLs. Therefore don't modify unmanagedAcePathsRegex but rather skip this principal when removing ACEs (emitting a info LOG message)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated ACL reconciliation to exclude everyone from removal sets when no regex is configured, while leaving its regex unset so configured ACEs are still installed. The INFO history entry records the preservation. Commit: 1251f78.

for (AuthorizableConfigBean authorizableConfigBean : authorizablesConfig) {
if (PRINCIPAL_EVERYONE.equals(authorizableConfigBean.getPrincipalName())
&& StringUtils.isEmpty(authorizableConfigBean.getUnmanagedAcePathsRegex())) {
installLog.addWarning(LOG,
"The default unmanagedAcePathsRegex '.*' is applied to principal everyone; its ACLs will not be managed unless a narrower regex is configured.");
authorizableConfigBean.setUnmanagedAcePathsRegex(".*");
return;
}
}
}

private Set<String> removeNonExistingAuthorizables(Set<String> authorizablesToCheck, Session session)
throws AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException {
Set<String> nonExistingAuthorizables = new HashSet<String>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -78,6 +79,15 @@
assertEquals(principalSet("testgroupAllManaged", "nonExistentPrincipal"), removedPrincipals);
}

@Test
public void testEveryoneRegexIsNotSetWhenAdded() {
AuthorizablesConfig config = new AuthorizablesConfig();

Check warning on line 84 in accesscontroltool-bundle/src/test/java/biz/netcentric/cq/tools/actool/configmodel/AuthorizablesConfigTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Consume or remove this unused collection

See more on https://sonarcloud.io/project/issues?id=Netcentric_accesscontroltool&issues=AaGImTsP-J1SRkj-vPjk&open=AaGImTsP-J1SRkj-vPjk&pullRequest=918
AuthorizableConfigBean everyone = getBean("everyone", null);
config.add(everyone);

assertNull(everyone.getUnmanagedAcePathsRegex());
}

@Test
public void testRemoveUnmanagedPrincipalNamesAtPathUsingGlobalConfig() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.verifyNoInteractions;

import java.text.MessageFormat;
import java.util.Arrays;
Expand Down Expand Up @@ -46,6 +47,9 @@
import org.mockito.stubbing.Answer;

import biz.netcentric.cq.tools.actool.api.InstallationOptionsBuilder;
import biz.netcentric.cq.tools.actool.configmodel.AuthorizableConfigBean;
import biz.netcentric.cq.tools.actool.configmodel.AuthorizablesConfig;
import biz.netcentric.cq.tools.actool.history.InstallationLogger;

@ExtendWith(MockitoExtension.class)
class AcInstallationServiceImplTest {
Expand Down Expand Up @@ -126,6 +130,30 @@

}

@Test
void testDefaultEveryoneUnmanagedAcePathsRegexIsAppliedOnlyWhenInstallingAces() {
AuthorizablesConfig authorizablesConfig = new AuthorizablesConfig();
AuthorizableConfigBean everyone = new AuthorizableConfigBean();
everyone.setPrincipalName("everyone");
authorizablesConfig.add(everyone);

InstallationLogger installLog = Mockito.mock(InstallationLogger.class);

Check warning on line 140 in accesscontroltool-bundle/src/test/java/biz/netcentric/cq/tools/actool/impl/AcInstallationServiceImplTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use a static import for "mock".

See more on https://sonarcloud.io/project/issues?id=Netcentric_accesscontroltool&issues=AaGImTuj-J1SRkj-vPjl&open=AaGImTuj-J1SRkj-vPjl&pullRequest=918
AcInstallationServiceImpl.applyDefaultEveryoneUnmanagedAcePathsRegex(authorizablesConfig, installLog);

Mockito.verify(installLog).addWarning(Mockito.any(org.slf4j.Logger.class), Mockito.contains("unmanagedAcePathsRegex '.*'"));

Check warning on line 143 in accesscontroltool-bundle/src/test/java/biz/netcentric/cq/tools/actool/impl/AcInstallationServiceImplTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use a static import for "verify".

See more on https://sonarcloud.io/project/issues?id=Netcentric_accesscontroltool&issues=AaGImTuj-J1SRkj-vPjm&open=AaGImTuj-J1SRkj-vPjm&pullRequest=918
assertEquals(".*", everyone.getUnmanagedAcePathsRegex());

everyone.setUnmanagedAcePathsRegex(".*");
InstallationLogger explicitlyConfiguredLog = Mockito.mock(InstallationLogger.class);

Check warning on line 147 in accesscontroltool-bundle/src/test/java/biz/netcentric/cq/tools/actool/impl/AcInstallationServiceImplTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use a static import for "mock".

See more on https://sonarcloud.io/project/issues?id=Netcentric_accesscontroltool&issues=AaGImTuj-J1SRkj-vPjn&open=AaGImTuj-J1SRkj-vPjn&pullRequest=918
AcInstallationServiceImpl.applyDefaultEveryoneUnmanagedAcePathsRegex(authorizablesConfig, explicitlyConfiguredLog);
verifyNoInteractions(explicitlyConfiguredLog);

everyone.setUnmanagedAcePathsRegex("^/content.*");
InstallationLogger narrowedRegexLog = Mockito.mock(InstallationLogger.class);

Check warning on line 152 in accesscontroltool-bundle/src/test/java/biz/netcentric/cq/tools/actool/impl/AcInstallationServiceImplTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use a static import for "mock".

See more on https://sonarcloud.io/project/issues?id=Netcentric_accesscontroltool&issues=AaGImTuj-J1SRkj-vPjo&open=AaGImTuj-J1SRkj-vPjo&pullRequest=918
AcInstallationServiceImpl.applyDefaultEveryoneUnmanagedAcePathsRegex(authorizablesConfig, narrowedRegexLog);
verifyNoInteractions(narrowedRegexLog);
}

private static class GroupIteratorAnswer implements Answer<Iterator<Group>> {

static GroupIteratorAnswer forGroups(Group... groups) {
Expand Down Expand Up @@ -177,7 +205,7 @@
when(jobContext.result()).thenReturn(new ResultBuilderImpl());

// schedule in one server
assertEquals("id", acInstallationServiceImpl.applyAsynchronously(new InstallationOptionsBuilder().withConfigurationRootPath("/apps").build()));

Check warning on line 208 in accesscontroltool-bundle/src/test/java/biz/netcentric/cq/tools/actool/impl/AcInstallationServiceImplTest.java

View workflow job for this annotation

GitHub Actions / Maven build (ubuntu-latest, JDK 25)

applyAsynchronously(biz.netcentric.cq.tools.actool.api.InstallationOptions) in biz.netcentric.cq.tools.actool.api.AcInstallationService has been deprecated and marked for removal

Check warning on line 208 in accesscontroltool-bundle/src/test/java/biz/netcentric/cq/tools/actool/impl/AcInstallationServiceImplTest.java

View workflow job for this annotation

GitHub Actions / Maven build (ubuntu-latest, JDK 17)

applyAsynchronously(biz.netcentric.cq.tools.actool.api.InstallationOptions) in biz.netcentric.cq.tools.actool.api.AcInstallationService has been deprecated and marked for removal

Check warning on line 208 in accesscontroltool-bundle/src/test/java/biz/netcentric/cq/tools/actool/impl/AcInstallationServiceImplTest.java

View workflow job for this annotation

GitHub Actions / Maven build (macOS-latest, JDK 21)

applyAsynchronously(biz.netcentric.cq.tools.actool.api.InstallationOptions) in biz.netcentric.cq.tools.actool.api.AcInstallationService has been deprecated and marked for removal

Check warning on line 208 in accesscontroltool-bundle/src/test/java/biz/netcentric/cq/tools/actool/impl/AcInstallationServiceImplTest.java

View workflow job for this annotation

GitHub Actions / Maven build (ubuntu-latest, JDK 11)

applyAsynchronously(biz.netcentric.cq.tools.actool.api.InstallationOptions) in biz.netcentric.cq.tools.actool.api.AcInstallationService has been deprecated and marked for removal

Check warning on line 208 in accesscontroltool-bundle/src/test/java/biz/netcentric/cq/tools/actool/impl/AcInstallationServiceImplTest.java

View workflow job for this annotation

GitHub Actions / Maven build (macOS-latest, JDK 11)

applyAsynchronously(biz.netcentric.cq.tools.actool.api.InstallationOptions) in biz.netcentric.cq.tools.actool.api.AcInstallationService has been deprecated and marked for removal

Check warning on line 208 in accesscontroltool-bundle/src/test/java/biz/netcentric/cq/tools/actool/impl/AcInstallationServiceImplTest.java

View workflow job for this annotation

GitHub Actions / Maven build (macOS-latest, JDK 17)

applyAsynchronously(biz.netcentric.cq.tools.actool.api.InstallationOptions) in biz.netcentric.cq.tools.actool.api.AcInstallationService has been deprecated and marked for removal

Check warning on line 208 in accesscontroltool-bundle/src/test/java/biz/netcentric/cq/tools/actool/impl/AcInstallationServiceImplTest.java

View workflow job for this annotation

GitHub Actions / Maven build (macOS-latest, JDK 25)

applyAsynchronously(biz.netcentric.cq.tools.actool.api.InstallationOptions) in biz.netcentric.cq.tools.actool.api.AcInstallationService has been deprecated and marked for removal

Check warning on line 208 in accesscontroltool-bundle/src/test/java/biz/netcentric/cq/tools/actool/impl/AcInstallationServiceImplTest.java

View workflow job for this annotation

GitHub Actions / Main Maven build (ubuntu-latest, JDK 21)

applyAsynchronously(biz.netcentric.cq.tools.actool.api.InstallationOptions) in biz.netcentric.cq.tools.actool.api.AcInstallationService has been deprecated and marked for removal
// and process in another server (with another instance of the service)
AcInstallationServiceImpl acInstallationServiceImpl2 = new AcInstallationServiceImpl();
acInstallationServiceImpl2.process(job, jobContext);
Expand Down
2 changes: 1 addition & 1 deletion docs/AdvancedFeatures.md
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ To configure permissions for already existing users/groups, it's best to create
This is not an option for the [`everyone` group](https://jackrabbit.apache.org/oak/docs/security/user/default.html#Everyone_Group) as it is neither allowed to put groups/users as members to this group (because implicitly every principal is member of this group) nor to put this group as member to another group (to prevent cycles, compare with [OAK-7323](https://issues.apache.org/jira/browse/OAK-7323)).
Also in case of using [Sling Service Authentication bound to principals](https://sling.apache.org/documentation/the-sling-engine/service-authentication.html#service-user-mappings)(available since AEM 6.4) you cannot use group memberships, as the principal mapping does not consider (transitive) group memberships. Those mappings can be identified by looking up the according `org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended` configuration instance with its `user.mapping` property. It that has the format `<service-name>[:<subservice-name>]="["<principal name>{","<principal name>}"]"` (look for square brackets) it is a principal mapping.

In those cases just list the built-in authorizable (user/group) in the YAML file (with the correct authorizable id) and leverage `unmanagedAcePathsRegex` as outlined below. No other properties need to be set on the authorizable as this is in fact not touched by the ACTool. Alternatively just extend the permissions with [Repository Initialization (repoinit)](https://sling.apache.org/documentation/bundles/repository-initialization.html).
In those cases just list the built-in authorizable (user/group) in the YAML file (with the correct authorizable id) and leverage `unmanagedAcePathsRegex` as outlined below. No other properties need to be set on the authorizable as this is in fact not touched by the ACTool. When `everyone` is listed without an `unmanagedAcePathsRegex`, the AC Tool defaults it to `.*` so existing ACEs for this principal are not removed (including repo level ACEs). To manage selected paths for `everyone`, explicitly configure a regex that excludes all other paths. Alternatively just extend the permissions with [Repository Initialization (repoinit)](https://sling.apache.org/documentation/bundles/repository-initialization.html).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot This is no longer true, when there is no unmanagedAcePathsRegex set for everyone no ACEs will ever be removed. If the unmanagedAcePathsRegex is set it is considered for both removing ACEs and installing ACEs for everyone.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the documentation to clarify that omitting the regex preserves existing everyone ACEs during cleanup while configured ACEs remain installable; an explicit regex governs both removal and installation. Commit: $(git rev-parse --short HEAD). (The commit is c7a2c01.)


### Configure memberships of/towards externally managed groups

Expand Down
Loading