HTTP Basic Authentication from Database for Slim

Wed, Nov 5, 2014

HTTP Basic Authentication middleware comes with simple PDO authenticator. It can be used to authenticate users from database. Authenticator assumes username and hashed password are stored in database. Default name for database table is users. Default column names for username and hash are unsurprisingly user and hash. Column and table names can also be set in options. Hash must be created with password_hash() function. Simplest possible table to store user data looks something like this.