Base on https://www.drupal.org/project/restrict_node_page_view but ported for Drupal 8 and 9.https://www.drupal.org/project/new_restrict_node_page_view