partial integration of Ben Edmunds ION_AUTH Librrary