diff --git a/.gitignore b/.gitignore index 6beb5975..b8b65467 100644 --- a/.gitignore +++ b/.gitignore @@ -69,3 +69,5 @@ postgres-data/ backend/uploads/ docker-compose.yml .mypy_cache/ + +backend/celerybeat-schedule \ No newline at end of file diff --git a/scripts/init_first_time.sh b/scripts/init_first_time.sh index c03a12f9..de1c32ae 100755 --- a/scripts/init_first_time.sh +++ b/scripts/init_first_time.sh @@ -14,9 +14,8 @@ # 8. Licencia Enterprise para el tenant (ilimitada, 1 año de vigencia) # # Requisitos: -# - Keycloak y PostgreSQL corriendo (por ejemplo: docker compose up -d) -# - Keycloak corriendo en http://localhost:8080 -# - PostgreSQL corriendo en localhost:5432 o 5939 +# - Keycloak corriendo en http://localhost:8080 +# - PostgreSQL corriendo en localhost:5432 o 5939 # - Base de datos anexo76_core creada # - jq instalado (para procesamiento JSON) # @@ -127,15 +126,11 @@ create_tenant_mapper() { } # Variables de configuración (puertos con prefijo 1 hardcodeados) -KEYCLOAK_URL="http://localhost:18080/kcauth" +KEYCLOAK_URL="${KEYCLOAK_URL:-http://localhost:8080/kcauth}" KEYCLOAK_ADMIN="${KEYCLOAK_ADMIN:-admin}" KEYCLOAK_ADMIN_PASSWORD="${KEYCLOAK_ADMIN_PASSWORD:-admin}" KEYCLOAK_REALM="${KEYCLOAK_REALM:-master}" -<<<<<<< HEAD -KEYCLOACK_ADMIN_URL="http://localhost:19000/kcauth" -======= KEYCLOAK_ADMIN_URL="${KEYCLOAK_ADMIN_URL:-http://localhost:9000/kcauth}" ->>>>>>> origin/development POSTGRES_HOST="${POSTGRES_HOST:-localhost}" POSTGRES_PORT="${POSTGRES_PORT:-5432}" @@ -149,7 +144,7 @@ DEMO_EMAIL="demo@aduanasoft.com" DEMO_FIRSTNAME="Demo" DEMO_LASTNAME="User" -TENANT_NAME="Aduanasoft" +TENANT_NAME="Aduanasoft"A TENANT_SLUG="aduanasoft" COMPANY_NAME="Aduanasoft S.A. de C.V." COMPANY_RFC="ADS010101AAA" @@ -280,13 +275,13 @@ else "directAccessGrantsEnabled": true, "standardFlowEnabled": true, "implicitFlowEnabled": false, - "rootUrl": "http://localhost:18000/api", - "baseUrl": "http://localhost:18000/api", + "rootUrl": "http://localhost:8000/api", + "baseUrl": "http://localhost:8000/api", "redirectUris": [ - "http://localhost:18000/*", - "http://localhost:15173/*" + "http://localhost:8000/*", + "http://localhost:5173/*" ], - "webOrigins": ["http://localhost:18000/api"], + "webOrigins": ["http://localhost:8000/api"], "attributes": { "access.token.lifespan": "3600", "client.secret.creation.time": "0" @@ -400,27 +395,6 @@ else CREATE_FRONTEND=$(curl -s -w "\n%{http_code}" -X POST "${KEYCLOAK_URL}/admin/realms/${KEYCLOAK_REALM}/clients" \ -H "Authorization: Bearer ${ACCESS_TOKEN}" \ -H "Content-Type: application/json" \ -<<<<<<< HEAD - -d "{ - \"clientId\": \"anexo76-frontend\", - \"name\": \"Anexo76 Frontend\", - \"description\": \"Aplicación web frontend para el sistema Anexo76\", - \"enabled\": true, - \"protocol\": \"openid-connect\", - \"publicClient\": true, - \"directAccessGrantsEnabled\": false, - \"standardFlowEnabled\": true, - \"implicitFlowEnabled\": false, - \"rootUrl\": \"http://localhost:15173\", - \"baseUrl\": \"http://localhost:15173\", - \"redirectUris\": [ - \"http://localhost:15173/*\", - \"http://localhost:13000/*\" - ], - \"webOrigins\": [ - \"http://localhost:15173\", - \"http://localhost:13000\" -======= -d '{ "clientId": "anexo76-frontend", "name": "Anexo76 Frontend", @@ -442,12 +416,11 @@ else "http://localhost:5173", "http://localhost:5174", "http://localhost:3000" ->>>>>>> origin/development ], - \"attributes\": { - \"pkce.code.challenge.method\": \"S256\" + "attributes": { + "pkce.code.challenge.method": "S256" } - }") + }') HTTP_CODE=$(echo "$CREATE_FRONTEND" | tail -n1) RESPONSE_BODY=$(echo "$CREATE_FRONTEND" | head -n -1) @@ -666,12 +639,8 @@ echo -e "${GREEN}✓ Atributo tenant_id asignado al usuario${NC}" # Agregar relación usuario-tenant en la base de datos (usar company_id real) echo -e "\n${YELLOW}Creando relación usuario-tenant en la base de datos...${NC}" -<<<<<<< HEAD -exec_pg_sql "INSERT INTO core.user_tenants (keycloak_user_id, tenant_id, company_id, role, is_active, created_at, updated_at) VALUES ('${USER_ID}', ${TENANT_ID}, ${COMPANY_ID}, 'admin', true, now(), now()) ON CONFLICT (keycloak_user_id, tenant_id, company_id) DO UPDATE SET is_active = true, updated_at = CURRENT_TIMESTAMP;" >/dev/null -======= exec_pg_sql "INSERT INTO core.user_tenants (keycloak_user_id, tenant_id, company_id, role, is_active, created_at, updated_at) VALUES ('${USER_ID}', ${TENANT_ID}, 1, 'admin', true, now(), now()) ON CONFLICT (keycloak_user_id, tenant_id, company_id) DO UPDATE SET is_active = true, updated_at = CURRENT_TIMESTAMP;" >/dev/null exec_pg_sql_client "INSERT INTO core.user_tenants (keycloak_user_id, tenant_id, company_id, role, is_active, created_at, updated_at) VALUES ('${USER_ID}', ${TENANT_ID}, 1, 'admin', true, now(), now()) ON CONFLICT (keycloak_user_id, tenant_id, company_id) DO UPDATE SET is_active = true, updated_at = CURRENT_TIMESTAMP;" >/dev/null ->>>>>>> origin/development echo -e "${GREEN}✓ Relación usuario-tenant creada en la base de datos (Hub y Cliente)${NC}" @@ -768,5 +737,5 @@ echo -e " ${GREEN}✓${NC} Status: Activa" echo -e " ${GREEN}✓${NC} Features: API, Reportes Avanzados, Integraciones, Soporte Dedicado" echo -e " ${GREEN}✓${NC} Vigencia: 1 año" echo -e "\n${YELLOW}Puedes acceder al sistema en:${NC}" -echo -e " ${GREEN}http://localhost:15173${NC}" +echo -e " ${GREEN}http://localhost:5173${NC}" echo -e "\n${GREEN}════════════════════════════════════════════════════════${NC}\n"