fix(auth): allow zero string credentials - #810
Merged
stevebauman merged 1 commit intoSep 10, 2026
Merged
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The change precisely addresses PHP empty("0") behavior and includes targeted regression tests for both username and password cases.
Pull request overview
This PR fixes LDAP authentication credential validation so the string "0" is treated as a valid (non-empty) username/password, avoiding PHP empty() semantics that incorrectly classify "0" as empty.
Changes:
- Update
Guard::attempt()to validate credentials with strict empty-string checks (=== '') instead ofempty(). - Add unit-test regression coverage for
"0"username and"0"password inGuardTest.
File summaries
| File | Description |
|---|---|
src/Auth/Guard.php |
Adjusts credential validation to accept "0" as a valid string and proceed to bind. |
tests/Unit/Auth/GuardTest.php |
Adds regression tests ensuring "0" credentials are accepted and binding proceeds as expected. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
stevebauman
approved these changes
Sep 10, 2026
Member
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.
Summary
Fixes authentication credential validation so string
"0"is treated as a valid non-empty username or password.Previously
Guard::attempt()used PHPempty()checks. In PHP,empty("0") === true, so a password or username of"0"incorrectly triggeredUsernameRequiredException/PasswordRequiredExceptioninstead of attempting LDAP bind.Changes
empty($username)with$username === ''empty($password)with$password === ''"0""0"Why
A zero
0string is not an empty credential. Applications using validation rules such as Laravel’srequired|stringaccept"0"as present, but LdapRecord rejected it as missing. This caused valid input to be treated as absent before LDAP bind was attempted.Validation
./vendor/bin/phpunit --filter='test_attempt_allows_zero_string'./vendor/bin/phpunit tests/Unit/Auth/GuardTest.php./vendor/bin/pint --dirtyTargeted auth tests pass. Full suite was not run locally because the PHP LDAP extension/constants are unavailable in my local environment.