627360113f
P8: Invalidate all Redis sessions when is_system_admin changes - Added is_system_admin to UserUpdate schema and UserResponse - Added invalidate_all_user_sessions call in users.py route - Added is_system_admin param to user_service.update_user P9: Remove no-op permission resolution strategies - Only highest_wins supported, others removed as no-ops - Updated tenant.py CheckConstraint to only allow highest_wins - Added KI-Kommentar in permissions.py P10: Remove legacy check_permission from auth.py - Removed duplicate check_permission and filter_fields_by_permission - Fixed ai_copilot_service.py to use permissions.check_permission - Updated ai_copilot route to pass resolved permissions dict P11: Verified — no guest_users remnants found P12: Migrate ContactFolderPermission to EntityPermission - contact_folder_permission_service now delegates to entity_permission_service - contact_folder_service uses EntityPermission queries - Removed ContactFolderPermission from models/__init__.py - Created migration 0114 to migrate data and drop table P13: Added RLS migration history comment in alembic/env.py P14: Verified — services already apply visibility_filter - saved_filters/views filter by user_id (personal data) - workspaces are UI context only - notifications already filter by entity access P15: Split entity_permission_service.py (932 lines) into 4 modules - permission_resolver.py: get_effective_access, get_visible_ids, etc. - permission_cache.py: Redis caching functions - permission_audit.py: Audit logging helpers - entity_permission_service.py: CRUD operations + re-exports P16: Centralize PERM_RANK in permissions.py - Single source: app.core.permissions.PERM_RANK - Updated all services to import from permissions.py P17: Fix MIGRATION_DATABASE_URL to use crm_migration - docker-compose.yaml defaults changed from crm_user to crm_migration - .env.docker.example updated - prestart.sh comment updated
63 lines
2.8 KiB
Bash
63 lines
2.8 KiB
Bash
# =============================================================================
|
|
# .env.docker.example — template for `docker compose --env-file .env.docker up`
|
|
#
|
|
# DO NOT COMMIT .env.docker. It contains real secrets.
|
|
# Usage:
|
|
# cp .env.docker.example .env.docker
|
|
# $EDITOR .env.docker
|
|
# docker compose --env-file .env.docker up --build
|
|
# =============================================================================
|
|
|
|
# --- PostgreSQL (local container) ---------------------------------------------
|
|
POSTGRES_USER=crm_user
|
|
# Generate a strong password, e.g.:
|
|
# python -c "import secrets; print(secrets.token_urlsafe(24))"
|
|
POSTGRES_PASSWORD=STRONG_PASSWORD_HERE
|
|
POSTGRES_DB=crm_db
|
|
|
|
# --- Redis (REQUIRED) ---------------------------------------------------------
|
|
# Generate a strong password:
|
|
# python -c "import secrets; print(secrets.token_urlsafe(24))"
|
|
REDIS_PASSWORD=STRONG_REDIS_PASSWORD_HERE
|
|
|
|
# --- CRM Application: Runtime DB user (NOSUPERUSER, NOBYPASSRLS) --------------
|
|
# The app and worker use crm_runtime — RLS is enforced.
|
|
# This user is created by migration 0044 with DML-only permissions.
|
|
# Set RUNTIME_DB_PASSWORD to the password you want for crm_runtime.
|
|
RUNTIME_DB_PASSWORD=STRONG_RUNTIME_PASSWORD_HERE
|
|
DATABASE_URL=postgresql+asyncpg://crm_runtime:STRONG_RUNTIME_PASSWORD_HERE@postgres:5432/crm_db
|
|
|
|
# --- CRM Application: Migration DB user (NOSUPERUSER, BYPASSRLS) ------------
|
|
# Migrations use crm_migration (NOSUPERUSER, BYPASSRLS) — NOT crm_user (SUPERUSER).
|
|
# This is NOT used by the app at runtime — only by prestart.sh / alembic.
|
|
MIGRATION_DATABASE_URL=postgresql+asyncpg://crm_migration:STRONG_PASSWORD_HERE@postgres:5432/crm_db
|
|
|
|
# --- SECRET_KEY (REQUIRED, min 32 chars) -------------------------------------
|
|
# Session signing secret. MUST be at least 32 characters.
|
|
# Generate with:
|
|
# python -c "import secrets; print(secrets.token_urlsafe(48))"
|
|
SECRET_KEY=MIN_32_CHARS_GENERATE_WITH_secrets_token_urlsafe_32_xxxxxxxxxxxx
|
|
|
|
# --- Frontend URL (for email links) ------------------------------------------
|
|
# The public URL where users access the LeoCRM frontend.
|
|
# Used for password reset links, invitations, etc.
|
|
FRONTEND_URL=https://crm.example.com
|
|
|
|
# --- CORS / environment -------------------------------------------------------
|
|
# Comma-separated, NO wildcards. In dev we allow localhost:8000 (the app) and
|
|
# :5173 (e.g. Vite dev server). In production, restrict to the real domain.
|
|
CORS_ORIGINS=https://crm.example.com
|
|
ENVIRONMENT=production
|
|
LOG_LEVEL=INFO
|
|
|
|
# --- SMTP (for password reset emails) -----------------------------------------
|
|
SMTP_HOST=smtp.example.com
|
|
SMTP_PORT=587
|
|
SMTP_USERNAME=noreply@example.com
|
|
SMTP_PASSWORD=YOUR_SMTP_PASSWORD
|
|
SMTP_FROM_EMAIL=noreply@example.com
|
|
SMTP_USE_TLS=true
|
|
|
|
# --- bcrypt tuning ----------------------------------------------------------
|
|
BCRYPT_ROUNDS=12
|