Skip to content

Commit 51b0ac4

Browse files
krivardmelange396
andauthored
Text check for rollout (#1171)
* Fix temporary key and contact point msgs * Removed exceptions no longer in use * UnAuthenticatedException * MissingAPIKeyException * Synced rollout warnings to approved comms * Fixed per minute -> per hour, and added "free" where it was supposed to be * Increase longevity of rate limit warning Co-authored-by: melange396 <[email protected]>
1 parent 806b6b2 commit 51b0ac4

File tree

2 files changed

+9
-25
lines changed

2 files changed

+9
-25
lines changed

src/server/_exceptions.py

-10
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,6 @@ def __init__(self, endpoints: Iterable[str]):
2525
super(MissingOrWrongSourceException, self).__init__(f"no data source specified, possible values: {','.join(endpoints)}", 400)
2626

2727

28-
class UnAuthenticatedException(EpiDataException):
29-
def __init__(self):
30-
super(UnAuthenticatedException, self).__init__("unauthenticated", 401)
31-
32-
33-
class MissingAPIKeyException(EpiDataException):
34-
def __init__(self):
35-
super(MissingAPIKeyException, self).__init__("missing api key", 401)
36-
37-
3828
class ValidationFailedException(EpiDataException):
3929
def __init__(self, message: str):
4030
super(ValidationFailedException, self).__init__(message, 400)

src/server/_security.py

+9-15
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,22 @@
2222
API_KEY_SOFT_WARNING = API_KEY_HARD_WARNING - timedelta(days=14)
2323

2424
# rollout warning messages
25-
# intended usage: in place of API_KEY_WARNING_TEXT
26-
# phase 1 / soft warning: ROLLOUT_WARNING_RATE_LIMIT or ROLLOUT_WARNING_MULTIPLES
27-
# phase 2 / hard warning: (ROLLOUT_WARNING_RATE_LIMIT + PHASE_2_STOPGAP) or (ROLLOUT_WARNING_MULTIPLES + PHASE_2_STOPGAP)
28-
29-
ROLLOUT_WARNING_RATE_LIMIT = "This request exceeded the anonymous limit on requests per minute."
30-
ROLLOUT_WARNING_MULTIPLES = "This request exceeded the anonymous limit on selected multiples."
31-
_ROLLOUT_WARNING_AD_FRAGMENT = "To be exempt from this limit, authenticate your requests with an API key, which will be enforced starting {}. Registration now available at {}.".format(
32-
API_KEY_REQUIRED_STARTING_AT, API_KEY_REGISTRATION_FORM_LINK_LOCAL
33-
)
25+
ROLLOUT_WARNING_RATE_LIMIT = "This request exceeded the rate limit on anonymous requests, which will be enforced starting {}.".format(API_KEY_REQUIRED_STARTING_AT)
26+
ROLLOUT_WARNING_MULTIPLES = "This request exceeded the anonymous limit on selected multiples, which will be enforced starting {}.".format(API_KEY_REQUIRED_STARTING_AT)
27+
_ROLLOUT_WARNING_AD_FRAGMENT = "To be exempt from this limit, authenticate your requests with a free API key, now available at {}.".format(API_KEY_REGISTRATION_FORM_LINK_LOCAL)
3428

35-
PHASE_1_2_STOPGAP = ( # todo: add temporary key
29+
PHASE_1_2_STOPGAP = (
3630
"A temporary public key `{}` is available for use between now and {} to give you time to register or adapt your requests without this message continuing to break your systems."
37-
).format(TEMPORARY_API_KEY, API_KEY_REQUIRED_STARTING_AT)
31+
).format(TEMPORARY_API_KEY, (API_KEY_REQUIRED_STARTING_AT + timedelta(days=7)))
3832

3933

4034
# steady-state error messages
41-
ERROR_MSG_RATE_LIMIT = "Rate limit exceeded for anonymous queries.\nTo remove this limit, register a free API key at {}".format(API_KEY_REGISTRATION_FORM_LINK_LOCAL)
42-
ERROR_MSG_MULTIPLES = "Requested too many multiples for anonymous queries.\nTo remove this limit, register a free API key at {}".format(API_KEY_REGISTRATION_FORM_LINK_LOCAL)
35+
ERROR_MSG_RATE_LIMIT = "Rate limit exceeded for anonymous queries. To remove this limit, register a free API key at {}".format(API_KEY_REGISTRATION_FORM_LINK_LOCAL)
36+
ERROR_MSG_MULTIPLES = "Requested too many multiples for anonymous queries. To remove this limit, register a free API key at {}".format(API_KEY_REGISTRATION_FORM_LINK_LOCAL)
4337
ERROR_MSG_INVALID_KEY = (
44-
"API key does not exist. Register a new key at {} or contact $CONTACT_POINT to troubleshoot".format(API_KEY_REGISTRATION_FORM_LINK_LOCAL)
38+
"API key does not exist. Register a new key at {} or contact [email protected] to troubleshoot".format(API_KEY_REGISTRATION_FORM_LINK_LOCAL)
4539
)
46-
ERROR_MSG_INVALID_ROLE = "Provided API key does not have access to this endpoint, please contact $CONTACT_POINT."
40+
ERROR_MSG_INVALID_ROLE = "Provided API key does not have access to this endpoint. Please contact [email protected]."
4741

4842

4943
def resolve_auth_token() -> Optional[str]:

0 commit comments

Comments
 (0)