swagger configurado na rota chavenfe
This commit is contained in:
118
src/auth/doc/login.fluxo.html
Normal file
118
src/auth/doc/login.fluxo.html
Normal file
@@ -0,0 +1,118 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="pt-BR">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Documentação - Fluxo de Login</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
background-color: #f9f9f9;
|
||||
color: #333;
|
||||
line-height: 1.6;
|
||||
padding: 2rem;
|
||||
}
|
||||
h1, h2, h3 {
|
||||
color: #007acc;
|
||||
}
|
||||
code, pre {
|
||||
background-color: #eee;
|
||||
padding: 1rem;
|
||||
border-radius: 4px;
|
||||
display: block;
|
||||
white-space: pre-wrap;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin: 1rem 0;
|
||||
}
|
||||
th, td {
|
||||
border: 1px solid #ddd;
|
||||
padding: 0.75rem;
|
||||
}
|
||||
th {
|
||||
background-color: #007acc;
|
||||
color: white;
|
||||
}
|
||||
.tag {
|
||||
display: inline-block;
|
||||
background: #007acc;
|
||||
color: white;
|
||||
padding: 0.2rem 0.6rem;
|
||||
border-radius: 4px;
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>🔐 Fluxo de Login - Portal Juru API</h1>
|
||||
|
||||
<h2>📌 Rota de Login</h2>
|
||||
<p><strong>URL:</strong> <code>POST /api/v1/auth/login</code></p>
|
||||
<p><strong>Descrição:</strong> Autentica o usuário, valida regras de negócio e retorna um token JWT.</p>
|
||||
<p><strong>Acesso:</strong> Público</p>
|
||||
|
||||
<h3>📤 Body (JSON)</h3>
|
||||
<pre>{
|
||||
"username": "joelson.r",
|
||||
"password": "1010"
|
||||
}</pre>
|
||||
|
||||
<h3>✅ Resposta (200 OK)</h3>
|
||||
<pre>{
|
||||
"id": 1498,
|
||||
"sellerId": 2013,
|
||||
"name": "JOELSON DE BRITO RIBEIRO",
|
||||
"username": "JOELSON DE BRITO RIBEIRO",
|
||||
"storeId": "4",
|
||||
"email": "JOELSON.R@JURUNENSE.COM.BR",
|
||||
"token": "eyJhbGciOiJIUzI1NiIsInR5..."
|
||||
}</pre>
|
||||
|
||||
<h3>❌ Resposta (401 Unauthorized)</h3>
|
||||
<pre>{
|
||||
"success": false,
|
||||
"message": "Usuário ou senha inválidos.",
|
||||
"data": null,
|
||||
"error": "Usuário ou senha inválidos."
|
||||
}</pre>
|
||||
|
||||
<h2>🧱 Camadas e Responsabilidades</h2>
|
||||
<table>
|
||||
<tr><th>Camada</th><th>Responsabilidade</th></tr>
|
||||
<tr><td>AuthController</td><td>Recebe requisição e coordena autenticação</td></tr>
|
||||
<tr><td>UsersService</td><td>Orquestra os casos de uso (login, reset, troca senha)</td></tr>
|
||||
<tr><td>AuthenticateUserService</td><td>Executa lógica de autenticação e validações</td></tr>
|
||||
<tr><td>UserRepository</td><td>Executa SQL diretamente no Oracle</td></tr>
|
||||
<tr><td>AuthService</td><td>Gera o token JWT com os dados do usuário</td></tr>
|
||||
<tr><td>JwtStrategy</td><td>Valida o token em rotas protegidas, usando Redis como cache</td></tr>
|
||||
<tr><td>RedisClientAdapter</td><td>Wrapper de acesso ao Redis com interface genérica e TTL</td></tr>
|
||||
</table>
|
||||
|
||||
<h2>🧊 Redis na Autenticação</h2>
|
||||
<ul>
|
||||
<li><strong>Chave:</strong> <code>session:{userId}</code></li>
|
||||
<li><strong>Valor:</strong> JSON serializado do usuário autenticado</li>
|
||||
<li><strong>TTL:</strong> 8 horas</li>
|
||||
<li><strong>Fallback:</strong> Se o cache não existir, consulta ao banco</li>
|
||||
<li><strong>Auditoria:</strong> espaço reservado para log de acesso</li>
|
||||
</ul>
|
||||
|
||||
<h2>🔐 Proteção de Rotas</h2>
|
||||
<p>Rotas protegidas utilizam <code>@UseGuards(JwtAuthGuard)</code> e <code>@ApiBearerAuth()</code>.</p>
|
||||
<p><strong>Header necessário:</strong></p>
|
||||
<code>Authorization: Bearer <token></code>
|
||||
|
||||
<h2>🚀 Melhorias Futuras</h2>
|
||||
<ul>
|
||||
<li>[ ] Blacklist de tokens para logout</li>
|
||||
<li>[ ] Log de auditoria</li>
|
||||
<li>[ ] Refresh Token</li>
|
||||
<li>[ ] Controle de permissões/roles</li>
|
||||
</ul>
|
||||
|
||||
<p><strong>Última atualização:</strong> 28/03/2025</p>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user