Add auth

Creating a PR for discussion of the changes etc; not yet ready or tested.

See Issue 23.