Server side authentication

WIP - need to add tests

see #120