refractor(auth): removed password from everywhere
This commit is contained in:
+1
-5
@@ -30,15 +30,11 @@ Authorization: Bearer <token>
|
||||
|
||||
## Auth + Profile
|
||||
- `POST /auth/register`
|
||||
citizen registration
|
||||
citizen registration without password
|
||||
- `POST /auth/otp/request`
|
||||
sends OTP through Mailpit
|
||||
- `POST /auth/otp/verify`
|
||||
consumes OTP, returns bearer token
|
||||
- `POST /auth/login/password`
|
||||
password fallback login
|
||||
- `POST /auth/change-password`
|
||||
authenticated password change, also clears `must_change_password`
|
||||
- `GET /me`
|
||||
current user profile, roles, permissions, points
|
||||
- `PATCH /me`
|
||||
|
||||
@@ -25,7 +25,6 @@ generate public read-only intervention links.
|
||||
## Runtime Model
|
||||
- Auth uses bearer tokens from `api_tokens`.
|
||||
- OTP login uses `otp_challenges` and Mailpit in local dev.
|
||||
- Password hash uses PBKDF2-HMAC-SHA256. Legacy `sha256$` hashes rejected.
|
||||
- DB access uses raw parameterized SQL through `drogon::orm::DbClient`.
|
||||
- No Drogon generated ORM models. No `Mapper<T>`.
|
||||
|
||||
@@ -37,7 +36,6 @@ generate public read-only intervention links.
|
||||
Effective permission helpers:
|
||||
- `auth::canManageReports(user)`: admin or `reports.manage`
|
||||
- `auth::canOperateReports(user)`: non-admin report manager
|
||||
- `auth::mustChangePassword(user)`: blocks protected operational/admin flows
|
||||
|
||||
## Workflow Ownership Rules
|
||||
- `reports.assigned_operator_id` is single platform owner of report.
|
||||
|
||||
@@ -14,7 +14,7 @@ Schema truth is `migrations/*.sql`. This file is compact human map of current DB
|
||||
|
||||
## Core Auth Tables
|
||||
- `users`
|
||||
identity, profile, password hash, points, `banned`, `must_change_password`
|
||||
identity, profile, points, `banned`
|
||||
- `roles`
|
||||
- `permissions`
|
||||
- `role_permissions`
|
||||
|
||||
+1
-3
@@ -29,12 +29,10 @@ public revocable link generated by operator/admin.
|
||||
|
||||
## Current Auth Model
|
||||
- Registration creates `citizen`.
|
||||
- Login paths:
|
||||
- Login path:
|
||||
- OTP email via Mailpit
|
||||
- password fallback
|
||||
- Auth token: bearer token from `api_tokens`
|
||||
- Banned users cannot authenticate.
|
||||
- `must_change_password` blocks most protected operator/admin flows until changed.
|
||||
|
||||
## Current Report Workflow
|
||||
### Citizen flow
|
||||
|
||||
@@ -29,9 +29,7 @@ moderate abuse, and inspect operational stats.
|
||||
### Auth
|
||||
- citizen registration
|
||||
- OTP login through Mailpit
|
||||
- password login fallback
|
||||
- bearer token auth
|
||||
- forced first password change for seed admin
|
||||
- profile read + limited self-edit (`first_name`, `last_name`, `phone`)
|
||||
|
||||
### Reports
|
||||
|
||||
+3
-4
@@ -17,9 +17,9 @@ Dopodichè ho elaborato una serie di feature che il sistema deve implementare an
|
||||
Feature Segnalazioni urbane
|
||||
– Lo sviluppo del della webapp avverrà su una istanza self hosted di Gitea come gesto di ribellione nei confronti di github che userà i dati sulle repo per trainare i modelli di IA (lo faceva già prima ma ora lo dice)
|
||||
– Il progetto sarà diviso tra frontend e backend. Frontend in probabilmente Vue.js e backend in C++, nello specifico Dragon è stato scelto come framework. Abbiamo scelto di sviluppare una webapp perchè il punto importante di un progetto del genere è la versatilità, la compatibilità su tutti i sistemi e la velocità.
|
||||
– Deve esistere un account amministratore generato dal sistema, appena ci si logga la prima volta ci chiederà di cambiare password, e questo profilo lo dovrà teoricamente avere solo chi il tecnico che gestisce la piattaforma di quel comune, dato che da questo profilo si può fare tutto. E’ diverso da un account operatore perchè l’operatore ha meno permessi rispetto ad un admin, l’admin può decidere chi sono gli operatori. (NOTA: eventualmente ci possono essere i permessi customizzabili, quindi l’admin può creare anche altri utenti che hanno permessi in più)
|
||||
– Deve esistere un account amministratore generato dal sistema. Questo profilo lo dovrà teoricamente avere solo chi il tecnico che gestisce la piattaforma di quel comune, dato che da questo profilo si può fare tutto. E’ diverso da un account operatore perchè l’operatore ha meno permessi rispetto ad un admin, l’admin può decidere chi sono gli operatori. (NOTA: eventualmente ci possono essere i permessi customizzabili, quindi l’admin può creare anche altri utenti che hanno permessi in più)
|
||||
– Deve essere possibile registrarsi alla piattaforma con tutti i quanti i dati anagrafici possibili e immaginabili, sarebbe figo avere un sistema che dato il codice fiscale ti auto completa i dati deducibili da quest’ultimo. Integrazione frontend con google maps per l’indirizzo. Deve essere possibile anche collegare CIE. Nella registrazione si richiede verifica a due fattori
|
||||
– Il login deve essere effettuato con email o CIE. Nel caso di email la modalità di default non richiede una password ma un OTP, in quanto dimostrato essere più sicuro. (La password è comunque obbligatoria da settare)
|
||||
– Il login deve essere effettuato con email o CIE. Nel caso di email la modalità di default usa OTP, in quanto dimostrato essere più sicuro.
|
||||
– Una volta registrati, se siamo un operatore (comunale, poliziotto, pompiere o chiunque) sarà un admin o un’altro operatore con abbastanza permessi ad assegnarci a quel ruolo e sbloccare i permessi per accedere ad altre parti della piattaforma.
|
||||
– Admin/operatori vari devono poter creare le varie zone in base al perimetro, se questo è fattibile tramite una mappa sarebbe l’ideale, assegnare i vari nomi ecc.. Questo serve sia per le segnalazioni e per l’assegnazione dell’agente/squadra che deve intervenire sia per fini statistici
|
||||
– Al sito non si registrano solo gli agenti che intervengono o gli operatori ma anche i cittadini, che possono effettuare delle segnalazioni. Le segnalazioni devono avere una foto, la posizione con coordinate geografiche e via con numero. Il sistema automaticamente capisce a che zona del comune fa parte
|
||||
@@ -69,7 +69,6 @@ erDiagram
|
||||
string nome
|
||||
string cognome
|
||||
string email UK
|
||||
string password_hash
|
||||
string codice_fiscale UK
|
||||
date data_nascita
|
||||
string luogo_nascita
|
||||
@@ -165,4 +164,4 @@ erDiagram
|
||||
int utente_id FK
|
||||
text testo
|
||||
datetime data_invio
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,9 +66,6 @@
|
||||
"last_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"must_change_password": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"phone": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -191,25 +188,6 @@
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"ChangePasswordRequest": {
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"current_password": {
|
||||
"format": "password",
|
||||
"type": "string"
|
||||
},
|
||||
"new_password": {
|
||||
"format": "password",
|
||||
"minLength": 10,
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"current_password",
|
||||
"new_password"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"CreateAreaRequest": {
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
@@ -347,9 +325,6 @@
|
||||
"last_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"must_change_password": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"permissions": {
|
||||
"items": {
|
||||
"type": "string"
|
||||
@@ -379,7 +354,6 @@
|
||||
"email",
|
||||
"fiscal_code",
|
||||
"points",
|
||||
"must_change_password",
|
||||
"role",
|
||||
"roles",
|
||||
"permissions"
|
||||
@@ -1126,24 +1100,6 @@
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"PasswordLoginRequest": {
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"email": {
|
||||
"format": "email",
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"format": "password",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"email",
|
||||
"password"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"ReadyResponse": {
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
@@ -1207,11 +1163,6 @@
|
||||
"last_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"format": "password",
|
||||
"minLength": 10,
|
||||
"type": "string"
|
||||
},
|
||||
"phone": {
|
||||
"type": "string"
|
||||
}
|
||||
@@ -1220,7 +1171,6 @@
|
||||
"first_name",
|
||||
"last_name",
|
||||
"email",
|
||||
"password",
|
||||
"fiscal_code"
|
||||
],
|
||||
"type": "object"
|
||||
@@ -2434,89 +2384,6 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v1/auth/change-password": {
|
||||
"post": {
|
||||
"description": "Changes the authenticated user's password.",
|
||||
"operationId": "AuthController.changePassword",
|
||||
"parameters": [ ],
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ChangePasswordRequest"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": true
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/OkResponse"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Password change result."
|
||||
},
|
||||
"400": {
|
||||
"$ref": "#/components/responses/BadRequest"
|
||||
},
|
||||
"401": {
|
||||
"$ref": "#/components/responses/Unauthorized"
|
||||
},
|
||||
"403": {
|
||||
"$ref": "#/components/responses/Forbidden"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"bearerAuth": [ ]
|
||||
}
|
||||
],
|
||||
"summary": "Change password",
|
||||
"tags": [
|
||||
"Auth"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v1/auth/login/password": {
|
||||
"post": {
|
||||
"description": "Password-based login fallback for local development.",
|
||||
"operationId": "AuthController.loginWithPassword",
|
||||
"parameters": [ ],
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/PasswordLoginRequest"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": true
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/TokenResponse"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Bearer token when credentials are valid."
|
||||
},
|
||||
"400": {
|
||||
"$ref": "#/components/responses/BadRequest"
|
||||
}
|
||||
},
|
||||
"summary": "Password login",
|
||||
"tags": [
|
||||
"Auth"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v1/auth/otp/request": {
|
||||
"post": {
|
||||
"description": "Sends a one-time code by email through Mailpit locally.",
|
||||
@@ -2591,7 +2458,7 @@
|
||||
},
|
||||
"/api/v1/auth/register": {
|
||||
"post": {
|
||||
"description": "Creates a citizen account with personal data and password.",
|
||||
"description": "Creates a citizen account with personal data.",
|
||||
"operationId": "AuthController.registerCitizen",
|
||||
"parameters": [ ],
|
||||
"requestBody": {
|
||||
|
||||
Reference in New Issue
Block a user