Alfrescoメモ
先日からAlfrescoをお試しで構築していて、その構築中に遭遇した事象のメモです。
Alfresco
Alfrescoとはエンタープライズ向けのコンテンツ管理・文書管理ツールです。
公式Webサイト: https://www.alfresco.com/jp/
構成
フロントエンドをリバースプロキシとして Apache httpd (+mod_proxy) 、バックエンドを Alfresco とし、ポート80のみ公開することを目指しました(https化はとりあえず置いといて)。
リバースプロキシの設定
Apache側は以下のように設定
ProxyRequests Off ProxyPass /alfresco http://127.0.0.1:8080/alfresco ProxyPassReverse /alfresco http://127.0.0.1:8080/alfresco ProxyPass /share http://127.0.0.1:8080/share ProxyPassReverse /share http://127.0.0.1:8080/share
エラー
この設定で /share にアクセス、ログインしたところ、 share.log にCSRF攻撃が可能です的なエラーメッセージが記録されダッシュボードが表示できませんでした。
[org.alfresco.web.site] [http-apr-8080-exec-5] javax.servlet.ServletException: Possible CSRF attack noted when asserting referer header
解決方法
ググったところ、Tomcat の CSRF チェックに使用するURLをリファラに設定されるURL(ブラウザに入力されるURL)と同一設定にすれば良いようです。
次のファイルを開く。
${alfresco_root}/tomcat/webapps/share/WEB-INF/classes/alfresco/share-security-config.xml
ファイルを開いたら次の範囲をコピー。
<config evaluator="string-compare" condition="CSRFPolicy"> ~ </config>
次のファイルを開く。
${alfresco_root}/tomcat/shared/classes/alfresco/web-extension/share-config-custom.xml
この記述の直後くらいにペースト(他の
<!-- Disable the CSRF Token Filter --> <!-- <config evaluator="string-compare" condition="CSRFPolicy" replace="true"> <filter/> </config> --> <!-- To run the CSRF Token Filter behind 1 or more proxies that do not rewrite the Origin or Referere headers: 1. Copy the "CSRFPolicy" default config in share-security-config.xml and paste it into this file. 2. Replace the old config by setting the <config> element's "replace" attribute to "true" like below: <config evaluator="string-compare" condition="CSRFPolicy" replace="true"> 3. To every <action name="assertReferer"> element add the following child element <param name="referer">http://www.proxy1.com/.*|http://www.proxy2.com/.*</param> 4. To every <action name="assertOrigin"> element add the following child element <param name="origin">http://www.proxy1.com|http://www.proxy2.com</param> -->
configタグを書き換え
<config evaluator="string-compare" condition="CSRFPolicy"> ↓ <config evaluator="string-compare" condition="CSRFPolicy" replace="true">
refererとoriginタグをリバースプロキシにアクセスする際のFQDNやIPアドレスに変更。複数のプロキシサーバーがある時などは |(パイプ) で記述する(例: http://proxy1.com/|http://proxy2.com )。こうすることで以降に書かれている {referer} や {origin} といった変数部分に代入されるらしい。
<!-- Override and set this property with a regexp that if you have placed Share behind a proxy that does not rewrite the Referer header. --> <referer>http://proxy.domain/.*</referer> <!-- Override and set this property with a regexp that if you have placed Share behind a proxy that does not rewrite the Origin header. --> <origin>http://proxy.domain</origin>
Alfrescoを再起動
${alfresco_root}/alfresco.sh stop ${alfresco_root}/alfresco.sh start
これでエラー無しにログインすることができました。