Use a RADIUS server for user authentication. You need php radius extension for this to work. If you get an php segfault your php-radius is too old (see https://bugs.php.net/bug.php?id=60885).