copied Brian's revised Auth.pm from github