copied auth stuff from earlier project