Skip to content

Commit 841fd25

Browse files
committed
Fixes typo and improve README
1 parent 3ee8536 commit 841fd25

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ def device_data():
277277
metrics.set_device_parameters(
278278
secret_key=device.secret_key,
279279
data_format=data_format,
280+
last_request_count=device.last_request_count,
280281
last_request_timestamp=device.last_request_timestamp
281282
)
282283
# We check the authentication
@@ -312,6 +313,9 @@ def device_data():
312313

313314
## Changelog
314315

316+
### 2023-10-12 - v0.5.1
317+
- Fixes typo in function name
318+
315319
### 2023-10-12 - v0.5.0
316320
- Added convenience functions for accessing the current request count and request timestamp
317321
- Improved documentation on how to avoid replay attacks

openpaygo/metrics_response.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,15 @@ def is_auth_valid(self):
5252
self.auth_method = auth_string[:2]
5353
new_signature = OpenPAYGOMetricsShared.generate_request_signature_from_data(self.request_dict, self.auth_method, self.secret_key)
5454
if auth_string == new_signature:
55-
request_count = self.request_dict.get('request_count')
56-
if request_count and self.last_request_count and request_count <= self.last_request_count:
55+
request_count = self.get_request_count()
56+
if request_count and self.last_request_count and request_count > self.last_request_count:
5757
return False
58-
timestamp = self.request_dict.get('timestamp')
59-
if timestamp and self.last_request_timestamp and timestamp <= self.last_request_timestamp:
58+
timestamp = self.get_request_timestamp()
59+
if timestamp and self.last_request_timestamp and timestamp > self.last_request_timestamp:
6060
return False
61-
return True
61+
# Either the request count or timestamp is required
62+
if request_count or timestamp:
63+
return True
6264
return False
6365

6466
def get_simple_metrics(self):
@@ -76,7 +78,7 @@ def get_simple_metrics(self):
7678
def get_data_timestamp(self):
7779
return self.request_dict.get('data_collection_timestamp', self.timestamp)
7880

79-
def get_request_timestmap(self):
81+
def get_request_timestamp(self):
8082
return self.request_timestamp
8183

8284
def get_request_count(self):

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = openpaygo
3-
version = 0.5.0
3+
version = 0.5.1
44
url = https://github.com/EnAccess/OpenPAYGO-python/
55
description-file=README.md
66
license_files=LICENSE

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
setup(
55
name="openpaygo",
66
packages=find_packages(),
7-
version='0.5.0',
7+
version='0.5.1',
88
license='MIT',
99
author="Solaris Offgrid",
1010
url='https://github.com/EnAccess/OpenPAYGO-python/',

0 commit comments

Comments
 (0)