I started setting up a local AEM dispatcher after years today. The start wasn't great as after setting up the ssl, vhost and dispatcher.any, i got to the error that the dispatcher doesn't work with the Apache shipped with mac. that was the first learning of the day.
Thanks to brew, i was up and running with the latest Apache in minutes.
Once the installation was working, i started working on the filter rules and was annoyed with the numbering of rules. This is what my filter looked like.
I could see there are many problems with it
Guess what. You can. A quick test confirmed that i can name the rules the way i want. Here is the same configuration with the clean code applied.
I hope this was helpful.
Thanks to brew, i was up and running with the latest Apache in minutes.
Once the installation was working, i started working on the filter rules and was annoyed with the numbering of rules. This is what my filter looked like.
/filter {
/0001 { /type "deny" /glob "*" }
/0002 { /type "allow" /url "/content*" }
/0003 { /type "allow" /extension '(clientlibs|css|gif|ico|js|png|swf|jpe?g|woff2?)' }
/0004 { /type "allow" /url "/libs/cq/personalization/*" } #enable personalization
/0005 { /type "deny" /selectors '((sys|doc)view|query|[0-9-]+)' /extension '(json|xml)' }
/0006 { /type "deny" /path "/content" /selectors '(feed|rss|pages|languages|blueprint|infinity|tidy)' /extension '(json|xml|html)' }
/0007 { /type "allow" /url "/libs/granite/csrf/token.json*" }
}
I could see there are many problems with it
- The number doesn't have any significance on the rule order. The rules are evaluated top-to-bottom irrespective of the rule number.
- It's a common scenario that rule needs to be added in the middle to optimize evaluation performance. If you are a person like me who prefer keeping things in order, this becomes annoying as all the rule below the insertion requires a +1 in the rule number. that makes git diff messy.
- One really need to review the complete line to understand what the rule offers as the rule number doesn't give any hint.
Guess what. You can. A quick test confirmed that i can name the rules the way i want. Here is the same configuration with the clean code applied.
/filter {
/deny-all { /type "deny" /glob "*" }
/allow-content { /type "allow" /url "/content*" }
/allow-extensions { /type "allow" /extension '(clientlibs|css|gif|ico|js|png|swf|jpe?g|woff2?)' }
/allow-cq-personalization { /type "allow" /url "/libs/cq/personalization/*" }
/deny-selectors-on-all-paths { /type "deny" /selectors '((sys|doc)view|query|[0-9-]+)' /extension '(json|xml)' }
/deny-selectors-on-content { /type "deny" /path "/content" /selectors '(feed|rss|pages|languages|blueprint|infinity|tidy)' /extension '(json|xml|html)' }
/allow-csrf-token { /type "allow" /url "/libs/granite/csrf/token.json*" }
}
I hope this was helpful.
Thanks for sharing such a great blog Keep posting.. Loop Dispatch
ReplyDelete