Apache Auth Cookie Fu を使ってみた
- Date
- 2007-06-04 (Mon)
- Category
- Web
ちょっと興味があったので、触ってみた。
用意した環境
- CentOS 4 (Kernel 2.6.9-42.0.10)
- Apache 2.2.4
書いたコード
httpd-cookiefu.conf
<Directory /htdocs/cookie/apple> AuthCookieEnable on # AuthCookieDenyAction redirect # AuthCookieRedirectURL http://www.apple.com/ # AuthCookieCheckIP no AuthCookieCheckExpire yes # AuthCookieCookieName ACF # AuthCookieCookieSalt "!Open Sesame!" </Directory>
index.html
<h2>No Cookie</h2> <div id="nocookie"> <iframe src="faces/text.html?" width="700" height="200" style="border:1px solid #999"></iframe> </div> <h2>Cookie</h2> <div id="nocookie"> <iframe src="apple/text.html?" width="700" height="200" style="border:1px solid #999"></iframe> </div>
faces/text.html は人の顔がいっぱい並んだページで、顔写真はすべて faces ディレクトリ以下に並んでいます。apple も同様。
hash_hmac.php
$expire = time() + (3600 * 24) ;
$remoteip = $_SERVER["REMOTE_ADDR"];
$key = '!Open Sesame!';
$message = "$expire,$remoteip";
$hmac = hash_hmac('sha1', $message, $key);
trigger_error("$expire, $remoteip, $key, $message, $hmac", E_USER_NOTICE);
$name = 'ACF';
setcookie ( $name, $hmac, $expire, '/');
想定されるユーザシナリオは…
- index.html にアクセス → 顔は見られる。リンゴは forbidden
- hash_hmac.php にアクセス → クッキーを焼く
- index.html にアクセス → 顔は見られる。リンゴも見られる。
なのですが、今のところ何度やってもリンゴが見られません…
cookie を焼く PHP のコードは会ってると思います。試しに以下のようなコードを書きました。
hmac_test.php
$expire = 1178442572;
$remoteip = '192.168.1.9';
$key = '!Open Sesame!';
$message = "$expire,$remoteip";
$hmac = hash_hmac('sha1', $message, $key);
trigger_error("$expire, $remoteip, $key, $message, $hmac", E_USER_NOTICE);
この出力は Apache Auth Cookie Fu module のページにあるように 5719b9e205cc63d896184c79ced2dd35a3702c18 となっています。
というわけで、apache 側、というか cookie の handling に問題があるのだと思うのだけど…
確認している問題
- アクセス制限のあるページをクッキーなしに見ようとすると、Apache が Segment Fault で落ちる。→一度クッキーを焼くと、Forbidden になる。
- アクセス制限があっても、Options Indexes があると、ファイルの一覧が見られる。
もうちょっと調べてみます。
Comment:24
- yamaz:2007-06-04 (Mon) 17:37
-
ちょっと調べてみます。
- tksh:2007-06-05 (Tue) 00:40
-
ありがとうございます。僕もちらっとソースコードを眺めて、コメントアウトを外してログ取りくらいはできそうなかんじだったので、明日また少しやってみます。
- yamaz:2007-06-19 (Tue) 09:08
-
こんにちは.すごく遅くなりましたが,対応版を作りました。まだ入用でしたらこちらを試してもらえますか?
http://scaleout.jp/tmp/mod_auth_cookie_fu-0.003.tar.gz
バージョンがあり得ないくらい戻ってて,復旧に時間がかかってしまいました...
- yamaz:2007-06-19 (Tue) 11:48
-
> アクセス制限があっても、Options Indexes があると、ファイルの一覧が見られる。
これですが,
Options -Indexes
で対応してもらえますか?もっとうまい方法があるかもしれませんが,
Options indexesはcore機能でindexingの前に認証を割り込ませる方法がちょっと分からなかったです. - tksh:2007-06-19 (Tue) 14:34
-
新しいバージョンを早速試してみました。
|| アクセス制限のあるページをクッキーなしに見ようとすると、
|| Apache が Segment Fault で落ちる。
|| →一度クッキーを焼くと、Forbidden になる。この件は直ってました。ありがとうございます!!
Options の件は了解しました。
ただまだ Cookie を焼いても 403 か 302 が出ますね… valid_cookie 内部から ap_log_error でちょっと確認してみます。が、ちょっと今日は時間がないのでまた今週中くらいにでも。
ちょっと疑問なのは1回のアクセスで ConfigDump が2〜3回出てるんですよね。必ず最後の行が、設定された内容で、最初の1〜2回はデフォルトの内容で出ます。
- No Name:2007-06-19 (Tue) 19:34
-
うーん.ちなみに下記URLで焼いたCookieをそのまま持っていくとどうなりますか?
http://www.scaleout.jp/so/test/cookie_write
> ちょっと疑問なのは1回のアクセスで ConfigDump が2〜3回出てるんですよね
これはAP_INIT_*で定義されたConfig系の関数が複数回呼ばれるということでしょうか?
- tksh:2007-06-19 (Tue) 22:59
-
今は環境がないのですぐ試せません。明日やってみます。
|| > ちょっと疑問なのは1回のアクセスで ConfigDump が
|| > 2〜3回出てるんですよね
||
|| これはAP_INIT_*で定義されたConfig系の関数が複数回呼ばれるということ
|| でしょうか?auth_cookie_fu_handler でコメントアウトされていた5カ所 の ap_log_error を有効にして Apache のエラーログを見ていたら、『ConfigDump が2〜3回出て』いました。実際に読んでいるのは1ページだけなのに、auth_cookie_fu_handler はそれだけ呼ばれていた、という事だと思いますが、これもまた明日もう一度確認してみます。
- agent in yiwu:2011-03-11 (Fri) 20:25
-
This is nice post which I was awaiting for such an artice and I have gained some useful information from this site.
- cheap bridesmaid dresses under 100:2011-07-25 (Mon) 02:33
-
Well,OK.I have to say,what a wonderful blog it is.thank you for your sharing so good articles in the website.I like it very much.It is very interesting in it.Look forward to reading so good articles in the website
- Oakley Lifestyle Sunglasses:2011-07-25 (Mon) 08:12
-
A knowledge, a growth, a good article can make a person to enhance the taste, thank you for sharing, I will carefully read the product to make themselves rich!
discount oakley sunglasses - Rift power leveling:2011-09-15 (Thu) 02:14
-
uses the automatic Jaeger LeCoultre 968 the movement and design beyond their own was first held in 2006 omega replica sub .
- replica watches:2011-09-18 (Sun) 20:56
-
stuff.Veronika Satchel The HYPEexpensive to replace. Maxi dial meaningalready know what their passions.
- gxwatches:2011-09-19 (Mon) 01:22
-
you must ensure your scalp is not oilylasting and having the quality butwinter season and light colors for.
- fake watches:2011-09-21 (Wed) 02:15
-
them as well!as though you still have hair rootssomething new from the new watches Inspired by.
- Louis Vuitton Outlet:2011-10-21 (Fri) 01:57
-
Have you ever dreamed of being as charming as Madonna? Have you ever thought of becoming an envy of all your friends? If so, come to louis vuitton outlet.
- Aaron Rodgers Jersey:2011-11-07 (Mon) 03:18
-
thank you for share the good knowlege. So beautiful posts,all I like,hope to be better then,
and enjoy yourself,good luck in your life. Thanks for your ideas to something. Great post,
thanks very much, please write more and more about this. - Charles Woodson Jersey:2011-11-07 (Mon) 03:19
-
Your blog is very informative.This is obviously one great post.i keep on reading articles from here.
thanks for sharing..
- B.J. Raji Jersey:2011-11-07 (Mon) 03:21
-
I really like this website, And hope you will write more ,thanks a lot for your information.
- cheap clothes:2011-11-28 (Mon) 19:41
-
I very light given you of the article, very good, top, you a
- cheap clothes:2011-11-29 (Tue) 22:32
-
Good article, well worth learning! Very good!
- cartier pasha:2011-12-02 (Fri) 04:31
-
It is possible to get a great deal on designer handbags, but one must be aware of the scams and tricks people try to get away with. If you do decide to purchase a handbag from somewhere other than the actual store or outlet store, make sure to check the purse over before making th
- replica cartier watches:2011-12-02 (Fri) 04:31
-
urchase. Although finding a great deal on a designer handbag is something almost every woman wishes for, you must use caution and common sense. Do that and you will find a designer handbag to fit your style and budget.
- replica breitling:2011-12-02 (Fri) 04:32
-
All nations IWC Vintage Portuguese manual chain to restore ancient ways series wrist watch
In the IWC decisive Portugal wrist watch family, was born in 1939, Portuguese manual chain wrist watch witness a long time goes by. Although this is not the first time to celebrate its - Microsoft Office:2011-12-23 (Fri) 02:42
-
Thanks a lot!
Trackback:0
- TrackBack URL for this entry
- http://blogs.grf-design.com/mt/mt-tb.cgi/214
- Listed below are links to weblogs that reference
- Apache Auth Cookie Fu を使ってみた from The Croton