Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanseifert committed Jul 8, 2024
2 parents 4fb5ad8 + c8098e9 commit 166a815
Show file tree
Hide file tree
Showing 18 changed files with 98 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/maven-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
java: [11, 17]
java: [11, 17, 21]
os: [ubuntu-latest]
distribution: [temurin]

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/maven-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Configure GIT
run: |
git config --global user.email "${{ secrets.GH_SITE_DEPLOY_EMAIL }}"
git config --global user.name "${{ secrets.GH_SITE_DEPLOY_NAME }}"
- name: Setup JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-from-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ncipollo/release-action@v1
with:
body: 'Changes: https://wcm.io/caconfig/extensions/changes-report.html'
Expand Down
13 changes: 0 additions & 13 deletions .maven-settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,6 @@
</snapshots>
</repository>

<repository>
<id>maven-nodejs-proxy</id>
<url>https://maven-nodejs-proxy.pvtool.org</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>

<repository>
<id>oss-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
Expand Down
10 changes: 10 additions & 0 deletions changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@
xsi:schemaLocation="http://maven.apache.org/changes/1.0.0 http://maven.apache.org/plugins/maven-changes-plugin/xsd/changes-1.0.0.xsd">
<body>

<release version="1.9.6" date="2024-07-08">
<action type="update" dev="cnagel" issue="4">
Adds context path allow list to ToolsConfigPagePersistenceStrategy configuration.
This is a (minor) breaking change - by default only configurations stored in /content will work with this strategy.
</action>
<action type="update" dev="sseifert">
Switch to AEM 6.5.17 as minimum version.
</action>
</release>

<release version="1.9.4" date="2023-10-17">
<action type="update" dev="cnagel" issue="1">
Adds relative config path to ToolsConfigPagePersistenceStrategy configuration.
Expand Down
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
<parent>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.parent_toplevel</artifactId>
<version>2.2.2</version>
<version>2.3.2</version>
<relativePath/>
</parent>

<groupId>io.wcm</groupId>
<artifactId>io.wcm.caconfig.extensions</artifactId>
<version>1.9.4</version>
<version>1.9.6</version>
<packaging>jar</packaging>

<name>Context-Aware Configuration Extensions for AEM</name>
Expand All @@ -49,7 +49,7 @@
<site.url.module.prefix>caconfig/extensions</site.url.module.prefix>

<!-- Enable reproducible builds -->
<project.build.outputTimestamp>2023-10-17T08:02:02Z</project.build.outputTimestamp>
<project.build.outputTimestamp>2024-07-08T09:00:59Z</project.build.outputTimestamp>
</properties>

<dependencies>
Expand Down Expand Up @@ -160,13 +160,13 @@
<dependency>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.testing.aem-mock.junit5</artifactId>
<version>5.0.0</version>
<version>5.5.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.testing.caconfig-mock-plugin</artifactId>
<version>1.4.0</version>
<version>1.5.4</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ public class ToolsConfigPagePersistenceStrategy implements ConfigurationPersiste
description = "Relative path to the configuration page content.")
String relativeConfigPath() default "/tools/config/jcr:content";

@AttributeDefinition(name = "Context path allow list",
description = "Expression to match context paths. Context paths matching this expression are allowed.")
String contextPathRegex() default "^/content(/.+)$";

}

private static final String DEFAULT_CONFIG_NODE_TYPE = NT_UNSTRUCTURED;
Expand All @@ -111,6 +115,7 @@ public class ToolsConfigPagePersistenceStrategy implements ConfigurationPersiste

private boolean enabled;
private Pattern configPathPattern;
private Pattern contextPathPattern;
private Config config;

@Reference
Expand All @@ -126,6 +131,7 @@ public class ToolsConfigPagePersistenceStrategy implements ConfigurationPersiste
void activate(Config value) {
this.enabled = value.enabled();
this.configPathPattern = loadConfigPathPattern(value);
this.contextPathPattern = loadContextPathPattern(value);
this.config = value;
}

Expand All @@ -136,6 +142,13 @@ void activate(Config value) {
: null;
}

private @Nullable Pattern loadContextPathPattern(Config value) {
String contextPathRegex = value.contextPathRegex();
return enabled && StringUtils.isNotBlank(contextPathRegex)
? Pattern.compile(contextPathRegex)
: null;
}

@Override
public Resource getResource(@NotNull Resource resource) {
if (!enabled || !isConfigPagePath(resource.getPath())) {
Expand Down Expand Up @@ -298,7 +311,11 @@ private String checkPath(final ContextResource contextResource, final String che

@SuppressWarnings("unused")
private boolean isEnabledAndParamsValid(final Resource contentResource, final Collection<String> bucketNames, final String configName) {
return enabled && contentResource != null;
return enabled && contentResource != null && isContextPathAllowed(contentResource.getPath());
}

private boolean isContextPathAllowed(String contextPath) {
return contextPathPattern == null || contextPathPattern.matcher(contextPath).matches();
}

private String buildResourcePath(String path, String name) {
Expand Down
26 changes: 14 additions & 12 deletions src/site/markdown/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,29 @@ The following extensions are provided:
* A [Reference Provider][reference-provider] implementation for context-aware configurations


### Supported AEM versions

Context-Aware Configuration is supported in AEM 6.1, 6.2, 6.3 and upwards. AEM 6.0 is not supported.

When you are using AEM 6.1 or 6.2 you have to additionally deploy the Apache Sling Context-Aware Configuration bundles (API, SPI, Impl) to AEM. In AEM 6.3 you have to update the Apache Sling Context-Aware Configuration SPI and Impl bundles to the latest version to use all features.

See [Deploy and configure Context-Aware Configuration in AEM][deploy-configure-caconfig-in-aem] for details.


### AEM Version Support Matrix

|Context-Aware Configuration Extensions for AEM version |AEM version supported
|-------------------------------------------------------|----------------------
|1.9.2 or higher |AEM 6.5.7+, AEMaaCS
|1.9.0 |AEM 6.5+, AEMaaCS
|1.9.6 or higher |AEM 6.5.17+ *), AEMaaCS
|1.9.2 - 1.9.4 |AEM 6.5.7+ *), AEMaaCS
|1.9.0 |AEM 6.5+ *), AEMaaCS
|1.8.x |AEM 6.4+, AEMaaCS
|1.7.x |AEM 6.3+
|1.6.x |AEM 6.2+
|1.0.x - 1.5.x |AEM 6.1+

### Dependencies

*) For version 1.9.0 and up, the bundle depends on `org.apache.sling.caconfig.spi` 1.4.0 and `org.apache.sling.caconfig.impl` 1.6.0 - but AEM 6.5 contains older versions of these bundles. It is recommended to update latest versions of these bundles and deploy them together with your application:

|---|---|---|
| [Apache Sling Context-Aware Configuration API](https://repo1.maven.org/maven2/org/apache/sling/org.apache.sling.caconfig.api/) | [![Maven Central](https://img.shields.io/maven-central/v/org.apache.sling/org.apache.sling.caconfig.api)](https://repo1.maven.org/maven2/org/apache/sling/org.apache.sling.caconfig.api/) |
| [Apache Sling Context-Aware Configuration SPI](https://repo1.maven.org/maven2/org/apache/sling/org.apache.sling.caconfig.spi/) | [![Maven Central](https://img.shields.io/maven-central/v/org.apache.sling/org.apache.sling.caconfig.spi)](https://repo1.maven.org/maven2/org/apache/sling/org.apache.sling.caconfig.spi/) |
| [Apache Sling Context-Aware Configuration Implementation](https://repo1.maven.org/maven2/org/apache/sling/org.apache.sling.caconfig.impl/) | [![Maven Central](https://img.shields.io/maven-central/v/org.apache.sling/org.apache.sling.caconfig.impl)](https://repo1.maven.org/maven2/org/apache/sling/org.apache.sling.caconfig.impl/) |

AEMaaCS includes recent enough versions of these dependencies.


### GitHub Repository

Expand All @@ -49,7 +52,6 @@ Sources: https://github.com/wcm-io/io.wcm.caconfig.extensions

[usage]: usage.html
[changelog]: changes-report.html
[deploy-configure-caconfig-in-aem]: https://wcm.io/caconfig/deploy-configure-caconfig-in-aem.html
[context-path-strategies]: context-path-strategies.html
[persistence-strategies]: persistence-strategies.html
[override-providers]: override-providers.html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class AemConfigurationInjectResourceDetectionStrategyTest {
private ConfigurationInjectResourceDetectionStrategyMultiplexer strategyMultiplexer;

@BeforeEach
void setUp() throws Exception {
void setUp() {
context.registerInjectActivateService(AemConfigurationInjectResourceDetectionStrategy.class);
strategyMultiplexer = context.getService(ConfigurationInjectResourceDetectionStrategyMultiplexer.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class AbsoluteParentContextPathStrategyLegacyVersionHistoryTenantTest extends Ab

@Override
@BeforeEach
void setUp() throws Exception {
void setUp() {
context.registerAdapter(ResourceResolver.class, Tenant.class, tenant);

level1 = context.create().page("/content/versionhistory/tenant1/user1/region1").adaptTo(Resource.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class AbsoluteParentContextPathStrategyLegacyVersionHistoryTest extends Absolute

@Override
@BeforeEach
void setUp() throws Exception {
void setUp() {
level1 = context.create().page("/content/versionhistory/user1/region1").adaptTo(Resource.class);
level2 = context.create().page("/content/versionhistory/user1/region1/site1").adaptTo(Resource.class);
level3 = context.create().page("/content/versionhistory/user1/region1/site1/en").adaptTo(Resource.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class AbsoluteParentContextPathStrategyTest {
protected Resource level4;

@BeforeEach
void setUp() throws Exception {
void setUp() {
level1 = context.create().page("/content/region1").adaptTo(Resource.class);
level2 = context.create().page("/content/region1/site1").adaptTo(Resource.class);
level3 = context.create().page("/content/region1/site1/en").adaptTo(Resource.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class AbsoluteParentContextPathStrategyVersionHistoryTest extends AbsoluteParent

@Override
@BeforeEach
void setUp() throws Exception {
void setUp() {
level1 = context.create().page("/tmp/versionhistory/user1/version1/region1").adaptTo(Resource.class);
level2 = context.create().page("/tmp/versionhistory/user1/version1/region1/site1").adaptTo(Resource.class);
level3 = context.create().page("/tmp/versionhistory/user1/version1/region1/site1/en").adaptTo(Resource.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ public void execute(@NotNull AemContext ctx) {
private Page contentPage;

@BeforeEach
void setUp() throws Exception {
void setUp() {
context.create().resource("/conf");
contentPage = context.create().page("/content/test/site1", "/apps/app1/templates/template1",
ImmutableValueMap.of("sling:configRef", "/conf/test/site1"));
}

@Test
void testSimpleConfig() throws Exception {
void testSimpleConfig() {
context.registerInjectActivateService(new PagePersistenceStrategy(), "enabled", true);

// write config
Expand All @@ -111,7 +111,7 @@ void testSimpleConfig() throws Exception {
}

@Test
void testSimpleConfig_Disabled() throws Exception {
void testSimpleConfig_Disabled() {
context.registerInjectActivateService(new PagePersistenceStrategy(), "enabled", false);

// write config
Expand All @@ -130,7 +130,7 @@ void testSimpleConfig_Disabled() throws Exception {
}

@Test
void testListConfig() throws Exception {
void testListConfig() {
context.registerInjectActivateService(new PagePersistenceStrategy(), "enabled", true);

// write config
Expand Down Expand Up @@ -163,7 +163,7 @@ void testListConfig() throws Exception {
}

@Test
void testListConfig_Nested() throws Exception {
void testListConfig_Nested() {
context.registerInjectActivateService(new PagePersistenceStrategy(), "enabled", true);

// write config
Expand Down Expand Up @@ -239,7 +239,7 @@ void testListConfig_Nested() throws Exception {
}

@Test
void testNestedConfig() throws Exception {
void testNestedConfig() {
context.registerInjectActivateService(new PagePersistenceStrategy(), "enabled", true);

// write config
Expand Down Expand Up @@ -278,7 +278,7 @@ void testNestedConfig() throws Exception {
}

@Test
void testDeeplyNestedConfig_WCON60() throws Exception {
void testDeeplyNestedConfig_WCON60() {
context.registerInjectActivateService(new PagePersistenceStrategy(), "enabled", true);

// write config
Expand All @@ -305,7 +305,7 @@ void testDeeplyNestedConfig_WCON60() throws Exception {
}

@Test
void testSimpleConfig_ResourceType() throws Exception {
void testSimpleConfig_ResourceType() {
context.registerInjectActivateService(new PagePersistenceStrategy(), "enabled", true,
"resourceType", "app1/components/page/config");

Expand All @@ -322,7 +322,7 @@ void testSimpleConfig_ResourceType() throws Exception {
}

@Test
void testListConfig_ResourceType() throws Exception {
void testListConfig_ResourceType() {
context.registerInjectActivateService(new PagePersistenceStrategy(), "enabled", true,
"resourceType", "app1/components/page/config");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
class PagePersistenceStrategyTestWithToolsConfigPage extends PagePersistenceStrategyTest {

@BeforeEach
void registerAdditionalPersictenceStrategy() throws Exception {
void registerAdditionalPersictenceStrategy() {
context.registerInjectActivateService(new ToolsConfigPagePersistenceStrategy(),
"enabled", true);
}
Expand Down
Loading

0 comments on commit 166a815

Please sign in to comment.