From 953bf4702bfa54321ac742bf426d1062ae5f7ca0 Mon Sep 17 00:00:00 2001 From: Mark Daugherty Date: Thu, 7 Mar 2019 11:36:59 -0600 Subject: [PATCH 1/8] version. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2996cc95..7532f1c5 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ com.icfolson.aem.groovy.console aem-groovy-console jar - 13.0.0 + 13.0.1-SNAPSHOT AEM Groovy Console The AEM Groovy Console provides an interface for running Groovy scripts in the AEM container. Scripts can be From 366f098d3753374d47ee9677fe1b69efa361b61e Mon Sep 17 00:00:00 2001 From: Mark Daugherty Date: Thu, 7 Mar 2019 13:45:10 -0600 Subject: [PATCH 2/8] doc updates. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 02adb076..7d2980fb 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ The AEM Groovy Console provides an interface for running [Groovy](http://www.gro ## Compatibility -Groovy Console Version(s) | AEM Version +Groovy Console Version(s) | AEM Version(s) ------------ | ------------- 13.x.x | 6.3, 6.4, 6.5 12.x.x | 6.4 From 62631b7881e6750d6874ca1a818eec268a2acec0 Mon Sep 17 00:00:00 2001 From: Mark Daugherty Date: Fri, 8 Mar 2019 15:21:25 -0600 Subject: [PATCH 3/8] doc updates. --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7d2980fb..cfca85d0 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,14 @@ Saved scripts can be remotely executed by sending a POST request to the console Beginning in version 7.0.0, the Groovy Console provides extension hooks to further customize script execution. The console exposes an API containing three extension provider interfaces that can be implemented as OSGi services in any bundle deployed to an AEM instance. See the default extension providers in the `com.icfolson.aem.groovy.console.extension.impl` package for examples of how a bundle can implement these services to supply additional script bindings, metaclasses, and star imports. -### Notifications +Service Interface | Description +------------ | ------------- +`com.icfolson.aem.groovy.console.api.BindingExtensionProvider` | Customize the bindings that are provided for each script execution. +`com.icfolson.aem.groovy.console.api.CompilationCustomizerExtensionProvider` | Restrict language features (via blacklist or whitelist) or provide AST transformations within the Groovy script compilation. +`com.icfolson.aem.groovy.console.api.ScriptMetaClassExtensionProvider` | Add runtime metaclasses (i.e. new methods) to the underlying script class. +`com.icfolson.aem.groovy.console.api.StarImportExtensionProvider` | Supply additional star imports that are added to the compiler configuration for each script execution. + +## Notifications To provide custom notifications for script executions, bundles may implement the `com.icfolson.aem.groovy.console.notification.NotificationService` interface (see the `com.icfolson.aem.groovy.console.notification.impl.EmailNotificationService` class for an example). These services will be dynamically bound by the Groovy Console service and all registered notification services will be called for each script execution. From 275c844b261fda78e4cae7fb33a217ea135adae2 Mon Sep 17 00:00:00 2001 From: Mark Daugherty Date: Fri, 8 Mar 2019 15:40:09 -0600 Subject: [PATCH 4/8] doc updates. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cfca85d0..2a2208a3 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ Saved scripts can be remotely executed by sending a POST request to the console ## Extensions -Beginning in version 7.0.0, the Groovy Console provides extension hooks to further customize script execution. The console exposes an API containing three extension provider interfaces that can be implemented as OSGi services in any bundle deployed to an AEM instance. See the default extension providers in the `com.icfolson.aem.groovy.console.extension.impl` package for examples of how a bundle can implement these services to supply additional script bindings, metaclasses, and star imports. +The Groovy Console provides extension hooks to further customize script execution. The console provides an API containing extension provider interfaces that can be implemented as OSGi services in any bundle deployed to an AEM instance. See the default extension providers in the `com.icfolson.aem.groovy.console.extension.impl` package for examples of how a bundle can implement these services to supply additional script bindings, compilation customizers, metaclasses, and star imports. Service Interface | Description ------------ | ------------- From f806e9e8b3e635951017f29a6c635c9dba3fa6a5 Mon Sep 17 00:00:00 2001 From: Mark Daugherty Date: Wed, 10 Apr 2019 09:47:38 -0400 Subject: [PATCH 5/8] fixed broken groovydocs link. --- .../apps/groovyconsole/components/console/enhancements.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/content/jcr_root/apps/groovyconsole/components/console/enhancements.html b/src/main/content/jcr_root/apps/groovyconsole/components/console/enhancements.html index d12b7446..07bb661e 100644 --- a/src/main/content/jcr_root/apps/groovyconsole/components/console/enhancements.html +++ b/src/main/content/jcr_root/apps/groovyconsole/components/console/enhancements.html @@ -6,7 +6,7 @@

-

See the AEM Groovy Extension documentation here for details on registered metaclasses.

+

See the AEM Groovy Extension documentation here for details on registered metaclasses.

\ No newline at end of file From d32d60c3ea1b31cca748b044d9e346c6102ae06c Mon Sep 17 00:00:00 2001 From: Mark Daugherty Date: Wed, 2 Oct 2019 12:42:17 -0500 Subject: [PATCH 6/8] added immediate=true to start services on bundle start. --- .../configuration/impl/DefaultConfigurationService.groovy | 2 +- .../aem/groovy/console/impl/DefaultGroovyConsoleService.groovy | 2 +- .../console/notification/impl/EmailNotificationService.groovy | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/groovy/com/icfolson/aem/groovy/console/configuration/impl/DefaultConfigurationService.groovy b/src/main/groovy/com/icfolson/aem/groovy/console/configuration/impl/DefaultConfigurationService.groovy index 8f1f71a2..0f6bf427 100755 --- a/src/main/groovy/com/icfolson/aem/groovy/console/configuration/impl/DefaultConfigurationService.groovy +++ b/src/main/groovy/com/icfolson/aem/groovy/console/configuration/impl/DefaultConfigurationService.groovy @@ -14,7 +14,7 @@ import org.osgi.service.component.annotations.Modified import org.osgi.service.component.annotations.Reference import org.osgi.service.metatype.annotations.Designate -@Component(service = ConfigurationService) +@Component(service = ConfigurationService, immediate = true) @Designate(ocd = ConfigurationServiceProperties) @Slf4j("LOG") class DefaultConfigurationService implements ConfigurationService { diff --git a/src/main/groovy/com/icfolson/aem/groovy/console/impl/DefaultGroovyConsoleService.groovy b/src/main/groovy/com/icfolson/aem/groovy/console/impl/DefaultGroovyConsoleService.groovy index e9518bc0..34373a88 100755 --- a/src/main/groovy/com/icfolson/aem/groovy/console/impl/DefaultGroovyConsoleService.groovy +++ b/src/main/groovy/com/icfolson/aem/groovy/console/impl/DefaultGroovyConsoleService.groovy @@ -34,7 +34,7 @@ import static com.icfolson.aem.groovy.console.constants.GroovyConsoleConstants.E import static com.icfolson.aem.groovy.console.constants.GroovyConsoleConstants.PARAMETER_DATA import static com.icfolson.aem.groovy.console.constants.GroovyConsoleConstants.PATH_SCRIPTS_FOLDER -@Component(service = GroovyConsoleService) +@Component(service = GroovyConsoleService, immediate = true) @Slf4j("LOG") class DefaultGroovyConsoleService implements GroovyConsoleService { diff --git a/src/main/groovy/com/icfolson/aem/groovy/console/notification/impl/EmailNotificationService.groovy b/src/main/groovy/com/icfolson/aem/groovy/console/notification/impl/EmailNotificationService.groovy index e3e4fad4..ed607877 100644 --- a/src/main/groovy/com/icfolson/aem/groovy/console/notification/impl/EmailNotificationService.groovy +++ b/src/main/groovy/com/icfolson/aem/groovy/console/notification/impl/EmailNotificationService.groovy @@ -13,7 +13,7 @@ import org.osgi.service.component.annotations.Component import org.osgi.service.component.annotations.Reference import org.osgi.service.component.annotations.ReferenceCardinality -@Component(service = NotificationService) +@Component(service = NotificationService, immediate = true) @Slf4j("LOG") class EmailNotificationService implements NotificationService { From 67f0951990c773a37e4c2c50ad5a992b3a1ad5f2 Mon Sep 17 00:00:00 2001 From: Mark Daugherty Date: Wed, 2 Oct 2019 12:51:55 -0500 Subject: [PATCH 7/8] updated configuration service to deny permission for requests when allowed groups are not configured. --- README.md | 2 +- pom.xml | 2 +- .../impl/DefaultConfigurationService.groovy | 35 ++++++++----------- 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 2a2208a3..e9635526 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ The AEM Groovy Console provides an interface for running [Groovy](http://www.gro Groovy Console Version(s) | AEM Version(s) ------------ | ------------- -13.x.x | 6.3, 6.4, 6.5 +14.x.x, 13.x.x | 6.3, 6.4, 6.5 12.x.x | 6.4 11.x.x | 6.3 10.x.x, 9.x.x | 6.2 diff --git a/pom.xml b/pom.xml index 7532f1c5..b7c1ce3b 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ com.icfolson.aem.groovy.console aem-groovy-console jar - 13.0.1-SNAPSHOT + 14.0.0-SNAPSHOT AEM Groovy Console The AEM Groovy Console provides an interface for running Groovy scripts in the AEM container. Scripts can be diff --git a/src/main/groovy/com/icfolson/aem/groovy/console/configuration/impl/DefaultConfigurationService.groovy b/src/main/groovy/com/icfolson/aem/groovy/console/configuration/impl/DefaultConfigurationService.groovy index 8f1f71a2..46021e46 100755 --- a/src/main/groovy/com/icfolson/aem/groovy/console/configuration/impl/DefaultConfigurationService.groovy +++ b/src/main/groovy/com/icfolson/aem/groovy/console/configuration/impl/DefaultConfigurationService.groovy @@ -3,13 +3,12 @@ package com.icfolson.aem.groovy.console.configuration.impl import com.icfolson.aem.groovy.console.configuration.ConfigurationService import groovy.transform.Synchronized import groovy.util.logging.Slf4j +import org.apache.jackrabbit.api.security.user.User import org.apache.jackrabbit.api.security.user.UserManager import org.apache.sling.api.SlingHttpServletRequest -import org.apache.sling.api.resource.ResourceResolver import org.apache.sling.api.resource.ResourceResolverFactory import org.osgi.service.component.annotations.Activate import org.osgi.service.component.annotations.Component -import org.osgi.service.component.annotations.Deactivate import org.osgi.service.component.annotations.Modified import org.osgi.service.component.annotations.Reference import org.osgi.service.metatype.annotations.Designate @@ -26,8 +25,6 @@ class DefaultConfigurationService implements ConfigurationService { @Reference private ResourceResolverFactory resourceResolverFactory - private ResourceResolver resourceResolver - boolean emailEnabled Set emailRecipients @@ -42,15 +39,22 @@ class DefaultConfigurationService implements ConfigurationService { @Override boolean hasPermission(SlingHttpServletRequest request) { - resourceResolver.refresh() + def resourceResolver = resourceResolverFactory.getServiceResourceResolver(null) + + def hasPermission = false - def user = resourceResolver.adaptTo(UserManager).getAuthorizable(request.userPrincipal) + try { + def user = resourceResolver.adaptTo(UserManager).getAuthorizable(request.userPrincipal) as User + def memberOfGroupIds = user.memberOf()*.ID - def memberOfGroupIds = user.memberOf()*.ID + LOG.debug("member of group IDs = {}, allowed group IDs = {}", memberOfGroupIds, allowedGroups) - LOG.debug("member of group IDs = {}, allowed group IDs = {}", memberOfGroupIds, allowedGroups) + hasPermission = allowedGroups ? user.admin || memberOfGroupIds.intersect(allowedGroups as Iterable) : false + } finally { + resourceResolver.close() + } - allowedGroups ? memberOfGroupIds.intersect(allowedGroups as Iterable) : true + hasPermission } @Override @@ -59,15 +63,9 @@ class DefaultConfigurationService implements ConfigurationService { } @Activate - void activate(ConfigurationServiceProperties properties) { - resourceResolver = resourceResolverFactory.getServiceResourceResolver(null) - - modified(properties) - } - @Modified @Synchronized - void modified(ConfigurationServiceProperties properties) { + void activate(ConfigurationServiceProperties properties) { emailEnabled = properties.emailEnabled() emailRecipients = (properties.emailRecipients() ?: []).findAll() as Set allowedGroups = (properties.allowedGroups() ?: []).findAll() as Set @@ -75,9 +73,4 @@ class DefaultConfigurationService implements ConfigurationService { auditDisabled = properties.auditDisabled() displayAllAuditRecords = properties.auditDisplayAll() } - - @Deactivate - void deactivate() { - resourceResolver?.close() - } } From 882e645df2b210ecc53363ac68bd253e8f1891c2 Mon Sep 17 00:00:00 2001 From: Eric Van Geem Date: Wed, 2 Oct 2019 13:30:23 -0500 Subject: [PATCH 8/8] release version. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b7c1ce3b..fa11f646 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ com.icfolson.aem.groovy.console aem-groovy-console jar - 14.0.0-SNAPSHOT + 14.0.0 AEM Groovy Console The AEM Groovy Console provides an interface for running Groovy scripts in the AEM container. Scripts can be