Repository navigation
Conversation
- New PasswordDefinitionValidator (a MicroORM EntityValidatorInterface): a plain password outside the definition throws InvalidArgumentException, a stored hash is not checked - UsersService sets it on the users repository when it has a PasswordDefinition, so a user created with new and saved through UsersRepository or MicroORM's Repository is checked too - The validator declared on the user model's TableAttribute still runs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
ByJG\Authenticate\Validator\PasswordDefinitionValidator, a MicroORMEntityValidatorInterface. A plain password outside thePasswordDefinitionthrowsInvalidArgumentException; a stored hash (bcrypt or SHA-1) is not checked.UsersServicesets it on the users repository when it is given aPasswordDefinition. A user created withnew UserModel(...)used to be saved without any check (only users created or loaded by the service had the definition); now every save is checked, throughUsersService,UsersRepositoryor MicroORM'sRepository.#[TableAttribute(validator: ...)]still runs after it.Projects using byjg/config get the definition through DI (it is injected into
UsersService's constructor), so a model no longer needs to fetch it from the container.Tests
PasswordUpgradeTest: a weak password is rejected and a valid one saved through the service,UsersRepositoryandRepository; the model's own validator still runs; a loaded user with an old SHA-1 hash weaker than the rules is saved unchanged. Removing the wiring or the chaining fails the matching tests. PHPUnit 186 tests and Psalm pass.