提AEM供了旨在防止跨站點請求偽造攻擊的框架。 為了正確使用此框架,您需要對調度程式配置進行以下更改:
請確保根據現有配置更新以下示例中的規則編號。 請記住,調度程式將使用最後一個匹配規則來授予允許或拒絕,因此將規則放在現有清單的底部附近。
/clientheaders
在author-farm.any和publish-farm.any的部分,將以下條目添加到清單底部:CSRF-Token
author-farm.any
和 publish-farm.any
或 publish-filters.any
檔案,添加以下行以允許請求 /libs/granite/csrf/token.json
通過調度員。/0999 { /type "allow" /glob " * /libs/granite/csrf/token.json*" }
/cache /rules
的 publish-farm.any
,添加規則以阻止調度程式快取 token.json
的子菜單。 通常作者會繞過快取,因此您不必將規則添加到 author-farm.any
。/0999 { /glob "/libs/granite/csrf/token.json" /type "deny" }
要驗證配置是否正在工作,請在DEBUG模式下查看dispatcher.log以驗證token.json檔案是否未被快取且未被篩選器阻止。 您應看到類似於:
... checking [/libs/granite/csrf/token.json]
... request URL not in cache rules: /libs/granite/csrf/token.json
... cache-action for [/libs/granite/csrf/token.json]: NONE
您還可以驗證apache中的請求是否成功 access_log
。 「/libs/granite/csrf/token.json」的請求應返回HTTP 200狀態代碼。