|
1 | | -# Secure auth with NodeJS |
2 | | -> Login and registration system with TOTP (Time-based One-Time Password), password hashing using bcrypt, and some basic server-side validation. |
3 | | -
|
4 | | -## Features |
5 | | -- Hash the password with bcrypt before saving it to the database. |
6 | | -- Server-side checks: alphanumeric character validation for the username, minimum and maximum length checks for both password and username, check if the username is already registered, and a maximum attempt limit for entering the OTP code. |
7 | | -- Handling of pending login requests awaiting OTP code verification, with expiration after 5 minutes. |
8 | | -- Client-side QR code generation to easily add the secret key to your authentication app (e.g. Google Authenticator). |
9 | | -- Simple use of JSON to send and receive requests, with realistic status codes for responses. |
10 | | -- Use SQL parameters to prevent SQL injection. |
11 | | - |
12 | | -## How to use |
13 | | -### Install the dependencies |
| 1 | +# Secure Authentication with Node.js |
| 2 | + |
| 3 | +> Un sistema di registrazione e autenticazione professionale con supporto a **TOTP (Time-based One-Time Password)**, hashing sicuro delle password tramite **bcrypt** e solide validazioni lato server. |
| 4 | +
|
| 5 | + |
| 6 | + |
| 7 | +Language: |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | +## Caratteristiche principali |
| 20 | + |
| 21 | +* **Archiviazione sicura delle password** |
| 22 | + Tutte le password vengono sottoposte ad hashing con **bcrypt** prima di essere salvate nel database. |
| 23 | + |
| 24 | +* **Validazione completa** |
| 25 | + |
| 26 | + * Controllo alfanumerico per il nome utente |
| 27 | + * Verifica della lunghezza minima e massima di username e password |
| 28 | + * Prevenzione della registrazione con username duplicati |
| 29 | + * Limitazione dei tentativi di inserimento OTP |
| 30 | + |
| 31 | +* **Gestione dei login in sospeso** |
| 32 | + Supporto per richieste di accesso in attesa di verifica OTP, con scadenza automatica dopo 5 minuti. |
| 33 | + |
| 34 | +* **Configurazione semplice della 2FA** |
| 35 | + Generazione di QR code lato client per un’integrazione immediata con app di autenticazione (es. Google Authenticator). |
| 36 | + |
| 37 | +* **API moderne e standardizzate** |
| 38 | + Tutte le interazioni avvengono tramite JSON, con utilizzo di codici di stato HTTP appropriati. |
| 39 | + |
| 40 | +* **Protezione contro SQL Injection** |
| 41 | + Tutte le query al database utilizzano **parametri preparati**. |
| 42 | + |
| 43 | +--- |
| 44 | + |
| 45 | +## Avvio rapido |
| 46 | + |
| 47 | +### 1. Installazione delle dipendenze |
| 48 | + |
14 | 49 | ```bash |
15 | | -# Run the command inside the API/ folder |
| 50 | +# All’interno della directory API/ |
16 | 51 | npm install |
17 | 52 | ``` |
18 | | -### Start the backend server |
| 53 | + |
| 54 | +### 2. Avvio del server backend |
| 55 | + |
19 | 56 | ```bash |
20 | | -# Run the command inside the API/ folder |
| 57 | +# All’interno della directory API/ |
21 | 58 | node server.js |
22 | 59 | ``` |
23 | | -> Make sure the HTML files are served from a server (hosted) and not opened directly as local files, because the login stores the pending login request ID in cookies, which won’t work if you open the file locally. |
24 | 60 |
|
25 | | -I hope this helps you learn how a robust login and signup system works. Have fun experimenting and modifying my code by adding extra features, for example, a token-based system after the user logs in. |
| 61 | +> **Nota importante:** i file HTML devono essere serviti tramite un web server. L’apertura diretta in locale impedirà il corretto funzionamento dei cookie utilizzati per la gestione dei login in sospeso. |
| 62 | +
|
| 63 | +--- |
| 64 | + |
| 65 | +## Azioni rapide |
| 66 | + |
| 67 | +<p align="center"> |
| 68 | + <a href="https://github.com/LightYagami28/secure-auth-nodejs" target="_blank"> |
| 69 | + <img src="https://img.shields.io/badge/Visualizza%20su-GitHub-181717?logo=github&style=for-the-badge" alt="View on GitHub"/> |
| 70 | + </a> |
| 71 | + <a href="https://your-demo-link.com" target="_blank"> |
| 72 | + <img src="https://img.shields.io/badge/Demo%20Online-Visita-4CAF50?style=for-the-badge" alt="Live Demo"/> |
| 73 | + </a> |
| 74 | + <a href="https://github.com/LightYagami28/secure-auth-nodejs/fork" target="_blank"> |
| 75 | + <img src="https://img.shields.io/badge/Fork%20Repository-Crea%20una%20copia-blue?style=for-the-badge" alt="Fork Repo"/> |
| 76 | + </a> |
| 77 | +</p> |
| 78 | + |
| 79 | +--- |
| 80 | + |
| 81 | +## Dimostrazione |
| 82 | + |
| 83 | +### Registrazione |
| 84 | + |
| 85 | + |
| 86 | + |
| 87 | +### Accesso |
26 | 88 |
|
27 | | -### Sign up phase |
28 | | - |
| 89 | + |
29 | 90 |
|
30 | | -### Log in phase |
31 | | - |
| 91 | +--- |
0 commit comments