comparison roundup/configuration.py @ 5772:8dbe307bdb57

Finish up login rate limit code. Set config item to 0 disables, make sure config item can't be negative integer.
author John Rouillard <rouilj@ieee.org>
date Fri, 07 Jun 2019 13:50:57 -0400
parents f91da208f26b
children 1151a2b31f1d
comparison
equal deleted inserted replaced
5771:3f00269f3297 5772:8dbe307bdb57
469 """Integer numbers""" 469 """Integer numbers"""
470 470
471 def str2value(self, value): 471 def str2value(self, value):
472 try: 472 try:
473 return int(value) 473 return int(value)
474 except ValueError:
475 raise OptionValueError(self, value, "Integer number required")
476
477 class IntegerNumberGeqZeroOption(Option):
478
479 """Integer numbers greater than or equal to zero."""
480
481 def str2value(self, value):
482 try:
483 v = int(value)
484 if v < 0:
485 raise OptionValueError(self, value,
486 "Integer number greater than or equal to zero required")
487 except OptionValueError:
488 raise # pass through subclass
474 except ValueError: 489 except ValueError:
475 raise OptionValueError(self, value, "Integer number required") 490 raise OptionValueError(self, value, "Integer number required")
476 491
477 class OctalNumberOption(Option): 492 class OctalNumberOption(Option):
478 493
773 "Whether to use HTTP Basic Authentication, if present.\n" 788 "Whether to use HTTP Basic Authentication, if present.\n"
774 "Roundup will use either the REMOTE_USER or HTTP_AUTHORIZATION\n" 789 "Roundup will use either the REMOTE_USER or HTTP_AUTHORIZATION\n"
775 "variables supplied by your web server (in that order).\n" 790 "variables supplied by your web server (in that order).\n"
776 "Set this option to 'no' if you do not wish to use HTTP Basic\n" 791 "Set this option to 'no' if you do not wish to use HTTP Basic\n"
777 "Authentication in your web interface."), 792 "Authentication in your web interface."),
778 (IntegerNumberOption, 'login_attempts_min', "3", 793 (IntegerNumberGeqZeroOption, 'login_attempts_min', "3",
779 "Limit login attempts per user per minute to this number.\n" 794 "Limit login attempts per user per minute to this number.\n"
780 "By default the 4th login attempt in a minute will notify\n" 795 "By default the 4th login attempt in a minute will notify\n"
781 "the user that they need to wait 20 seconds before trying to\n" 796 "the user that they need to wait 20 seconds before trying to\n"
782 "log in again. This limits password guessing attacks and\n" 797 "log in again. This limits password guessing attacks and\n"
783 "shouldn't need to be changed.\n"), 798 "shouldn't need to be changed. Rate limiting on login can\n"
799 "be disabled by setting the value to 0."),
784 (SameSiteSettingOption, 'samesite_cookie_setting', "Lax", 800 (SameSiteSettingOption, 'samesite_cookie_setting', "Lax",
785 """Set the mode of the SameSite cookie option for 801 """Set the mode of the SameSite cookie option for
786 the session cookie. Choices are 'Lax' or 802 the session cookie. Choices are 'Lax' or
787 'Strict'. 'None' can be used to suppress the 803 'Strict'. 'None' can be used to suppress the
788 option. Strict mode provides additional security 804 option. Strict mode provides additional security

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