Update auth library

This is a refactor of the authorization code.