HTTP authentication is generally used to restrict access to site, it is generally used if site is intended for specific user groups or to restrict access to development server.
Drupal 8 provides contributed module named shield to restrict access. You can enable HTTP authetication using the following steps
- Download shield module from https://www.drupal.org/project/shield and place it in modules directory
- Login to your site as Admin
- From module list "admin/modules" enable "PHP Authentication shield"
- Goto "Admin > Configuration > System > Shield"(admin/config/system/shield)
- Add desired user name and password and save the configuration
Note: As of now Drupal 8 basic_auth module and shield module cannot co-exist together