Skip to content

Commit 1ecb907

Browse files
Add HMAC capabilities
This adds the capability for HMAC based signing into the reporting client. Signed-off-by: Florian Wagner <[email protected]>
1 parent c60b4ab commit 1ecb907

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ dependencies = [
3232
"frequenz-client-common >= 0.3.0, < 0.4",
3333
"grpcio >=1.70.0, < 2",
3434
"protobuf >= 5.29.3, < 7",
35-
"frequenz-client-base >= 0.8.0, < 0.10.0",
35+
"frequenz-client-base @ git+https://github.com/frequenz-floss/frequenz-client-base-python/@v0.x.x",
3636
]
3737
dynamic = ["version"]
3838

src/frequenz/client/reporting/cli/__main__.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
from pprint import pprint
1010
from typing import AsyncIterator
1111

12+
from frequenz.client.base.authentication import AuthenticationOptions
13+
from frequenz.client.base.channel import ChannelOptions
14+
from frequenz.client.base.signing import SigningOptions
1215
from frequenz.client.common.metric import Metric
1316

1417
from frequenz.client.reporting import ReportingApiClient
@@ -85,6 +88,12 @@ def main() -> None:
8588
help="API key",
8689
default=None,
8790
)
91+
parser.add_argument(
92+
"--secret",
93+
type=str,
94+
help="The secret for the reporting service",
95+
default=None,
96+
)
8897
args = parser.parse_args()
8998
asyncio.run(
9099
run(
@@ -99,6 +108,7 @@ def main() -> None:
99108
service_address=args.url,
100109
key=args.key,
101110
fmt=args.format,
111+
secret=args.secret,
102112
)
103113
)
104114

@@ -116,6 +126,7 @@ async def run( # noqa: DOC502
116126
bounds: bool,
117127
service_address: str,
118128
key: str,
129+
secret: str,
119130
fmt: str,
120131
) -> None:
121132
"""Test the ReportingApiClient.
@@ -130,13 +141,19 @@ async def run( # noqa: DOC502
130141
states: include states in the output
131142
bounds: include bounds in the output
132143
service_address: service address
133-
key: API key
144+
key: API key (per customer)
145+
secret: cryptographic secret of the service (per API)
134146
fmt: output format
135147
136148
Raises:
137149
ValueError: if output format is invalid
138150
"""
139-
client = ReportingApiClient(service_address, key)
151+
auth = AuthenticationOptions(key)
152+
sign = SigningOptions(secret)
153+
154+
channel_options = ChannelOptions(auth=auth, sign=sign)
155+
156+
client = ReportingApiClient(service_address, key, channel_defaults=channel_options)
140157

141158
metrics = [Metric[mn] for mn in metric_names]
142159

0 commit comments

Comments
 (0)