Send 401 if authentication failed.
Auth-script in ruby.
Auth-script using curl. Fast.
Auth-script that reads DB directly. Slow.