I would like to use LDAP Authorization with my instance of lsws-2.1.2-std-i386-linux on x86 gentoo with a 2.6.13-ck7 kernel against some version of openldap configured for no read access to the crypted password. Having no access to the ldap servers' root password rules out lsws buildin support for ldap authentcation. Why don't you support "real" authentication, so that no special priviledges are needed? Why does lsws still open a connection to the ldap server even though no ldap using realm is configured?
Because lsws ldap auth couldn't work, I thought about using a fcgi perl app in the authorizer role. I saved the following perl script for testing at /opt/lsws/DEFAULT/fcgi-bin/ldap.fcgi and did chmod +x on it.
I created a new fcgi authorizer in my vhost settings like this:
I switched to the vhost security page and wondered why fcgi authorizers can not be used to create a realm. Does that ultimatly mean, that under no circumstances whatever so I can use an fcgi authorizer to protect /awstats because it only allows to setup a realm? Why are realms and authorizers treatet differently anyway? It looks like a bad design decision to me, that should be fixed as fast as possible.
Consulting the manual I finally found the proper solution. I created a new static context inside my vhost settings like so:
The other settings were set to N/A. I put a bogus index.html inside /opt/lsws/DEFAULT/edit. After setting the log level to high and switching debug on, I restarted the server.
Accessing /edit/index.html showed the ldap file without even asking for authentication. The error.log made no indication that fcgi is even tried:
Did I miss something in the manual? Why doesn't it even try to use the fcgi authorizer? How can I fix my misconfiguration?
Because lsws ldap auth couldn't work, I thought about using a fcgi perl app in the authorizer role. I saved the following perl script for testing at /opt/lsws/DEFAULT/fcgi-bin/ldap.fcgi and did chmod +x on it.
Code:
#!/usr/bin/perl
use FCGI;
while (FCGI::accept >= 0)
{
if( $ENV{'REMOTE_USER' } eq "foo" &&
$ENV{'REMOTE_PASSWD'} eq "bar" )
{
print( "Status: 200\n\n" );
}
else
{
print( "Status: 401\n\n" );
print( "WWW-Authenticate: basic realm=\"foo\"\n\n" );
}
}
__END__
Code:
Name LDAP Auth
Address uds://tmp/lshttpd/ldapauth.sock
Max Connections 3
Environment
Initial Request Timeout (secs) 60
Retry Timeout (secs) 0
Response Bufferring No
Auto Start Yes
Command /opt/lsws/DEFAULT/fcgi-bin/ldap.fcgi
Back Log 20
Instances 3
Priority 0
Consulting the manual I finally found the proper solution. I created a new static context inside my vhost settings like so:
Code:
URI /edit
Location /opt/lsws/DEFAULT/edit
Accessible Yes
Authentication Name LDAP Auth
Authorizer [VHost Level]: LDAP Auth
Add Default Charset Off
Accessing /edit/index.html showed the ldap file without even asking for authentication. The error.log made no indication that fcgi is even tried:
Code:
2005-10-15 20:43:41.934 [DEBUG] [*:80] 1 connections accepted!
2005-10-15 20:43:42.057 [DEBUG] [192.168.3.1:59511-0] HttpIOLink::handleEvents() events=1!
2005-10-15 20:43:42.057 [DEBUG] [192.168.3.1:59511-0] HttpConnection::onReadEx(), state: 0!
2005-10-15 20:43:42.057 [DEBUG] [192.168.3.1:59511-0] readToHeaderBuf().
2005-10-15 20:43:42.057 [DEBUG] [192.168.3.1:59511-0] Read from client: 416
2005-10-15 20:43:42.057 [DEBUG] [192.168.3.1:59511-0] processHeader() return 0, header state: 3.
2005-10-15 20:43:42.057 [DEBUG] [192.168.3.1:59511-0#Example] New request:
Method=[GET], URI=[/edit/index.html],
QueryString=[]
Content Length=0
2005-10-15 20:43:42.057 [DEBUG] [192.168.3.1:59511-0#Example] Find context with URI: [/edit/], location: [/opt/lsws/DEFAULT/edit/]
2005-10-15 20:43:42.057 [DEBUG] [192.168.3.1:59511-0#Example] processContextPath() return 0
2005-10-15 20:43:42.058 [DEBUG] [192.168.3.1:59511-0#Example] readyCacheData() return 0
2005-10-15 20:43:42.058 [DEBUG] [192.168.3.1:59511-0#Example] Written to client: 213
2005-10-15 20:43:42.058 [DEBUG] [192.168.3.1:59511-0#Example] m_pHandler->onWrite() return 0
2005-10-15 20:43:42.058 [DEBUG] [192.168.3.1:59511-0#Example] HttpConnection::flush()!
2005-10-15 20:43:42.058 [DEBUG] [192.168.3.1:59511-0#Example] HttpConnection::nextRequest()!
2005-10-15 20:43:42.058 [DEBUG] [192.168.3.1:59511-1] processNewReq() return 0.
2005-10-15 20:43:42.058 [DEBUG] [192.168.3.1:59511-1] readToHeaderBuf() return 0.