mod_auth_mysql で認証ができない!!→暗号化が必要でした
久しぶりに自分でゼロからサーバーを立てました…。
腕が鈍ってるorz
CentOS4→CecntOS5で、もの凄くパッケージ内容、使い勝手が変わっていてビックリです。
前置きはさておき「社内サーバーでDMZとWebDavでファイルサーバーしよう!!」と言うミッション。
認証は外部パートナーとのデータやりとりもあるので
アイパス(IDとパスワード)をSQL管理してフォルダ毎に許可を出す。
やっとの思いで mod_auth_mysql をインストールしましたが
【Apache エラーログ】[Wed Feb 18 02:29:53 2009] [error] [client 114.182.67.140] user davuser: password mismatch: /uploads
パスワードが違いますと弾かれます。
???????
あってるよ、パスワード!!
いろいろ見てみると mod_auth_mysql の付属ドキュメント「CONFIGURE」に
怪しい下りを発見。
User_name must be a unique, non-empty field. Its length is however long you
want it to be. Password length of 20 follows new-style crypt() usage; the
older crypt uses shorter encrypted passwords. Any other fields in the named
table will be ignored. The actual field names are configurable using the
parameters listed below. The defaults are "user_name" and "user_passwd"
respectively, for the user ID and the password, and "user_group" for the group
which is optional.
え!?
パスワードは暗号化(ハッシュ?)しましょうと。
で馬鹿正直にcrypt('password')とやってみましたが、mysqlにそんな関数はないと怒られます。
でどうやるんだ?とググったところ
http://dev.mysql.com/doc/refman/5.1/en/encryption-functions.html#function_encrypt
encrypt('password') とやればよいそうです。
例)
insert into user_info values('user_id',encrypt('user_pass'));
ちなみに crypt() はOSの暗号化関数だそうでmysqlのencryptは
OSのcrypt()を呼び出すそうです、知らんかった。
簡単な処理もJAVAに頼ってしまうのもよくないなぁ…
知識が狭くなる。
【暗号化の回避方法】
AuthMySQLPwEncryption none
↑とするとPlainTextでパスワードの紹介ができます。
おまけ:
上記で引用しましたmod_auth_mysql の付属ドキュメント
パスワードフィールドのデフォルト値が「user_passwd」となっておりますが
私が試した環境では「user_password」がデフォルト値になっておりました。
このあたりは安易にデフォルト値使わずに指定しましょうね☆
という指導的ミスかもしれません。
CentOS5
Apache2.2
mod_auth_mysql 3.0.0(※Apache2用のパッチ適用)
| 固定リンク | コメント (0) | トラックバック (0)

最近のコメント