⚒️ Host your own JWT authentication system with Data Tables and token management

3,554 views · ⚒️ Engineering

Description

Description

A production-ready authentication workflow implementing secure user registration, login, token verification, and refresh token mechanisms. Perfect for adding authentication to any application without needing a separate auth service.

Get started with n8n now!

What it does

This template provides a complete authentication backend using n8n workflows and Data Tables:

Why use this template

How to set up

Prerequisites

Setup Steps

  1. Create Data Tables:
  1. Generate Secret Keys: Run this command to generate a random secret:
  node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"

Generate two different secrets for ACCESS_SECRET and REFRESH_SECRET 3. Configure Secrets:

  1. Connect Data Tables:
  1. Activate Workflow:

API Endpoints

Register: POST /webhook/register-user Request body:

{
 "email": "user@example.com",
 "username": "username",
 "password": "password123"
}

Login: POST /webhook/login Request body:

{
 "email": "user@example.com",
 "password": "password123"
}

Returns:

{
 "accessToken": "...",
 "refreshToken": "...",
 "user": {...}
}

Verify Token: POST /webhook/verify-token Request body:

{
 "access_token": "your_access_token"
}

Refresh: POST /webhook/refresh Request body:

{
 "refresh_token": "your_refresh_token"
}

Frontend Integration Example (Vue.js/React)

Login flow:

const response = await fetch('https://your-n8n.app/webhook/login', {
 method: 'POST',
 headers: { 'Content-Type': 'application/json' },
 body: JSON.stringify({ email, password })
});
const { accessToken, refreshToken } = await response.json();
localStorage.setItem('accessToken', accessToken);

Make authenticated requests:

const data = await fetch('https://your-api.com/protected', {
 headers: { 'Authorization': Bearer ${accessToken} }
});

Key Features

Use Cases

Customization

Security Notes

:warning: Important:

Support & Documentation

The workflow includes comprehensive documentation:

Get Started with n8n now!

Tags: authentication, jwt, login, security, user-management, tokens, password-hashing, api, backend

🔗 Nodes Used

Webhook, Execute Workflow Trigger, Data table

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup