diff --git a/met-api/src/met_api/resources/widget_poll.py b/met-api/src/met_api/resources/widget_poll.py index 799932803..02dab70ed 100644 --- a/met-api/src/met_api/resources/widget_poll.py +++ b/met-api/src/met_api/resources/widget_poll.py @@ -89,7 +89,7 @@ def validate_request_format(data): @cors_preflight('POST') @API.route('//responses') class PollResponseRecord(Resource): - """Resource for recording responses for a poll widget. Not require authentication.""" + """Resource for recording responses for a poll widget. Does not require authentication.""" @staticmethod @cross_origin(origins=allowedorigins()) @@ -138,7 +138,7 @@ def is_poll_active(poll_id): @staticmethod def is_poll_limit_exceeded(poll_id, participant_id): - """Check poll limt execeeded or not.""" + """Check poll limit execeeded or not.""" return WidgetPollService.check_already_polled(poll_id, participant_id, 10) @staticmethod diff --git a/met-api/src/met_api/utils/ip_util.py b/met-api/src/met_api/utils/ip_util.py index 9698ea0f8..81dd614fa 100644 --- a/met-api/src/met_api/utils/ip_util.py +++ b/met-api/src/met_api/utils/ip_util.py @@ -25,6 +25,9 @@ def hash_ip(ip_address): """ # Retrieve the secret key from Flask configuration with a fallback empty string secret_key = current_app.config.get('SECRET_KEY', '') + + # Extract the fragment (e.g., first three octets of an IPv4 address) + ip_fragment = '.'.join(ip_address.split('.')[:3]) # Concatenate the IP address and secret key, and hash the resulting string - return sha256(f'{ip_address}{secret_key}'.encode()).hexdigest() + return sha256(f'{ip_fragment}{secret_key}'.encode()).hexdigest()