From 70f94c88976c00de479bcc3f8ac018e15596d3d0 Mon Sep 17 00:00:00 2001 From: juancho Date: Sun, 7 Dec 2025 12:13:25 -0500 Subject: [PATCH] =?UTF-8?q?Actualizar=20la=20configuraci=C3=B3n=20del=20RE?= =?UTF-8?q?ADME.md,=20agregar=20archivo=20.env.example=20y=20mejorar=20el?= =?UTF-8?q?=20.gitignore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 21 ++++++++++ .gitignore | 47 +++++++++++++++++++++++ README.md | 96 +++++++++++++++++++++++++++++++++++----------- docker-compose.yml | 26 +++++++------ 4 files changed, 157 insertions(+), 33 deletions(-) create mode 100644 .env.example create mode 100644 .gitignore diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..b413355 --- /dev/null +++ b/.env.example @@ -0,0 +1,21 @@ +# Microsoft E5 Auto-Renewal Configuration +# Copy this file to .env and fill in your actual values +# DO NOT commit .env to version control + +# === Engine (odengin) Configuration === +# Microsoft Azure credentials +E5_CLIENT_ID=your_client_id_here +E5_CLIENT_SECRET=your_client_secret_here +E5_REFRESH_TOKEN=your_refresh_token_here + +# Web application passwords +WEB_APP_PASSWORD=your_secure_password_here +E5_WEB_APP_PASSWORD=your_e5_password_here + +# === Cron Service (odcron) Configuration === +# Engine connection +CRON_IP=odengin:8080 + +# Authentication +CRON_PASSWORD=your_cron_password_here +CRON_REFRESH_TOKEN=your_cron_refresh_token_here diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7c4229e --- /dev/null +++ b/.gitignore @@ -0,0 +1,47 @@ +# Environment variables +.env +.env.local +.env.*.local + +# IDE +.vscode/ +.idea/ +*.swp +*.swo +*~ +.DS_Store + +# Docker +docker-compose.override.yml + +# Python +__pycache__/ +*.py[cod] +*$py.class +*.so +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg + +# Logs +logs/ +*.log + +# Node modules (if applicable) +node_modules/ + +# OS +Thumbs.db diff --git a/README.md b/README.md index a779e6c..11ea808 100644 --- a/README.md +++ b/README.md @@ -41,22 +41,41 @@ git clone cd onedrive ``` -2. Configura las variables de entorno en `docker-compose.yml`: +2. Copia el archivo de configuración de ejemplo: -```yaml +```bash +cp .env.example .env +``` + +3. Edita el archivo `.env` con tus credenciales: + +```bash +# Linux/Mac +nano .env + +# Windows +notepad .env +``` + +4. Rellena todas las variables requeridas: + +```env E5_CLIENT_ID=tu_client_id E5_CLIENT_SECRET=tu_client_secret E5_REFRESH_TOKEN=tu_refresh_token WEB_APP_PASSWORD=tu_password_segura +E5_WEB_APP_PASSWORD=tu_e5_password +CRON_PASSWORD=tu_cron_password +CRON_REFRESH_TOKEN=tu_cron_refresh_token ``` -3. Inicia los servicios: +5. Inicia los servicios: ```bash docker-compose up -d ``` -4. Verifica el estado: +6. Verifica el estado: ```bash docker-compose ps @@ -65,25 +84,35 @@ docker-compose logs -f ## ⚙️ Configuración +### Archivo `.env` + +El archivo `.env` contiene todas las variables de entorno necesarias. **Nunca** debes: + +- ❌ Subir `.env` a Git +- ❌ Compartir `.env` públicamente +- ❌ Guardar credenciales en el código + +El archivo `.env.example` se incluye como referencia para documentar qué variables se necesitan. + ### Variables de Entorno #### Servicio `odengin` -| Variable | Descripción | Requerida | -| --------------------- | ------------------------------- | --------- | -| `E5_CLIENT_ID` | Client ID de Microsoft Azure | ✅ | -| `E5_CLIENT_SECRET` | Client Secret de Azure | ✅ | -| `E5_REFRESH_TOKEN` | Token de renovación | ✅ | -| `WEB_APP_PASSWORD` | Contraseña de la aplicación web | ✅ | -| `E5_WEB_APP_PASSWORD` | Contraseña adicional E5 | ✅ | +| Variable | Descripción | Requerida | Variable de Entorno | +| --------------------- | ------------------------------- | --------- | --------------------- | +| `E5_CLIENT_ID` | Client ID de Microsoft Azure | ✅ | `E5_CLIENT_ID` | +| `E5_CLIENT_SECRET` | Client Secret de Azure | ✅ | `E5_CLIENT_SECRET` | +| `E5_REFRESH_TOKEN` | Token de renovación | ✅ | `E5_REFRESH_TOKEN` | +| `WEB_APP_PASSWORD` | Contraseña de la aplicación web | ✅ | `WEB_APP_PASSWORD` | +| `E5_WEB_APP_PASSWORD` | Contraseña adicional E5 | ✅ | `E5_WEB_APP_PASSWORD` | #### Servicio `odcron` -| Variable | Descripción | Requerida | -| --------------- | -------------------------------------------- | --------- | -| `IP` | Dirección del motor (formato: `host:puerto`) | ✅ | -| `PASSWORD` | Contraseña de autenticación | ✅ | -| `REFRESH_TOKEN` | Token de renovación | ✅ | +| Variable | Descripción | Requerida | Variable de Entorno | +| ------------------- | -------------------------------------------- | --------- | -------------------- | +| IP del motor | Dirección del motor (formato: `host:puerto`) | ✅ | `CRON_IP` | +| Contraseña | Contraseña de autenticación | ✅ | `CRON_PASSWORD` | +| Token de renovación | Token de renovación | ✅ | `CRON_REFRESH_TOKEN` | ### Puertos @@ -170,12 +199,35 @@ docker exec -it odcron ping odengin ## 🛡️ Seguridad -> ⚠️ **Importante**: -> -> - Nunca subas credenciales al repositorio -> - Usa variables de entorno o archivos `.env` -> - Cambia las contraseñas por defecto -> - Mantén las imágenes actualizadas +### Gestión de Credenciales + +✅ **HACER:** + +- ✅ Usar archivo `.env` para variables sensibles +- ✅ Incluir `.env` en `.gitignore` +- ✅ Compartir solo `.env.example` con placeholders +- ✅ Cambiar contraseñas por defecto +- ✅ Restringir permisos del archivo `.env`: `chmod 600 .env` +- ✅ Usar secretos de Docker/Kubernetes en producción + +❌ **NO HACER:** + +- ❌ Nunca subir `.env` a Git +- ❌ No guardar credenciales en el código +- ❌ No compartir `.env` por mensajes o email +- ❌ No usar contraseñas débiles +- ❌ No hacer commit accidental de `.env` + +### Verificar antes de subir + +```bash +# Asegurate de que .env NO está en Git +git status + +# Si fue agregado accidentalmente: +git rm --cached .env +git commit --amend -m "Remove .env from repository" +``` ## 📝 Notas diff --git a/docker-compose.yml b/docker-compose.yml index 2932df8..25b82ab 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,32 +1,36 @@ --- services: odengin: - build: ./odengin # Ajusta la ruta al directorio con su Dockerfile + build: ./engine container_name: odengin + env_file: .env environment: - - E5_CLIENT_ID=id - - E5_CLIENT_SECRET=secret - - E5_REFRESH_TOKEN=tokenit - - WEB_APP_PASSWORD=123 - - E5_WEB_APP_PASSWORD=123 + - E5_CLIENT_ID=${E5_CLIENT_ID} + - E5_CLIENT_SECRET=${E5_CLIENT_SECRET} + - E5_REFRESH_TOKEN=${E5_REFRESH_TOKEN} + - WEB_APP_PASSWORD=${WEB_APP_PASSWORD} + - E5_WEB_APP_PASSWORD=${E5_WEB_APP_PASSWORD} ports: - - 8089:8080 + - "8089:8080" restart: unless-stopped hostname: odengin networks: - odeng-net odcron: - build: ./odcron # Ajusta la ruta al directorio con su Dockerfile + build: ./cron container_name: odcron + env_file: .env environment: - - IP=odengin:8080 # Usa el nombre del servicio para comunicación interna - - PASSWORD=pass - - REFRESH_TOKEN=tokenit + - IP=${CRON_IP:-odengin:8080} + - PASSWORD=${CRON_PASSWORD} + - REFRESH_TOKEN=${CRON_REFRESH_TOKEN} restart: unless-stopped hostname: odcron networks: - odeng-net + depends_on: + - odengin networks: odeng-net: