Home Assistant HTTP Based Authentication Backend

This recipe is to authenticate users using a web server providing Basic HTTP authentication for it users.

This is useful if you want to consolidate users/passwords in a single system. So instead of managing users on Home Assistant you can have all users managed from a central location.

It uses the Home Assistant command line authentication provider and the curl command.

To make it work is quite simple. Copy this script to your /config directory as curl_auth.sh:

Add the following lines to your configure.yaml:

homeassistant:
  auth_providers:
    - type: command_line
      command: /config/curl_auth.sh
      args: [ "http://your-web-site-url/" ]
      meta: true

Make sure that you modify the URL in the configuration to a web server that is doing Basic HTTP authentication. It uses curl for checking URLs, so http and https protocols would work.

If using https with self-signed certificates, you need to pass the -k option which is then passed to curl. See curl(1).

Example:

args: [ "-k", "https://your-web-site-url/" ]