-
Notifications
You must be signed in to change notification settings - Fork 1k
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
fix(#7787): Added userInsensitive for comparrison checks in dbAuth #7979
Conversation
Hmm, I don't love the idea of having an additional field in the database for this functionality. What if we add a config option to const loginOptions = {
+ usernameMatch: 'insensitive',
handler: (user) => {
return user
},
errors: {
usernameOrPasswordMissing: 'Both username and password are required',
usernameNotFound: 'Username ${username} not found',
incorrectPassword: 'Incorrect password for ${username}',
},
expires: 60 * 60 * 24 * 365 * 10,
} And we document which database support insensitive matching. If we really wanted to get fancy we could have a check in the dbAuth code that makes sure the actual database in use supports the option that they passed in and throw our own error if there's a mismatch. |
Hi @cannikin |
@cannikin Here is what I found about the differences for the db's https://www.prisma.io/docs/concepts/components/prisma-client/case-sensitivity
Shall I make it so that it only attempts to add that usernameMatch if you have one defined and ignore if null. |
Yes I like that idea: if you don't provide the option at all then it behaves just the way it does now, and only if you provide a I suggested above that the code could actually compare the value for the option against the database you're using, and warn if the two aren't compatible (like SQLite not supporting an option at all) but that's probably overkill. I would say if the option is present, just give to Prisma, and let Prisma worry about throwing an error if it's invalid. |
@cannikin Brilliant I will get on this. Might be just after the easter break now as got family round :) |
…e insensitive check on db
…or case insensitive check on db
I actually prefer the additional field. It works in all databases |
Co-authored-by: Rob Cameron <cannikin@fastmail.com>
@cannikin merged in your changes. I never was good at spelling 👍 |
My bad! Trigger happy! 🔫 🤠 |
For #7787
What it does:
Fixes an issue in the dbAuth user validation where the check is not case insensitive. This would result in duplicate users if they had different casing.
Approach
I have taken the approach we discussed in the ticket of adding an additional db line item.
Outstanding Questions
David in the Discord channel https://discord.com/channels/679514959968993311/1091099927041556661 has suggested an alternative to this approach (below), I am happy to explore this idea as well if we decide in this PR to do that.
I also have an outstanding Q on my current implementation. I was wondering do I need to define a db migration for existing apps that use the dbAuth or does it only work for new installs of dbAuth. If I do can you point me to the correct place in the code please.