Adobe-Consulting-Services / acs-aem-commons

http://adobe-consulting-services.github.io/acs-aem-commons/
Apache License 2.0
454 stars 600 forks source link

Dispatcher flush not working in publish mode #3117

Closed kavinManickam closed 1 year ago

kavinManickam commented 1 year ago

Required Information

Expected Behavior

On configuring Agents on author for author instance and agents on publish for publish instance should be able to flush dispatcher successfully

Actual Behavior

In publish instance on dispatcher flush page load null pointer exception is observed in logs.

[2023-05-30 11:26:13,735][ERROR][[0:0:0:0:0:0:0:1] [1685512573724] GET /etc/acs-commons/dispatcher-flush/dispatcher-flush.html HTTP/1.1][org.apache.sling.scripting.sightly.render.ObjectModel] Cannot access method results on object [com.adobe.acs.commons.replication.dispatcher.impl.DispatcherFlushModelImpl@1f03504a](mailto:com.adobe.acs.commons.replication.dispatcher.impl.DispatcherFlushModelImpl@1f03504a)

Caused by: java.lang.NullPointerException: null
    at java.base/java.util.Objects.requireNonNull(Objects.java:221)
    at java.base/java.util.Arrays$ArrayList.<init>(Arrays.java:4323)
    at java.base/java.util.Arrays.asList(Arrays.java:4310)
    at com.adobe.acs.commons.replication.dispatcher.impl.DispatcherFlushModelImpl.getResults(DispatcherFlushModelImpl.java:82)

This in return is failing to create CSRF token resulting in 403 error.

[2023-05-30 11:04:50,072][INFO][qtp1034367768-96][log.request] 30/May/2023:11:04:50 +0530 [36] -> POST /etc/acs-commons/dispatcher-flush/dispatcher-flush/_jcr_content/configuration.flush.html HTTP/1.1
[2023-05-30 11:04:50,072][INFO][[0:0:0:0:0:0:0:1] [1685424890072] POST /etc/acs-commons/dispatcher-flush/dispatcher-flush/_jcr_content/configuration.flush.html HTTP/1.1][com.adobe.granite.csrf.impl.CSRFFilter] isValidRequest: empty CSRF token - rejecting
[2023-05-30 11:04:50,072][INFO][[0:0:0:0:0:0:0:1] [1685424890072] POST /etc/acs-commons/dispatcher-flush/dispatcher-flush/_jcr_content/configuration.flush.html HTTP/1.1][com.adobe.granite.csrf.impl.CSRFFilter] doFilter: the provided CSRF token is invalid
[2023-05-30 11:04:50,152][INFO][qtp1034367768-96][log.request] 30/May/2023:11:04:50 +0530 [36] <- 403 text/html 80ms
[2023-05-30 11:04:50,153][INFO][qtp1034367768-96][log.access] [0:0:0:0:0:0:0:1] - admin 30/May/2023:11:04:50 +0530 "POST /etc/acs-commons/dispatcher-flush/dispatcher-flush/_jcr_content/configuration.flush.html HTTP/1.1" 403 11081 "[http://localhost:4503/etc/acs-commons/dispatcher-flush/dispatcher-flush.html/flush/true"](http://localhost:4503/etc/acs-commons/dispatcher-flush/dispatcher-flush.html/flush/true%22) "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36"

Steps to Reproduce

Starting from vanilla instance,

  1. please install service pack 6.5.14 2.Install ACS commons version 6.0.8
  2. Configure Apache-22 dispatcher at any port( localhost:80) 4.Configure Agents in author for author and Agents in Publish for publish with dispatcher configuration

Links

https://archive.apache.org/dist/httpd/

davidjgonzalez commented 1 year ago

@kavinManickam Can you explain this a bit more? Are you running this on. AEM Author or on AEM Publish?

The idea with this tool is would setup agents that can flush dispatcher from AEM Author, not running the UI on Publish and flushing from there.

kavinManickam commented 1 year ago

@davidjgonzalez We are currently installing this on both instances but dispatcher flush is mainly used in publish. The idea here is to setup flush UI in publish and configure "Agents on publish" to flush the dispatcher. This was working with previous ACS versions up to 5.7.0. The main reason to use it in publish is so that the flush paths and flushing method could not be edited.

davidjgonzalez commented 1 year ago

@kavinManickam can you see if updating your configuration.html to the following works?

https://github.com/Adobe-Consulting-Services/acs-aem-commons/blob/695ccc812f7248c102d0b2c8c25b917e0421a333/ui.apps/src/main/content/jcr_root/apps/acs-commons/components/utilities/dispatcher-flush/configuration/configuration.html

I assume youre logged into AEM Publish to execute this right? And you've permissioned the pages so others can flush your cache?

kavinManickam commented 1 year ago

Hi @davidjgonzalez , I tried updating my configuration.html as mentioned above and it is working as expected. I logged in Publish to execute this as well as in author mode. Other members were also able to flush the dispatcher in Publisher

davidjgonzalez commented 1 year ago

Thanks for confirming @kavinManickam ! well get this merged and released!