Repository navigation
OpenTea DX-OS v1.6.0
Added
- Identity-aware core access: the web app keeps the Keycloak access and refresh tokens server-side in the encrypted session cookie and refreshes them in the middleware when under 30 seconds remain; a failed refresh sends the user to
/login./api/auth/sessionexposes neither token - Tenant isolation:
requireTenant()resolves the caller's HTX from thehtx_codeclaim, answering 403NO_HTXwhen it is missing or unknown;TenantGuardanswers 404 before any write by ID on a record of another HTX. Notifications sent to a whole HTX now carryhtx_profile_id - Gateway read adapters: parcels, households, lots, journal entries and disease reports are read through Hasura with the user's token. A core outage gives 503
CORE_UNAVAILABLEand a Vietnamese error page, never a fallback to Prisma - Internal gateway port
9081for thewebcontainer: not limited per IP, JWT and permissions as on9080 - Browser test
tests/e2e/tenant/core-tenant.spec.ts(E2E_CORE=1), run in theplatform-smokeCI job against a realwebcontainer and real Keycloak: isolation between two HTXs, no token in the session endpoint, a live refresh of an expired token, and a Hasura outage
Changed
- Disease detection and the local LLM go through the gateway with the user's token; the Groq path is unchanged when a key is set. The LLM route is limited per bearer token
- Sessions:
ssoSessionIdleTimeoutandssoSessionMaxLifespanare 8 hours, matching the app session - Accounts: registration and invitations write
htx_code; invited managers and officers must set up TOTP (#18) docker/.env.local.example,.env.example: removedDISEASE_API_URLandOLLAMA_BASE_URL, which no service reads.docker/.env.local.examplealso drops theKEYCLOAK_ISSUERthat Compose overrides and addsAUTH_URL;.env.examplehas noAUTH_URL- Documents are namespaced by HTX: keys are
para/<htxCode>/.... The list, URL and upload routes derive the namespace from the session and answer 404 for anything outside it, including..traversal;certificate_keysoutside it answer 400. The one exception ispara/Archives/Market_Reports/, written by the n8n workflow and holding no tenant data: the list and URL routes may read it, and the document screen shows it without upload
Fixed
- Migration drift (#7): migrations now produce the database described by
schema.prisma, without dropping any column - Login from the Docker image:
webbuilt theredirect_urifromHOSTNAME(0.0.0.0) and Keycloak refused it; Compose now setsAUTH_URL - Account attributes: Keycloak 24 silently dropped
fullName,phoneandhtxId; the realm now declares them as admin-only - HTX assumed to be the first one: every
htxProfile.findFirst()now reads the caller's HTX - Cross-HTX reads:
schedule/harvest,schedule/unscheduled,weather/forecastand the officer soil-health page returned data of every HTX; they now filter by the caller's HTX - Role frozen at sign-in: the role is read again from each refreshed access token, and is cleared when no recognised role remains
- Keycloak admin credentials on a release: the web app also reads
KEYCLOAK_ADMINandKEYCLOAK_ADMIN_PASSWORD, and refuses to fall back toadmin/adminin production - Self-registration: the middleware no longer answers 401 to the anonymous
POST /api/register; new accounts stay disabled until a manager approves them - Pre-upgrade sessions: in production a session without a refresh token goes to login instead of showing the no-HTX notice
- Silent load failures: the officer journal approval and manager farm-zone screens now say when loading failed
- Anonymous
POST /api/register: limited to 5 requests per IP per 10 minutes (429), and anything other than a validation error answers a generic message instead of the raw error text - Rejected registrations: the household is unlinked before the Keycloak account is deleted, so a failed unlink can be retried and never leaves the phone taken
- Object keys from clients:
POST /api/journalanswers 400 for aphoto_minio_keyoutside the caller's document root, and the journal list signs a stored key only when it is inside that root; other entries come back without a photo. The public certificate route signs a key only inside the document root of the lot's HTX
Upgrade notes
- Run
migrate(two new migrations:20261109120000_sync_schema_driftand20261109130000_notifications_htx), thenplatform-init, as in the deploy section. - On a running release, after
up -d --no-buildrundocker compose --env-file docker/.env.local -f docker/docker-compose.yml -f docker/docker-compose.release.yml restart hasura apisix. Their compose config is unchanged, so they are not recreated: APISIX keeps listening on 9080 only and Hasura lacks the new relationships, and every list answers 503. - Keycloak imports the realm only on a new database. On a running realm, set SSO Session Idle and SSO Session Max to 8 hours (Realm settings > Sessions) and declare
fullName,phoneandhtxIdas admin-only attributes (Realm settings > User profile). - Assign the
htx_codeattribute to existing accounts in Keycloak, or they receiveNO_HTX. - Old notifications with neither a recipient nor an HTX are no longer shown; n8n system alerts remain visible.
- Rows with a null
htx_profile_id(households, lots) become invisible and unwritable and must be assigned to an HTX (seescripts/backfill-htx-profile-id.sql). - Documents written before this release stay under
para/Projects/,para/Areas/,para/Resources/andpara/Archives/. They are no longer listed and are not moved automatically; copy them topara/<htxCode>/...to use them again. - Certificates of exported lots whose keys are outside
para/<htxCode>/of the lot's HTX now answer 403 on the public page, and such journal photos stop showing. Copy the object into that folder and update the key to use it again. - Set
KEYCLOAK_ADMINas well asKEYCLOAK_ADMIN_PASSWORDindocker/.env.local, or the admin routes answer 500 in production. - Set
AUTH_URLindocker/.env.localwhen the web app is not served fromhttp://localhost:3000, and add that URL to the redirect URIs of thenextjs-webclient. - Known limits:
9081must stay unpublished, because it is not rate limited per IP;workflows/mattermost-push.jsonposts disease and harvest events of all HTXs to one webhook; in production, pre-upgrade cookies go to login;/api/dev-logincookies carry no access token, so core reads fail closed; the write path is protected in the application, not in the database; thePOST /api/registerlimit is per process and trustsX-Forwarded-For, clients behind one proxy or NAT share it and a value that is not a valid IP goes to one sharedunknownbucket, so it must move to the gateway or a shared store whenwebruns more than one instance.
Container images
ghcr.io/maiychrus25/opentea-dx-os-web:1.6.0ghcr.io/maiychrus25/opentea-dx-os-api:1.6.0ghcr.io/maiychrus25/opentea-dx-os-postgres:1.6.0ghcr.io/maiychrus25/opentea-dx-os-scanner:1.6.0ghcr.io/maiychrus25/opentea-dx-os-migrate:1.6.0ghcr.io/maiychrus25/opentea-dx-os-dataops:1.6.0
Deploy
Download opentea-dx-os-1.6.0.tar.gz, verify it with SHA256SUMS, then follow the
release deployment guide (6-step order: postgres, platform-init, migrate, platform-init again, rest, then --profile tools run --rm ollama-init to pull the pinned LLM model).
Set DXOS_MQTT_DEVICES and DXOS_MQTT_INGEST_PASSWORD in docker/.env.local first: the broker refuses to start while any MQTT password begins with change_me.
Also set MINIO_ACCESS_KEY, MINIO_SECRET_KEY (SeaweedFS refuses placeholders), KEYCLOAK_ADMIN and KEYCLOAK_ADMIN_PASSWORD, and run every command as docker compose --env-file docker/.env.local -f docker/docker-compose.yml -f docker/docker-compose.release.yml ..., otherwise Compose ignores those values.