Demo application showcasing how to use custom JWT authentication with Particle Auth.
This repository demonstrates how to integrate JSON Web Tokens (JWTs) with Particle Auth to create a secure and efficient authentication system for your dApp. By leveraging JWTs, this app ensures stateless and scalable user authentication, enabling seamless login experiences for users.
Find the full tutorial on the Particle Network's docs: Custom Authentication via JWT
- JWT Generation: Create and manage JWTs using a custom server.
- User Verification: Authenticate users based on predefined criteria.
- Secure Key Management: Utilize RSA keys for signing and verifying JWTs.
- Integration with Particle Auth: Connect JWT-based authentication to Particle Auth for robust user management.
- JWT Decoding: Extract and display user information from JWTs.
The server includes a simulated user in a database.
// Simulate a user in a DB
const PREDETERMINED_USERNAME = 'David';
const PREDETERMINED_USER_ID = '1234567';
Particle Auth Core, a component of Particle Network's Wallet-as-a-Service, enables seamless onboarding to an application-embedded MPC-TSS/AA wallet facilitated by social login, such as Google, GitHub, email, phone number, etc. - as an alternative to Particle Auth, the Auth Core SDK comes with more control over the modal itself, application-embedded popups rather than redirects, and so on.
git clone https://github.com/Particle-Network/jwt-demo-particle-auth.git
cd jwt-server
npm ci
node index
Ensure the server is exposed to the Internet, either by deploying it to a cloud or using Ngrok.
Follow the instructions in the tutorial: Custom Authentication via JWT
cd particle-auth-frontend
yarn install
Or
npm install
This project requires several keys from Particle Network to be defined in .env
. The following should be defined:
NEXT_PUBLIC_PROJECT_ID
, the ID of the corresponding application in your Particle Network dashboard.NEXT_PUBLIC_CLIENT_KEY
, the ID of the corresponding project in your Particle Network dashboard.NEXT_PUBLIC_APP_ID
, the client key of the corresponding project in your Particle Network dashboard.
npm run dev
Or
yarn dev
Particle Auth config is in src/app/layout.tsx
.
Edit the app from src/app/page.tsx
.