Some work on the authentication, mostly wrong for now.