Remove custom evennia pwd validator for more pwd flexibility. Resolve #3415

This commit is contained in:
Griatch 2024-02-25 11:54:53 +01:00
parent 0edcebea0f
commit 32e9520db9
4 changed files with 14 additions and 71 deletions

View file

@ -2,28 +2,35 @@
## main branch
- [Feature] Add `evennia.ON_DEMAND_HANDLER` for making it easier to implement
timed element with the on-demand approach (Griatch)
- [Fix] Remove `AMP_ENABLED` setting since it services no real purpose and
erroring out on setting it would make it even less useful (Griatch).
- [Fix] `services` command with no args would traceback (regression) (Griatch)
- [Feature] Add [`evennia.ON_DEMAND_HANDLER`][new-ondemandhandler] for making it
easier to implement changes that are calculated on-demand (Griatch)
- [Feature][pull3412]: Make it possible to add custom webclient css in
`webclient/css/custom.css`, same as for website (InspectorCaracal)
- [Feature][pull3367]: [Component contrib][pull3367extra] got better
inheritance, slot names to choose attr storage, speedups and fixes (ChrisLR)
- [Fix] Remove `AMP_ENABLED` setting since it services no real purpose and
erroring out on setting it would make it even less useful (Griatch).
- [Feature] Remove too-strict password restrictions for Evennia logins, using
django defaults instead for passwords with more varied characters.
- [Fix] `services` command with no args would traceback (regression) (Griatch)
- [Fix][pull3423]: Fix wilderness contrib error moving to an already existing
wilderness room (InspectorCaracal)
- [Fix][pull3425]: Don't always include example the crafting recipe when
using the crafting contrib (InspectorCaracal)
- [pull3426]: Traceback banning a channel using with only one nick
- [Fix][pull3426]: Traceback banning a channel using with only one nick
(InspectorCaracal)
- [pull3434]: Adjust lunr search weights to void clashing of cmd-aliases over
- [Fix][pull3434]: Adjust lunr search weights to void clashing of cmd-aliases over
keys which caused some help entries to shadow others (InspectorCaracal)
- Doc fixes (InspectorCaracal, Griatch)
[new-ondemandhandler][https://www.evennia.com/docs/latest/Components/OnDemandHandler.html]
[pull3412]: https://github.com/evennia/evennia/pull/3412
[pull3423]: https://github.com/evennia/evennia/pull/3423
[pull3425]: https://github.com/evennia/evennia/pull/3425
[pull3426]: https://github.com/evennia/evennia/pull/3426
[pull3434]: https://github.com/evennia/evennia/pull/3434
[pull3367]: https://github.com/evennia/evennia/pull/3367
[pull3367extra]: https://www.evennia.com/docs/latest/Contribs/Contrib-Components.html
## Evennia 3.1.1

View file

@ -69,20 +69,6 @@ class TestDeprecations(TestCase):
)
class ValidatorTest(BaseEvenniaTest):
def test_validator(self):
# Validator returns None on success and ValidationError on failure.
validator = EvenniaPasswordValidator()
# This password should meet Evennia standards.
self.assertFalse(validator.validate("testpassword", user=self.account))
# This password contains illegal characters and should raise an Exception.
from django.core.exceptions import ValidationError
self.assertRaises(ValidationError, validator.validate, "(#)[#]<>", user=self.account)
class ThrottleTest(BaseEvenniaTest):
"""
Class for testing the connection/IP throttle.

View file

@ -39,52 +39,3 @@ class EvenniaUsernameAvailabilityValidator:
_("Sorry, that username is already taken."), code="evennia_username_taken"
)
class EvenniaPasswordValidator:
def __init__(
self,
regex=r"^[\w. @+\-',]+$",
policy="Password should contain a mix of letters, spaces, digits and @/./+/-/_/'/, only.",
):
"""
Constructs a standard Django password validator.
Args:
regex (str): Regex pattern of valid characters to allow.
policy (str): Brief explanation of what the defined regex permits.
"""
self.regex = regex
self.policy = policy
def validate(self, password, user=None):
"""
Validates a password string to make sure it meets predefined Evennia
acceptable character policy.
Args:
password (str): Password to validate
user (None): Unused argument but required by Django
Returns:
None (None): None if password successfully validated,
raises ValidationError otherwise.
"""
# Check complexity
if not re.findall(self.regex, password):
raise ValidationError(_(self.policy), code="evennia_password_policy")
def get_help_text(self):
"""
Returns a user-facing explanation of the password policy defined
by this validator.
Returns:
text (str): Explanation of password policy.
"""
return _(
"{policy} From a terminal client, you can also use a phrase of multiple words if "
"you enclose the password in double quotes.".format(policy=self.policy)
)

View file

@ -1096,7 +1096,6 @@ AUTH_PASSWORD_VALIDATORS = [
},
{"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator"},
{"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator"},
{"NAME": "evennia.server.validators.EvenniaPasswordValidator"},
]
# Username validation plugins