新兵器、登場。

tmx2003-07-29











2003-07-25の続き。さらに、mod_auth_external-2.1.17、インストールメモ。


~/work/mod_auth_external-2.1.17以下で、
$ /usr/local/apache/bin/apxs -c mod_auth_external.c
suして、
# /usr/local/apache/bin/apxs -i -a mod_auth_external.so

さらに、/usr/local/apache/conf/httpd.confを編集(下記を追加)。


AddExternalAuth pwauth /home/tmx/ひみつ☆/dummy_auth_ext.pl
SetExternalAuthMethod pwauth pipe

で、あぱっち再起動。

dummy_auth_ext.plはこんな感じ。


#!/usr/bin/perl -Tw

# Get the user name
my $user= ;
chomp $user;

# Get the password name
my $pass= ;
chomp $pass;

print STDERR "user: $user\n";
print STDERR "pass: $pass\n";

exit 0;

さらに、認証をかけるための.htaccessはこんな感じ。


AuthExternal pwauth
AuthName "Restricted Access Area"
AuthType Basic
require valid-user

CGI(Perl)からは$ENV{'REMOTE_USER'}で認証時のユーザ名が取れることは分かった


#!/usr/bin/perl

print "Content-type: text/html\n\n";
while (($key, $value) = each %ENV) {
print "$key = $value</BR>\n";
}

ので、PHPからも取ってみる。


<? echo($_SERVER['REMOTE_USER']); ?>
こんな感じで取れることを確認。

以上。


以下のWebページを参考にさせていただきました。

ありがとうございます。

mod_auth_externalが意外と重そうなコトが判明。どうしようかなー。

  • 7/30 あぱっち再起動のタイミングが間違ってたのを修正。