Verificação de Auth dos Clientes — #08 Cross-Tenant
Data: 2026-07-08
Objetivo: Confirmar que zzapp e zzportal já enviam Authorization: Bearer em todas as requests para /api/payment/*.
1. zzapp (Flutter)
1.1 Mecanismo de auth
Arquivo: coezzion_vendas_app/lib/middlewares/http/auth_interceptor.dart
// Linha 20 — adicionado em TODAS as requests
final auth = await Get.find<AuthController>(tag: "auth").auth;
if (auth != null) {
options.headers['Authorization'] = 'Bearer ${auth.accessToken}';
}
Arquivo: coezzion_vendas_app/lib/shared/utils/dio_utils.dart
// Linhas 84-95 — interceptors registrados no Dio global
dio.interceptors.addAll([
AuthInterceptor(), // ← Bearer token
RefreshTokenInterceptor(), // ← retry em 401
SchemaInterceptor(), // ← api-company-target (só em /api/payment)
BrandsInterceptor(), // ← X-Request-brands
DeviceIdInterceptor(), // ← X-device-id
]);
O AuthInterceptor é incondicional — adiciona Bearer a toda request, sem filtrar por path.
1.2 Endpoints chamados
| Endpoint | Ativo? | Envia Bearer? |
|---|---|---|
GET /api/payment/profile-fraud | Não (código comentado) | Sim (se ativo) |
GET /api/payment-report/report/sales/{orderId}/5 | Sim | Sim |
GET /api/payment-report/dashboard/app | Sim | Sim |
GET /api/store/payment/{storeId}/app | Sim | Sim |
1.3 Schema interceptor
Arquivo: coezzion_vendas_app/lib/middlewares/http/schema_interceptor.dart
// Linha 21-26 — só adiciona api-company-target se URL contém /api/payment
if (path.contains(ApiUtils.linkApi)) {
options.headers['api-company-target'] = schema;
}
Adiciona o header api-company-target junto com o Bearer, não no lugar dele.
2. zzportal (React)
2.1 Mecanismo de auth
Arquivo: coezzion-portal/src/store/auth/index.ts
// Linhas 17-19 — sign-in
api.defaults.headers.Authorization = `Bearer ${token}`;
api.defaults.headers['api-company-target'] = schema;
// Linhas 33-35 — refresh token
api.defaults.headers.Authorization = `Bearer ${token}`;
api.defaults.headers['api-company-target'] = schema;
Arquivo: coezzion-portal/src/store/index.ts
// Linhas 48-53 — rehydration (page reload)
persistStore(store, null, () => {
const state = store.getState();
if (state.auth.token) {
api.defaults.headers.Authorization = `Bearer ${state.auth.token}`;
api.defaults.headers['api-company-target'] = state.user.organizationToken.schema ?? '';
}
});
api.defaults.headers.common → todas as requests do axios recebem Bearer automaticamente.
2.2 Endpoints chamados
| Endpoint | Método | Envia Bearer? |
|---|---|---|
/api/payment/profile-fraud | GET, POST, DELETE | Sim |
/api/payment/approve | POST | Sim |
/api/payment/reverse | POST | Sim |
/api/payment/cancel | POST | Sim |
/api/payment/antifraud/retry/{id} | POST | Sim |
/api/payment/history/{id} | GET | Sim |
/api/payment/control-operation/store | PUT, POST, DELETE | Sim |
/api/payment/control-operation | PUT | Sim |
2.3 Token refresh
Arquivo: coezzion-portal/src/services/api.ts (linhas 18-68)
Response interceptor no axios:
- Detecta 401 → chama
POST api/auth/refresh-token - Atualiza
Authorizationheader com novo token - Retry da request original
3. Conclusão
| Cliente | Bearer em todas requests? | Mecanismo |
|---|---|---|
| zzapp | ✅ Sim | AuthInterceptor incondicional |
| zzportal | ✅ Sim | api.defaults.headers.common global |
Adicionar [Authorize(JwtBearer)] aos endpoints /api/payment/* não causa breaking change em nenhum dos dois clientes.