This can be simplified to:
/**
* Authenticate user
*
* @param \Magento\Framework\App\ActionInterface $subject
* @return void
*/
public function beforeDispatch(\Magento\Framework\App\ActionInterface $subject)
{
$loginUrl = $this->customerUrl->getLoginUrl();
if (!$this->customerSession->authenticate($loginUrl)) {
$subject->getActionFlag()->set('', $subject::FLAG_NO_DISPATCH, true);
}
}
A trick: a «before» plugin can avoid declaration of unused last arguments if it needs not modify any argument