| | 111 | == ptifall on Satisfy any == |
| | 112 | * 「Satisfy any」における落とし穴 |
| | 113 | * 目標 |
| | 114 | 1. 特定のIPからは、認証せず見られる |
| | 115 | 1. 特定のIP以外からは、認証後見られる |
| | 116 | 1. 特定のディレクトリ(URL)は、認証に関係なく見られない |
| | 117 | * ディレクトリごとに細かく設定するため.htaccessで制御したい |
| | 118 | * 例としては内部向けpukiwikiなど |
| | 119 | |
| | 120 | === 標準的な設定 === |
| | 121 | * /etc/apache2/sites-enabled/some.vhost.conf |
| | 122 | {{{ |
| | 123 | <Directory /> |
| | 124 | AllowOverride Limit |
| | 125 | |
| | 126 | Satisfy any |
| | 127 | Order deny,allow |
| | 128 | Deny from all |
| | 129 | Allow from XX.YY.ZZ.XYZ |
| | 130 | AuthType Digest |
| | 131 | AuthName "Authorized" |
| | 132 | AuthUserFile /path/to/.htdigest |
| | 133 | Require valid-user |
| | 134 | </Directory> |
| | 135 | }}} |
| | 136 | |
| | 137 | * /path/to/www/wikiplus/attach/.htaccess |
| | 138 | {{{ |
| | 139 | Order allow,deny |
| | 140 | Deny from all |
| | 141 | }}} |
| | 142 | |
| | 143 | === 問題点 === |
| | 144 | * 上位設定(この場合some.vhost.conf)で「Satisfy any」としているため、.htaccessにおいて「deny from all」に'''関係なく'''valid-userであればアクセスできてしまう。 |
| | 145 | * wget -S --spider --user username --password password !http://example.jp/www/wikiplus/attach/index.html |
| | 146 | {{{ |
| | 147 | HTTP/1.1 200 OK |
| | 148 | }}} |
| | 149 | |
| | 150 | === solution === |
| | 151 | * some.vhost.conf |
| | 152 | {{{ |
| | 153 | AllowOverride Limit FileInfo AuthConfig |
| | 154 | }}} |
| | 155 | * Satisfyを.htaccessで使うには「AuthConfig」が必要 |
| | 156 | * .htaccess |
| | 157 | {{{ |
| | 158 | Order allow,deny |
| | 159 | Deny from all |
| | 160 | Satisfy all |
| | 161 | }}} |
| | 162 | |
| | 163 | * 全ての.htaccessを書き換える必要がありスマートでないので、conf側だけで収まる設定を模索中 |
| | 164 | |