#
Authentication
User authentication is built on top of NextAuth, with Sign-in-with-Ethereum (SIWE) as an authentication mechanism.
The flow:
- A user must connect their web3 wallet to the Dapp.
- They are asked to sign a login message using their private key to prove ownership of the wallet.
- The signature is sent to the NextAuth backend for verification.
- Once verified, a corresponding JWT (JSON web token) is stored client-side, to be passed in with all subsequent queries to the backend. The token persists across browser sessions, until the user chooses to disconnect their wallet.
If a database record for the user doesn't yet exist then it is created during the backed verification step.