-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.x] Protect against ambiguous columns (#43278)
* [8.x] Protect against ambiguous columns Resolving #43274 * Updating tests.
- Loading branch information
1 parent
97e68c6
commit a6d9307
Showing
2 changed files
with
10 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
a6d9307
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change breaks my application:
Before with only $model->getAuthIdentifierName() was working:
"command":{"find":"users","filter":{"$and":[{"_id":{"$oid":"628e6230b59b425fd10c1543"}},{"deleted_at":null}]},"limit":1
Now with the change ($model->qualifyColumn($model->getAuthIdentifierName())):
"command":{"find":"users","filter":{"$and":[{"users._id":{"$oid":"628e6230b59b425fd10c1543"}},{"deleted_at":null}]},"limit":1
the search column users._id not working
a6d9307
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BenWalters any suggestion?
a6d9307
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rennorodrigo what's the use case? Is it when calling retrieveById?
a6d9307
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, when i call auth()->user()->id from the controller , the JWTGuard is calling on the line:
return $this->user = $this->provider->retrieveById($payload['sub']);
a6d9307
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/PHP-Open-Source-Saver/jwt-auth/blob/main/src/JWTGuard.php line 108
a6d9307
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rennorodrigo are you using MongoDB?
a6d9307
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you're suffering the same issue as posted here - mongodb/laravel-mongodb#2424
And I'm partly making that assumption on the fact that your primary key is
_id
and notid
as that is what's set by their abstract model - https://github.com/jenssegers/laravel-mongodb/blob/master/src/Eloquent/Model.phpThere's a workaround suggested in the issue listed above. I've also commented there with what I think needs to be changed in that package.
a6d9307
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, i am using mongodb
a6d9307
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! this workaround fixed the error