Factor out the realm from authentication.