カスタム検索
このエントリーをはてなブックマークに追加
tomo.gif (1144 ツバツイツト)line.gif (927 ツバツイツト)line.gif (927 ツバツイツト)line.gif (927 ツバツイツト)To previous pageTo home pageMailing to me

データベース(MySQL)を参照して認証する方法

Modified: 24 June 2009
Created: 20 September 2008

参考にさせていただいたページ

http://modauthmysql.sourceforge.net/CONFIGURE

http://blog.katsuma.tv/2007/10/mod_auth_mysql_basic_auth.html


モジュールのインストール

MySQLで認証する場合は、以下のモジュールが必要です。

# yum -y install mod_auth_mysql

モジュールをインストールした後は、Apacheの再起動が必要です。


設定してみる

MySQLに、認証させるユーザ名とパスワードを登録したデータベースのテーブルを作成し、".htaccess"に以下のようにデータベースの情報を設定します。

AuthMySQLEnable On
AuthMySQLSocket /var/lib/mysql/mysql.sock
AuthMySQLHost mysql.good-stream.com
AuthMySQLUser tomo
AuthMySQLPassword tomopw
AuthMySQLDB tomodb
AuthMySQLUserTable user
AuthMySQLNameField id
AuthMySQLPasswordField pw
AuthMySQLPwEncryption none
AuthMySQLNoPasswd Off
AuthGroupFile /dev/null
AuthType Basic
AuthName "Please enter username and password"
require valid-user


各コマンドの説明

AuthMySQLEnable On 機能させるためにOnにする
AuthMySQLSocket /var/lib/mysql/mysql.sock CentOSでは、この設定にする
AuthMySQLHost mysql.good-stream.com データベースのホスト名やIPアドレス
AuthMySQLUser tomo データベースの接続ユーザ
AuthMySQLPassword tomopw データベースの接続ユーザのパスワード
AuthMySQLDB tomodb データベースの名称
AuthMySQLUserTable user テーブルの名称
AuthMySQLNameField id 認証するユーザのIDが登録してあるフィールド名
AuthMySQLPasswordField pw 認証するユーザのID
AuthMySQLPwEncryption none パスワードの暗号化処理
AuthMySQLNoPasswd Off パスワードなしはNGに設定
AuthGroupFile /dev/null 決まり文句
AuthType Basic 決まり文句
AuthName "Please enter username and password" 認証画面に表示される文字列を指定する
require valid-user 決まり文句


パスワード暗号化の種類

none not encrypted (plain text) (パスワード暗号化)
crypt UNIX crypt() encryption
scrambled MySQL PASSWORD encryption (MySQLのPASWWORDで暗号化した場合)
md5 MD5 hashing
aes Advanced Encryption Standard (AES) encryption
sha1 Secure Hash Algorihm (SHA1)

To previous pageTo home pageMailing to meJump to Top of pageline.gif (927 ツバツイツト)line.gif (927 ツバツイツト)tomo.gif (1144 ツバツイツト)
カスタム検索



このエントリーをはてなブックマークに追加