-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Case insensitive signup #5634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Case insensitive signup #5634
Conversation
2. add _auth_data_anonymous to specialQueryKeys...whatever that is!
Codecov Report
@@ Coverage Diff @@
## master #5634 +/- ##
===========================================
+ Coverage 16.25% 83.53% +67.27%
===========================================
Files 166 169 +3
Lines 11632 11734 +102
===========================================
+ Hits 1891 9802 +7911
+ Misses 9741 1932 -7809
Continue to review full report at Codecov.
|
Now with a quick first pass.
|
FYI, to anyone following this, it is my goal to allow mixed case username's, but not to allow two usernames that would be equivalent in a case insensitive comparison. |
@acinader I should have sometime this week to look. |
i should probably take care of email too.... |
1. also make email validation case insensitive 2. update comments to reflect what this change does
@dplewis @davimacedo Hi Guys. I'd like to get this resolved. @davimacedo any interest in reviewing this? Any questions? @dplewis I could use your help on two things:
|
@aprato i think i've addressed your concerns too. |
@acinader The PR looks good to me for what it aims to do, but I have two questions:
|
I've just found out why Postgres is failing. You are searching for _auth_data_anonymous and it does not exist in the User class (it works well for Mongo but does not work for Postgres). You just need to add the following line of code right after the line https://github.com/parse-community/parse-server/blob/master/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js#L965:
|
I'm starting with the assumption that if a user puts in a username of 'TomWFox', we need to preserve the case and cannot simply lowercase it on save. I'd also want to check how Google and GitHub handle it. i.e. can @TomWFox login to GitHub with In any event, I view that a separate, but related issue that is not exacerbated by fixing case sensitive sign up.
I'm hoping that I can get some guidance or a pointer to an existing test from @dplewis on how to cover the AuthAdapter cases for anonymous and things like facebook. Addressing the AuthAdapter is also blocker. ...back to drawing board. |
@davimacedo do you use postgress, or do you just use for testing with parse? |
@acinader I can login as |
|
I've only looked into collation in Postgres casually so far ( i did install it and am looking at how to migrate one of our large mongo db's into it so I can get real query statistics. Unfortunately, it'll be a few days before I can turn back to this issue. Let me know what you think if you have the chance. |
@acinader I love the approach you chose. Let me know if you need any help. |
@acinader from what I can tell this adds behaviour that I think most devs would expect based on other platforms. I can have a look to see if there are any points in the docs that would need changing based on this new behaviour but I would say the most important thing is making the change clear to existing devs in the changelog. |
@dplewis i think this is ready for your review |
Nice catch! I’ll address. Thanks |
unique username that do collide when compared insensitively can still be created.
@dplewis I looked at that section of code and I have no idea how one would even get there! I looked at git history for a bit and it looks to me that the code section you highlighted came about a year before we added unique constraints on username and password. While it's possible that we should rip out the section, I'd don't want to do that as it really isn't part of this change I am trying to make. My changes only affect username and email address validation. When checking validation (which isn't done for anonymous users, for example), the check is more strict, prohibiting both exact matches as well as case insensitive matches, but the database itself has to permit all but an exact match to handle the corner case of anonymous users. In reviewing what you pointed out, I did want to make extra sure that I am not breaking anonymous users in the rare case that there is a case insensitive collision which I added with 201839a. I don't know what to do about Postgres, but I think the mongo implementation here is solid. |
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 honestly was thinking the same thing. I have no idea why its there or can we reach it. Maybe there is a test that runs against it that can reach it?
The changes look good to me!
that was a good question! interesting to see the stuff that isn't covered. I'll merge this in tomorrow. I can either cook up a releasee tomorrow or wait a week as I'll be away from the keyboard next week. thanks! |
wordsmith the changelog
Hi guys, Any link with #4883 ? :) |
Hi @oallouch I didn't implement it in a generic way but you could look at the code changes i made here if you wanted to do it and i'd be willing to help you with it if i can find the time. |
* Always delete data after each, even for mongo. * Add failing simple case test * run all tests * 1. when validating username be case insensitive 2. add _auth_data_anonymous to specialQueryKeys...whatever that is! * More case sensitivity 1. also make email validation case insensitive 2. update comments to reflect what this change does * wordsmithery and grammar * first pass at a preformant case insensitive query. mongo only so far. * change name of parameter from insensitive to caseInsensitive * Postgres support * properly handle auth data null * wip * use 'caseInsensitive' instead of 'insensitive' in all places. * update commenet to reclect current plan * skip the mystery test for now * create case insensitive indecies for mongo to support case insensitive checks for email and username * remove unneeded specialKey * pull collation out to a function. * not sure what i planned to do with this test. removing. * remove typo * remove another unused flag * maintain order * maintain order of params * boil the ocean on param sequence i like having explain last cause it seems like something you would change/remove after getting what you want from the explain? * add test to verify creation and use of caseInsensitive index * add no op func to prostgress * get collation object from mongocollection make flow lint happy by declaring things Object. * fix typo * add changelog * kick travis * properly reference static method * add a test to confirm that anonymous users with unique username that do collide when compared insensitively can still be created. * minot doc nits * add a few tests to make sure our spy is working as expected wordsmith the changelog Co-authored-by: Diamond Lewis <findlewis@gmail.com>
Hi @rdhelms
You should not expect a user with email That, of course, would be good and a logical next step from this pull request. |
Thanks for the clarification @acinader 👍🏻 |
todo:
configurabilityfixes: #3990