diff roundup/cgi/wsgi_handler.py @ 7556:273c8c2b5042

fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection. Failed API login rate limiting with expiring lockout added.
author John Rouillard <rouilj@ieee.org>
date Wed, 19 Jul 2023 20:37:45 -0400
parents 07ce4e4110f5
children 0fe2b9f6e19f
line wrap: on
line diff
--- a/roundup/cgi/wsgi_handler.py	Tue Jul 18 23:18:09 2023 -0400
+++ b/roundup/cgi/wsgi_handler.py	Wed Jul 19 20:37:45 2023 -0400
@@ -21,6 +21,15 @@
 BaseHTTPRequestHandler = http_.server.BaseHTTPRequestHandler
 DEFAULT_ERROR_MESSAGE = http_.server.DEFAULT_ERROR_MESSAGE
 
+try:
+    # python2 is missing this definition
+    http_.server.BaseHTTPRequestHandler.responses[429]
+except KeyError:
+    http_.server.BaseHTTPRequestHandler.responses[429] = (
+         'Too Many Requests',
+        'The user has sent too many requests in '
+        'a given amount of time ("rate limiting")'
+    )
 
 class Headers(object):
     """ Idea more or less stolen from the 'apache.py' in same directory.

Roundup Issue Tracker: http://roundup-tracker.org/