Make the auth logic more explicit and warnings if necessary
This commit is contained in:
parent
d80e716822
commit
9b071ff92f
1 changed files with 12 additions and 5 deletions
|
@ -59,11 +59,18 @@ def ping_monitor(hook_config, config_filename, state, monitoring_log_level, dry_
|
||||||
username = hook_config.get('username')
|
username = hook_config.get('username')
|
||||||
password = hook_config.get('password')
|
password = hook_config.get('password')
|
||||||
|
|
||||||
auth = (
|
auth = None
|
||||||
requests.auth.HTTPBasicAuth(username, password)
|
if (username and password) is not None:
|
||||||
if (username and password) is not None
|
auth = requests.auth.HTTPBasicAuth(username, password)
|
||||||
else None
|
logger.info(f'{config_filename}: Using basic auth with user {username} for Ntfy')
|
||||||
)
|
elif username is not None:
|
||||||
|
logger.warn(
|
||||||
|
f'{config_filename}: Password missing for Ntfy authentication, defaulting to no auth'
|
||||||
|
)
|
||||||
|
elif password is not None:
|
||||||
|
logger.warn(
|
||||||
|
f'{config_filename}: Username missing for Ntfy authentication, defaulting to no auth'
|
||||||
|
)
|
||||||
|
|
||||||
if not dry_run:
|
if not dry_run:
|
||||||
logging.getLogger('urllib3').setLevel(logging.ERROR)
|
logging.getLogger('urllib3').setLevel(logging.ERROR)
|
||||||
|
|
Loading…
Reference in a new issue