introduce local authentication
fix db selection
code cleanup
add proper AUTN support