docs: atualiza README com novos endpoints auth e exemplos

This commit is contained in:
2026-04-14 20:34:51 -05:00
parent 5fc265f3dc
commit ba698de249

View File

@@ -4,7 +4,7 @@ MVP de autenticação central para serviços distribuídos.
## O que este projeto entrega
- Auth Service com `login` e `refresh`
- Auth Service com `register`, `login`, `refresh` e recuperação de senha
- JWT assinado em `RS256` com contrato fixo
- Middleware de validação JWT local
- Serviço consumidor de referência (`/profile/me`)
@@ -73,6 +73,9 @@ A tabela `User` possui apenas:
- `POST /auth/login`
- `POST /auth/refresh`
- `POST /auth/register`
- `POST /auth/forgot-password`
- `POST /auth/reset-password`
- `GET /profile/me` (protegida)
- `GET /dashboard` (protegida, chama `/profile/me`)
@@ -94,29 +97,65 @@ A identidade confiável do usuário é sempre o `sub`.
## Teste rápido (curl)
### 1) Login
### 1) Cadastro
```bash
curl -X POST http://localhost:3000/auth/register \
-H 'Content-Type: application/json' \
-d '{"email":"novo.usuario@example.com","password":"senha123"}'
```
Fluxo recomendado no cliente: `register -> login`.
### 2) Login
```bash
curl -X POST http://localhost:3000/auth/login \
-H 'Content-Type: application/json' \
-d '{"email":"student@example.com","password":"student123"}'
-d '{"email":"novo.usuario@example.com","password":"senha123"}'
```
### 2) Rota protegida
### 3) Forgot password (sem SMTP, modo didático)
```bash
curl -X POST http://localhost:3000/auth/forgot-password \
-H 'Content-Type: application/json' \
-d '{"email":"novo.usuario@example.com"}'
```
Observação: neste MVP didático a resposta já traz `recovery.reset_token` e `recovery.reset_url`.
### 4) Reset password
```bash
curl -X POST http://localhost:3000/auth/reset-password \
-H 'Content-Type: application/json' \
-d '{"token":"<reset_token>","new_password":"novaSenha123"}'
```
### 5) Login com nova senha
```bash
curl -X POST http://localhost:3000/auth/login \
-H 'Content-Type: application/json' \
-d '{"email":"novo.usuario@example.com","password":"novaSenha123"}'
```
### 6) Rota protegida
```bash
curl http://localhost:3000/profile/me \
-H "Authorization: Bearer <access_token>"
```
### 3) Chamada entre serviços (A -> B)
### 7) Chamada entre serviços (A -> B)
```bash
curl http://localhost:3000/dashboard \
-H "Authorization: Bearer <access_token>"
```
### 4) Refresh
### 8) Refresh
```bash
curl -X POST http://localhost:3000/auth/refresh \