Next Auth V5 | how to implement authentication with Drizzle + Google, Github, Resend, Passkeys Guide

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 พ.ย. 2024

ความคิดเห็น • 22

  • @naumanahmed19
    @naumanahmed19 2 หลายเดือนก่อน +1

    good work, i am also building auth for my open community project defiantly will check it

    • @tobitacklestech
      @tobitacklestech  2 หลายเดือนก่อน

      Thanks, I hope you wont face to many Problems!

  • @Playmiza
    @Playmiza 2 หลายเดือนก่อน

    Please show the process of setting up user authentication from scratch using Next.js, Drizzle, and Resend.

    • @tobitacklestech
      @tobitacklestech  หลายเดือนก่อน +1

      With Auth.js?

    • @Playmiza
      @Playmiza หลายเดือนก่อน

      @@tobitacklestech It can be done with Auth.js or Clerk.

  • @paleo3142
    @paleo3142 11 วันที่ผ่านมา

    Hi Tobi! Great video, but I am quite confused by one thing in your set up:
    At what point exactly are you handling the auth check?
    I am asking because I am currently running into issues with verifying DB sessions in middleware, which runs on the edge runtime, which doesn't work with the drizzle adaptor.
    In your middleware file, you seem to check authentication by assigning isLoggedIn to if the request contains a cookie authjs.session-token , but are you certain that this token is synced to your DB sessions?

    • @tobitacklestech
      @tobitacklestech  11 วันที่ผ่านมา

      This is done by auth.js itself… so the sync with the db

    • @paleo3142
      @paleo3142 11 วันที่ผ่านมา

      @@tobitacklestech I am not sure that's the case. I rewatched the video again, and I believe that the only auth check you are doing is at 7.16, but at no point are you relying on Auth.js to actually verify the authentication though?
      You are just checking if there is a authjs.session-token present in the cookies, but at what point is this being verified?

    • @paleo3142
      @paleo3142 11 วันที่ผ่านมา

      @@tobitacklestech I might miss something, but I truly don't see where authentication is actually taking place in your video.
      Here are few examples:
      1. If you manually set a authjs.session-token cookie in your browser, you'll be authenticated. You are never relying on auth.js to verify this. Anyone could manually set this cookie with an empty value to be signed in as far as I am aware.
      2. I double checked your auth.js file and you aren't specifying a session strategy; so Auth.js is automatically setup to handle auth using database sessions.
      If you handle this in the middleware, you'll have to separate your auth config from the rest since the drizzle adaptor won't run on edge runtime, and if you would actually validate a db session in the middleware, you'd get an error.
      Again: I could be missing something, but the only check I am seeing is to verify if a cookie exists by name, but anyone can manually set a cookie by name in a browser session.

    • @tobitacklestech
      @tobitacklestech  11 วันที่ผ่านมา

      @@paleo3142 honestly I can’t tell you all the magic… this project already was a bit older :/ the exact auth logic is abstracted away from the user

    • @paleo3142
      @paleo3142 11 วันที่ผ่านมา

      @@tobitacklestech I cloned the project and opened it. It's what I thought: there is no auth check. If you go the middleware you'll see that your isLoggedIn variable is always set to true as long as authjs.session-token is present by name.
      I didn't even have to sign in here as i had another project open on localhost:3000 that had the cookie as well, and it sets your isLoggedIn to true just because it was present.
      I've set up auth with different libraries before, and frankly Auth.js sucks, but you should ensure that auth actually happens, even if the library "abstracts" it away.
      There's other cool stuff in your repo, but it might be worth re doing this video as it essentially shows how to set up auth without actually performing it.

  • @nicolaedel2945
    @nicolaedel2945 2 หลายเดือนก่อน

    awesome video, I needed that 😮

  • @alfredbasi5937
    @alfredbasi5937 2 หลายเดือนก่อน +1

    I have been struggling to implement authjs properly as the docs is not very helpful, and being new there aren't much resources on how to implement it properly especially on production. Thank you very much, really appreciate it!
    Also a few questions:
    1) if a user does login with google, github or magic links, where and when do you save the user information in the db?
    2) what editing software are you using? The animations in the video look sick

    • @tobitacklestech
      @tobitacklestech  2 หลายเดือนก่อน

      Hey Alfred,
      1. the User Information is Safed automatically and under the hood with auth.js but you can implement hooks inside the auth.ts to implement additional functionality while this is happening
      2. thanks! I use ScreenStudio for mac ✌🏻

  • @farastray1
    @farastray1 หลายเดือนก่อน

    Im trying to adapt this code but keep getting this error:
    Module not found: Can't resolve '@auth/drizzle-adapter'

    • @tobitacklestech
      @tobitacklestech  หลายเดือนก่อน

      Did you install it? Npm install …

    • @farastray1
      @farastray1 หลายเดือนก่อน

      @@tobitacklestech yes, it was something else (dumb) ... I think the drizzle config was messed up pointing to an old schema. Thanks for putting this together, I got all my auth working now, prolly just want to switch to jwt sessions.

  • @oluboinoni9617
    @oluboinoni9617 2 หลายเดือนก่อน

    Do you have the discord group?

    • @tobitacklestech
      @tobitacklestech  2 หลายเดือนก่อน

      Which one do you need?

    • @oluboinoni9617
      @oluboinoni9617 2 หลายเดือนก่อน

      @@tobitacklestech the next-auth and I don't mind if you can provide the two 😊

    • @oluboinoni9617
      @oluboinoni9617 2 หลายเดือนก่อน

      @@tobitacklestech the next-auth. I don't mind if u can provide the two groups