From 44eb91dbee5d56435ce904e764e7681817eaeed4 Mon Sep 17 00:00:00 2001 From: Florian Wagner Date: Mon, 16 Jun 2025 16:16:24 +0200 Subject: [PATCH 1/2] Update Readme for HMAC Signed-off-by: Florian Wagner --- README.md | 11 ++++++++--- RELEASE_NOTES.md | 7 ++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 08fbb9a..f1bd7e7 100644 --- a/README.md +++ b/README.md @@ -39,14 +39,18 @@ pip install frequenz-client-reporting==$VERSION ```python from datetime import datetime, timedelta +import os from frequenz.client.common.metric import Metric from frequenz.client.reporting import ReportingApiClient # Change server address SERVER_URL = "grpc://replace-this-with-your-server-url:port" -API_KEY = open('api_key.txt').read().strip() -client = ReportingApiClient(server_url=SERVER_URL, key=API_KEY) +AUTH_KEY = os.environ['REPORTING_API_AUTH_KEY'].strip() +# It is recommended to use a proper secret store to get the secret +# For local development, make sure not to leave it in the shell history +SIGN_SECRET= os.environ['REPORTING_API_SIGN_SECRET'].strip() +client = ReportingApiClient(server_url=SERVER_URL, auth_key=AUTH_KEY, sign_secret=SIGN_SECRET) ``` Besides the `microgrid_id`, `component_id`s, `metrics`, start, and end time, @@ -157,7 +161,8 @@ microgrid component data from the reporting API. ```bash reporting-cli \ --url localhost:4711 \ - --key=$( +* The `key` parameter of the client has been renamed to `auth_key` ## New Features * Add HMAC generation capabilities. - * The new CLI option "key" can be used to provide the server's key. - * The client itself now has a "key" argument in the constructor. + * The new CLI option "sign_secret" can be used to provide the server's HMAC secret. + * The client itself now has a "sign_secret" argument in the constructor. + * Update documentation describing how to use the above options. ## Bug Fixes From 7c758ac7650b71c88ba0a04f38bedc65438a55ce Mon Sep 17 00:00:00 2001 From: Florian Wagner Date: Mon, 16 Jun 2025 16:40:48 +0200 Subject: [PATCH 2/2] Fix bug in CLI Argument renaming Signed-off-by: Florian Wagner --- src/frequenz/client/reporting/cli/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frequenz/client/reporting/cli/__main__.py b/src/frequenz/client/reporting/cli/__main__.py index 6f0563b..9085055 100644 --- a/src/frequenz/client/reporting/cli/__main__.py +++ b/src/frequenz/client/reporting/cli/__main__.py @@ -102,7 +102,7 @@ def main() -> None: states=args.states, bounds=args.bounds, service_address=args.url, - auth_key=args.key, + auth_key=args.auth_key, fmt=args.format, sign_secret=args.sign_secret, )