Adding db auth based authentication

I simplified the pull request in one commit to easy revert the funcionality if needed.