A bunch of authentication functions in Scala