Next-Auth with my own supplied credentials (from a MySQL database)

Hello! I am creating an application that will be for internal employees. I would like to use Next-Auth for authentication. However for now I have only tried out the standard providers like (Discord, GitHub, Google etc..) For this project I have to use my own credentials. Supplied from a database that I host. I have tried looking at the web for some examples on how to do this, but im not able to find any good examples. In the docs you get a lot of the code for you, but not the logic for verifying the user/password and getting it from the database. Does anyone have a good example/tutorial for this? That would work in a real life application. I have heard bcrypt is good for hashing? πŸ™‚
17 Replies
Leonidas
Leonidasβ€’3y ago
Take a look at blitz auth. I find it easier to wrap my head around what is happening (more declarative api) and how to therefore alter it if needed. Also password auth is the default there: https://blitzjs.com/docs/auth
Leonidas
Leonidasβ€’3y ago
Bcrypt is good, argon2 is even better☝🏼 I would recommend to simply create a new starter project with the above blitz toolkit and afterwards take a look at the signing endpoints provided in the starter project for signing up, logging in/out, resetting password, … - that way you get a pretty good overview Note: you dont have to use the whole toolkit, the auth module is a standalone package* i only recommend to start with a new project to get to see the actual auth code fast so u dont waste your time and get to see their actual implementation.
sommeeeR
sommeeeROPβ€’3y ago
thanks i will try blitz then πŸ™‚ if anyone see this thread and wanna provide me with more examples, feel free to spit it in πŸ˜„
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
sommeeeR
sommeeeROPβ€’3y ago
as i mentioned in my first post here i dont want any third party provider. i wanna host this myself
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
sommeeeR
sommeeeROPβ€’3y ago
i have read this of course, but it doesnt show you an example on how you could fetch and login users from your own database. the logic for hashing/dehashing etc you have to write that yourself, and thats what i need an example of
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
sommeeeR
sommeeeROPβ€’3y ago
yes
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
sommeeeR
sommeeeROPβ€’3y ago
i know how the process works, i just want to see some example code
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
rocawear
rocawearβ€’3y ago
Hello, I did this as a project. Feel free to check how I did it to get inspiration! https://github.com/ruhap/t3-credentials
GitHub
GitHub - ruhap/t3-credentials: t3 stack with next-auth credential p...
t3 stack with next-auth credential provider. Contribute to ruhap/t3-credentials development by creating an account on GitHub.
sommeeeR
sommeeeROPβ€’3y ago
thanks i'll try it out
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
rocawear
rocawearβ€’3y ago
Thanks for sharing
Unknown User
Unknown Userβ€’3y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server