#!/usr/bin/perl
use FCGI;
while (FCGI::accept >= 0) {
if( $ENV{'HTTP_AUTHORIZATION'} ) {
# This value can be further decoded to get the actual username and password and then
# perform some kind of user validation. This program only checks for the presence of
# of this environment param and is not really bothered about its value
print( "Status: 200\r\n" );
print( "\r\n" );
} else {
print( "Status: 401\r\n" );
print( "WWW-Authenticate: basic realm=\"foo\"\r\n" );
print( "\r\n" );
}
}
Example obj.conf settings for the above example:
위 예에 사용되는 obj.conf 코드:
<Object name="responder.fcgi"> AuthTrans fn="auth-fastcgi" app-path="/fastcgi/apps/auth/SimpleAuth.pl" bind-path="localhost:3432" Service fn="responder-fastcgi" app-path="/foo/fastcgi-enabled-php-installation/bin/php" bind-path="localhost:3433" app-env="PHP_FCGI_CHILDREN=8" min-procs=1 </Object>
http://localhost/fcgi/php/ListDir.php에 대한 첫 요청이 수신되면 브라우저에 인증 대화 상자가 표시됩니다. 사용자가 사용자 이름과 비밀번호를 입력하고 나면 "/tmp" 디렉토리의 내용이 나열됩니다.