You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> 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.
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.
alert("Login successful:\nSTATUS CODE: "+data["STATUS_CODE"]+"\n\n"+data["MESSAGE"]+"\n\n\nI hope this repository has been helpful in understanding and learning how to manage a secure login!\n\nFeel free to experiment you can modify and improve my code, add extra checks, or implement new actions to execute after login.");
alert("Login successful:\nSTATUS CODE: "+data["STATUS_CODE"]+"\n\n"+data["MESSAGE"]+"\n\n\nI hope this repository has been helpful in understanding and learning how to manage a secure login!\n\nFeel free to experiment you can modify and improve my code, add extra checks, or implement new actions to execute after login.");
0 commit comments