[core] RemoteUser middleware fixes