A question about groovy console on AEM cloud | Community
Skip to main content
Level 8
January 3, 2023
Solved

A question about groovy console on AEM cloud

  • January 3, 2023
  • 3 replies
  • 7405 views

We have just discovered the groovy console, which is very powerful but also dangerous (from malicious or accidental use)

 

  1. How do you secure Groovy console on Author on AEM cloud?  The only auth levels provided by AEM cloud admin console are "user" and "administrator" for the author and for publish.  Typically we use dispatcher to block all but our admin VPN IP, but this wont work for author.
  2. What is the point of ever running groovy console on Publish?  If publish was hacked in this way, it would be different from author, and get overwritten.  Surely it should only exist on author, then any changes it makes synced to publish?

Thanks for any tips!

Best answer by makro24

I will share some of my experiences with groovy console.

We are using groovy console mostly for tasks, which can be automated. For example you want to migrate one component into another, you want to perform some content clean ups, you want to regenerate renditions for specific assets, when they don't have a specific rendition generated, and so on and so on. In some cases (like component migration) you will want to do it also on Publish instance, as this will eliminate the need of page activations (which goes in thousands from time to time).

Regarding securit, only specified users/groups can run groovy scripts, which minimizes the risk of being hacked. I would suggest to keep that list as short as possible.

Also, there is a tool called AEM Easy Content Upgrade tool, which adds a feature of running scripts automatically when they are placed in proper structure in your package (and there are other features as well).

This way you don't need to give access to groovy console to anyone, as only admin and AECU service user will be able to run scripts by default through groovy console. Also, you don't need direct access to publishers, as AECU will run the scripts for you.

I've never used it on AEM as a Cloud, but I saw that this tool is compatibile with it, so I would suggest to give it a try.

 

3 replies

joerghoh
Adobe Employee
Adobe Employee
January 3, 2023

You cannot access a publish instance directly on AEM as a Cloud Service, so it does not make any sense to deploy it there.

 

On author you can directly access it, and you should restrict access to it by access control.

TB3dockAuthor
Level 8
January 6, 2023

Thanks Jorg. Access control is not something we have managed to figure out or get working with cloud AEM managed by admin console.  we just use the two profiles AEM provides out of the box (user and admin for each env).   We gave up because of the known issues with groups set in admin console not replicating properly, and our inability to set permissions or groups via build and deployment.

Luckily, groovyConsole does have a way to manage access by setting the group in the admin console, which works when AEM replicates the group set in the admin console (works 95% of the time).  However, this method of controlling access to groovy console isnt used by the easy updater unfortunately.

arunpatidar
Community Advisor
Community Advisor
January 3, 2023

You can restricted groovy for certain users via https://github.com/icfnext/aem-groovy-console#osgi-configuration 

 

To enable access to the Groovy Console from /groovyconsole, update the Groovy Console Configuration Service via the OSGi console configuration page to enable the vanity path. 

 

Script Execution Allowed Groups List of group names that are authorized to use the console. By default, only the 'admin' user has permission to execute scripts. []
Arun Patidar
Level 2
June 6, 2024

Hi @arunpatidar 

I need to update the user.mapping value for the below path. Kindly share the best approach to do the same.

/apps/groovyconsole/osgiconfig/config/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-groovy-console

current

aem-groovy-console-bundle=groovy-console-system-user

 

Expected

aem-groovy-console-bundle=[groovy-console-system-user]

Level 2
June 7, 2024

Hi @lakshmi99 
You can raise a issue here

https://github.com/CID15/aem-groovy-console/issues 


will raise the issue @arunpatidar 

Meantime, I was trying to updating it through groovy script itself. But not its not returning the properties. But the issue here is its still showing as node instead of config file. Any help to resolve it please? Can't change it to config in higher environments as I don't have access.

 

 

import org.osgi.service.cm.ConfigurationAdmin

def admin = getService(ConfigurationAdmin)

def config = admin.getConfiguration("org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-groovy-console")

def properties = config.properties

def String[] mappings =(String[])properties.get("user.mapping") as List

mappings.add("aem-groovy-console-bundle=[groovy-console-system-user]")

properties.put("user.mapping", mappings.toArray(new String[0]))

config.update(properties)

makro24Accepted solution
January 4, 2023

I will share some of my experiences with groovy console.

We are using groovy console mostly for tasks, which can be automated. For example you want to migrate one component into another, you want to perform some content clean ups, you want to regenerate renditions for specific assets, when they don't have a specific rendition generated, and so on and so on. In some cases (like component migration) you will want to do it also on Publish instance, as this will eliminate the need of page activations (which goes in thousands from time to time).

Regarding securit, only specified users/groups can run groovy scripts, which minimizes the risk of being hacked. I would suggest to keep that list as short as possible.

Also, there is a tool called AEM Easy Content Upgrade tool, which adds a feature of running scripts automatically when they are placed in proper structure in your package (and there are other features as well).

This way you don't need to give access to groovy console to anyone, as only admin and AECU service user will be able to run scripts by default through groovy console. Also, you don't need direct access to publishers, as AECU will run the scripts for you.

I've never used it on AEM as a Cloud, but I saw that this tool is compatibile with it, so I would suggest to give it a try.

 

Level 3
July 17, 2024

Hi ,

I am trying to setup groovy console on my local AEM 

Following steps :  https://lucanerlich.com/docs/aem/groovy-console/

My build is failing . Kindly help me.

Error: 

[INFO] Using 9 validators for package of type CONTAINER: jackrabbit-accesscontrol (org.apache.jackrabbit.vault.validation.spi.impl.AccessControlValidator), jackrabbit-filter (org.apache.jackrabbit.vault.validation.spi.impl.AdvancedFilterValidator), jackrabbit-properties (org.apache.jackrabbit.vault.validation.spi.impl.AdvancedPropertiesValidator), jackrabbit-docviewparser (org.apache.jackrabbit.vault.validation.spi.impl.DocumentViewParserValidator), jackrabbit-dependencies (org.apache.jackrabbit.vault.validation.spi.impl.DependencyValidator), jackrabbit-emptyelements (org.apache.jackrabbit.vault.validation.spi.impl.EmptyElementsValidator), jackrabbit-mergelimitations (org.apache.jackrabbit.vault.validation.spi.impl.MergeLimitationsValidator), jackrabbit-packagetype (org.apache.jackrabbit.vault.validation.spi.impl.PackageTypeValidator), jackrabbit-nodetypes (org.apache.jackrabbit.vault.validation.spi.impl.nodetype.NodeTypeValidator)
[ERROR] ValidationViolation: "jackrabbit-filter: Node '/apps/c4c-vendor-packages/container/install/aem-groovy-console-all-17.0.0.zip' is not contained in any of the filter rules", filePath=jcr_root\apps\c4c-vendor-packages\container\install\aem-groovy-console-all-17.0.0.zip

 

Kindly help me