This patch allows lighttpd to authenticate users against mySQL DBbr
NOTE: Only basic auth is implemented. Passwords are stored as MD5 hash in DB
tar xzvf lighttpd-1.4.11.tar.gz # (unpack source) patch -p0 < lighttpd-1.4.11-mysql_auth.patch # (apply patch) cd lighttpd-1.4.11 ./configure --with-mysql # (add more options if you want) make make install
make mysql db and user (read mySQL doc's if you don't know how)br
auth.backend = "mysql" auth.backend.mysql.host = "localhost" auth.backend.mysql.user = "db_user" auth.backend.mysql.pass = "db_pass" auth.backend.mysql.db = "db_name" auth.backend.mysql.port = "0" # (for default port 0, always needed) auth.backend.mysql.socket = "" # (for default leave blank, always needed) auth.backend.mysql.users_table = "users_table" auth.backend.mysql.col_user = "col_name_username" auth.backend.mysql.col_pass = "col_name_password" # (md5 hash of password) auth.backend.mysql.col_realm = "col_realm_name"
configure lighttpd to use it (same as every other auth)
auth.require = ( "/some_path" => ( "method" => "basic", "realm" => "some_realm", "require" => "some_user", ) )
test & Njoy
P.S. patch include more complicated setup with separate table for domains.
If you are interested please contact with me to obtain more information.
Bugs, Patches and Suggestions
Send me E-Mail: drJeckyll@Jeckyll.net
original version is located here
(automatically load mod_authn_mysql with mod_auth for compatibility with
existing config usage via patches in various distros, e.g. FreeBSD)
#3 Updated by Anonymous almost 9 years ago
This patch work fine for me> johann.
But i think this patch has SQL Injection probrem.
i think it should use mysql_real_escape_string().
such as attached file.
but i think this version still has a probrem.
i think all of MySQL related lines should be in #ifdef HAVE_MYSQL ... #endif.
Sorry i could not resolve this probrem.
i read ldap related lines. i think there are many ldap line at outside ifdef. i can't understand it. sorry.
#5 Updated by Anonymous over 8 years ago
Sorry, for the late response:
I tried the latest patch, but it doesnt worked for me. Patching and build was fine, but on restart after configuration, i got:
2008-03-21 14:27:37: (plugin.c.165) dlopen() failed for: /usr/lib/lighttpd/mod_auth.so /usr/lib/lighttpd/mod_auth.so: undefined symbol: mysql_query 2008-03-21 14:27:37: (server.c.621) loading plugins finally failed
The System is a Gentoo Linux with mysql installed and mysql-support in lighttpd.
Sorry, but atm i have no time to dig deeper...
#7 Updated by Anonymous over 8 years ago
DrJeckyll's latest patch made my 1.4.19 segfault, so I've here's my version, based on the one by Taguchi.
I've also added support for digest authentication, in which the 'password' field should look like this:
This is easy to use when you create a MySQL view:
CREATE VIEW digest AS SELECT username AS username, MD5(CONCAT(username,':',realm,':',password)) AS password, realm AS realm FROM auth
#13 Updated by lordbone over 4 years ago
- Target version set to 1.4.x
Compiling the 1.4.28 patch against the current lighty version (1.4.31) doesn't seem to work.
1.4.28 - works! (tested)
1.4.29 - works! (tested)
1.4.30 - breaks compile (tested)
1.4.31 - breaks compile (tested)
http_auth.c: In function 'http_auth_basic_password_compare': http_auth.c:987:24: error: 'MD5_CTX' undeclared (first use in this function) http_auth.c:987:24: note: each undeclared identifier is reported only once for each function it appears in http_auth.c:987:32: error: expected ';' before 'Md5Ctx' http_auth.c:991:24: warning: implicit declaration of function 'MD5_Init' http_auth.c:991:34: error: 'Md5Ctx' undeclared (first use in this function) http_auth.c:992:24: warning: implicit declaration of function 'MD5_Update' http_auth.c:993:24: warning: implicit declaration of function 'MD5_Final'
Taking a look at the changelog, I've spotted this:
[mod_auth] Fix signedness error in http_auth (CVE-2011-4362)
Any1 want to take a shot at writing a patch for 1.4.x ?
FYI: FreeBSD has a set of patches at https://svnweb.freebsd.org/ports/head/www/lighttpd/files/ for auth with mysql
Also available in: Atom