From 44965c9c31a766fee8982b3826d7426d1984b3d9 Mon Sep 17 00:00:00 2001 From: Nick Satterly Date: Sat, 27 Feb 2021 14:05:34 +0100 Subject: [PATCH] feat(auth): add HMAC authentication as config option --- alertaclient/api.py | 4 ++-- alertaclient/cli.py | 1 + alertaclient/config.py | 1 + examples/alerta.conf | 5 +++++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/alertaclient/api.py b/alertaclient/api.py index ea0f9e6..3bd8ada 100644 --- a/alertaclient/api.py +++ b/alertaclient/api.py @@ -32,8 +32,8 @@ class Client: DEFAULT_ENDPOINT = 'http://localhost:8080' - def __init__(self, endpoint=None, key=None, secret=None, token=None, username=None, password=None, timeout=5.0, ssl_verify=True, - ssl_cert=None, ssl_key=None, headers=None, debug=False): + def __init__(self, endpoint=None, key=None, secret=None, token=None, username=None, password=None, timeout=5.0, + ssl_verify=True, ssl_cert=None, ssl_key=None, headers=None, debug=False): self.endpoint = endpoint or os.environ.get('ALERTA_ENDPOINT', self.DEFAULT_ENDPOINT) if debug: diff --git a/alertaclient/cli.py b/alertaclient/cli.py index 663f2e7..9d03530 100644 --- a/alertaclient/cli.py +++ b/alertaclient/cli.py @@ -63,6 +63,7 @@ def cli(ctx, config_file, profile, endpoint_url, output, color, debug): ctx.obj['client'] = Client( endpoint=endpoint, key=config.options['key'], + secret=config.options['secret'], token=get_token(endpoint), username=config.options.get('username', None), password=config.options.get('password', None), diff --git a/alertaclient/config.py b/alertaclient/config.py index d88f5d1..9c46f38 100644 --- a/alertaclient/config.py +++ b/alertaclient/config.py @@ -11,6 +11,7 @@ 'profile': None, 'endpoint': 'http://localhost:8080', 'key': '', + 'secret': None, 'client_id': None, 'username': None, 'password': None, diff --git a/examples/alerta.conf b/examples/alerta.conf index 30257fa..2f75a0b 100644 --- a/examples/alerta.conf +++ b/examples/alerta.conf @@ -19,3 +19,8 @@ key = demo-key [profile development] endpoint = http://localhost:8080 key = demo-key + +[profile hmac-auth] +endpoint = http://localhost:9080/api +key = access-key +secret = secret-key