From e28c698f7e1b64bd8d44b6a086f0cefea1856cd0 Mon Sep 17 00:00:00 2001 From: meeb Date: Mon, 26 Feb 2024 17:01:07 +1100 Subject: [PATCH] add http auth support to healthcheck, related to #472 --- tubesync/healthcheck.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tubesync/healthcheck.py b/tubesync/healthcheck.py index c4076748..840da640 100755 --- a/tubesync/healthcheck.py +++ b/tubesync/healthcheck.py @@ -10,16 +10,22 @@ ''' +import os import sys import requests TIMEOUT = 5 # Seconds +HTTP_USER = os.getenv('HTTP_USER') +HTTP_PASS = os.getenv('HTTP_PASS') def do_heatlhcheck(url): headers = {'User-Agent': 'healthcheck'} - response = requests.get(url, headers=headers, timeout=TIMEOUT) + auth = None + if HTTP_USER and HTTP_PASS: + auth = (HTTP_USER, HTTP_PASS) + response = requests.get(url, headers=headers, auth=auth, timeout=TIMEOUT) return response.status_code == 200