Extracting AuthState class

To allow for a plugin to be provided.