Aller au contenu principal

events

Status: implemented (cmd/events, tests). Runs in the apps profile of docker-compose.yml on port 8086 (Google Calendar not configured there, so the fake calendar is used). Reached through the gateway thanks to the compose GATEWAY_ROUTES entries /v1/events, /v1/public/events and /v1/public/calendar; the gateway built-in default routes do not include them. The gateway matches whole path segments, so /v1/public/calendar/<token>.ics is routed but /v1/public/calendar.ics is not (503 upstream_unavailable through the gateway; reachable directly on port 8086). The gateway caches the public responses (PUBLIC_CACHE_TTL); token feeds are private, no-store and never cached. See Not implemented.

Role: the association calendar: events and machine/room bookings, public or private, optionally linked to a site, a project and inventory items. It serves the public planning of the main page, a public ICS feed, revocable per-user ICS feeds, and pushes public events to a Google calendar.

Limits: no approval, no conflict detection (overlaps are allowed), no registrations, attendance or capacity; invitations only control visibility (no notification, no RSVP). Items are referenced by ID only; booking a machine does not change its inventory status.

Model and rules​

  • Event: title, description, starts_at, ends_at, all_day, timezone (default DEFAULT_TIMEZONE), site_id, location (free text), item_ids (max 50), project_id, visibility (public | private), external_guests_allowed, recurrence (RFC 5545 rrule + exdates, max 500), created_by, invitees (user_ids, role_ids, project_role_ids), invite_read_private_holders, show_as_busy. Max duration of one occurrence: 92 days. Aggregate event, current state in calendar_events with first_start / last_end bounds (null for infinite series) used to select candidates.
  • Validation: site_id must be a slug and project_id / item_ids ULIDs; their existence is not checked (authz only sees the site and project ARNs as parents). visibility defaults to private. Invitees: user_ids are Keycloak UUIDs (lower-cased, max 500), role_ids / project_role_ids ULIDs (max 50 each); roles are not checked for existence.
  • Visibility (one rule, event.Access.Level, mirrored by the MongoDB filter): public events are readable by anyone. A private event shows its details to its creator, to managers (events.event.update on the event scope, events.event.manage_all in admin mode), to invited users, to members of an invited global or project role, and, when invite_read_private_holders is set, to holders of events.event.read_private on the event scope. Being authenticated is not enough. Others get 404, unless show_as_busy is set: they then see a redacted event (busy: true, title "Réservé", no description, creator, project nor invitees; slot, site, location and items kept), in GET /v1/events/:id, lists, occurrences, the public API and the ICS feeds (SUMMARY:Réservé, CLASS:CONFIDENTIAL, no DESCRIPTION). Busy readers cannot update or delete (403). Role membership comes from authz SubjectRoles (assignments, Keycloak-synced roles and the default user role; an API key only has its own roles), fetched once per request. Events stored before invitations have no invite_read_private_holders field: it is read as true and written as true on their next update, so their previous visibility is kept.
  • Writes: creation needs events.event.create on the event ARN. Update and delete are allowed to the creator, else need events.event.update / delete, with events.event.manage_all (elevated) as fallback. Moving an event to another site or project also needs events.event.create there.
  • Optimistic concurrency: PATCH takes an optional version (body, or the If-Match header when the body has none), DELETE an optional If-Match (3, "3", W/"3") or ?version=. When given and different from the current version the write fails with 409 version_conflict (checked after the permission checks); a malformed value is 400 invalid_version. Without a version the last write wins (backward compatible). A race between the check and the save still fails with 409 concurrent_modification. The web client always sends the version it loaded, and on 409 reloads the event and shows a message.
  • Windows: from / to are RFC 3339; from defaults to now and to to from + 5 days. Max span 62 days for the public API, 366 days when authenticated. Occurrence pages are cursor paginated.
  • ICS feeds: from 31 days ago to 12 months ahead. The token feed is evaluated as its owner: the service signs a short-lived user principal (no admin mode, no step-up) so authz applies the owner's scopes and roles.
  • Calendar tokens: 256 random bits (base64url, shown once), only the SHA-256 hash is stored; one token per user, issuing a new one revokes the previous one.
  • Member erasure: on members.member.erased the member's calendar token is revoked and the member is removed from invitees.user_ids of every live event (an events.event.update with fields: [invitees], details not re-validated so legacy data never blocks it). created_by keeps the Keycloak ID: events store no name or email, only opaque IDs. Idempotent; failures are retried by the consumer.
  • Deletion: soft delete; the state is purged after EVENT_PURGE_DELAY by a lease job (events-purge, every EVENT_PURGE_INTERVAL, one replica), the event log is kept.

ARNs: atl:events:<site>:event/<id> (parents atl:settings:<site>:site/<site> and, when linked, atl:projects:<site>:project/<id>), atl:events:*:calendar/* (resync), atl:events:*:calendar_token/<user> (audit).

Google Calendar​

A consumer (group events-gcal) reads events.event.v1 and syncs the event: public and live → insert/update (Google event ID derived from the event ID, last pushed version stored), otherwise → removed from Google. Failures are retried by the consumer then sent to events.event.v1.dlq; a lease job (events-gcal-reconcile, every GOOGLE_RECONCILE_INTERVAL) reconciles every public and every mapped event. Without GOOGLE_SA_JSON_FILE and GOOGLE_CALENDAR_ID a fake calendar logs the calls (refused in production). Private events, including those shown as busy, are never pushed.

Dependencies​

  • Services: authz (ConnectRPC Check, LookupResources, SubjectRoles through authzclient).
  • Infrastructure: MongoDB (replica set, transactions), Kafka, Google Calendar API (service account).
  • Libraries: authzclient, httpx, principal (verifier + signer), pagination, problem, eventstore, outbox, audit, cloudevent, kafkax, lease, mongox, telemetry, logging, config. See libraries.

Inputs and outputs​

OpenAPI: API reference (services/events/openapi.yaml).

MethodPathAuth / permission
GET/v1/public/events?from&toanonymous; public occurrences and busy private ones (busy: true), Cache-Control: public, max-age=60
GET/v1/public/calendar.icsanonymous; public events and busy private ones
GET/v1/public/calendar/<token>.icstoken; events readable by the token owner, private, no-store
GET/v1/events?site&project&mineauthenticated; filtered by visibility rules (paginated events, not occurrences)
POST/v1/eventsevents.event.create
GET/v1/events/occurrences?from&to&site&project&mineauthenticated; filtered by visibility rules
GET/v1/events/:idvisibility rules
PATCH, DELETE/v1/events/:idcreator, or events.event.update / delete, or events.event.manage_all
GET, POST, DELETE/v1/events/me/calendar-tokena user, or a user-owned API key (403 otherwise)
POST/v1/events/calendar/resyncevents.calendar.manage (synchronous Google reconciliation)
KindNameNotes
RPC outauthz.v1.AuthzService/Check, LookupResources, SubjectRolespermission checks, read_private / update scopes, role membership for invitations
HTTP outGoogle Calendar APIpublic events only
Kafka outevents.event.v1created (details, creator), updated (patched field names + details), deleted (visibility, purge date)
Kafka outaudit.records.v1events.event.create/update/delete/purge, events.calendar_token.issue/revoke, events.google.push/remove
Kafka inevents.event.v1own events → Google Calendar sync (group events-gcal)
Kafka inmembers.member.v1members.member.erased (subject = member ID, else data.id; other fields ignored) → token revocation and invitee removal (group events-erasure)
Kafka outevents.event.v1.dlqGoogle sync failures after 5 attempts

The public web pages (main page planning, /events) read GET /v1/public/events; no web screen uses the authenticated API yet (/app/events is a "coming soon" placeholder).

See CQRS and Kafka for the outbox and event envelope.

Data (MongoDB events)​

CollectionKey fieldsIndexes
calendar_eventsevent state, version, first_start, last_end, deleted_at, purge_atpartial purge_at; (visibility, first_start); site_id, project_id, created_by (each with first_start and with _id); show_as_busy, invitees.user_ids, invitees.role_ids, invitees.project_role_ids (each with first_start); last_end; (deleted_at, _id)
calendar_tokens_id = user ID, hash, created_atunique hash
google_events_id = event ID, google_id, version, synced_at—
eventsevent logeventstore indexes
outbox, lockspending Kafka messages, lease jobs—

Not implemented​

  • item_ids, project_id and site_id are not checked against inventory, projects or settings; booking a machine does not change its inventory status.
  • Soft-deleted events (awaiting purge) and the event log keep an erased member's ID in invitees.user_ids and created_by (opaque IDs, no PII).
  • events.event.read is declared in the catalogue (and gates the /app/events menu in the web app) but the service never checks it: public events are readable anonymously, private ones through the visibility rule.
  • No compose gateway route for the public ICS feed /v1/public/calendar.ics (see the status above).
  • No internal web screens (create / edit events, calendar token management).

Configuration​

VariableDefaultDescription
HTTP_ADDR:8086Listen address
METRICS_ADDR:9186Prometheus listener
PRINCIPAL_PUBLIC_KEYrequiredVerifies X-Atl-Principal
PRINCIPAL_SIGNING_KEYrequiredSigns the owner principal of tokenised feeds
AUTHZ_URLhttp://localhost:8081authz ConnectRPC endpoint
KAFKA_BROKERSlocalhost:19092Outbox relay, Google sync and member erasure consumers
MONGO_URI, MONGO_DATABASEmongodb://localhost:27017/?directConnection=true, eventsMongoDB
EVENTS_PUBLIC_URLhttp://localhost:8080Absolute API base URL of feed links; its host is the ICS UID domain
DEFAULT_TIMEZONEEurope/ParisDefault event time zone (validated)
EVENTS_CALENDAR_NAMEAtelierICS calendar name ((personnel) appended for token feeds)
EVENT_PURGE_DELAY720h (30 days)Soft delete → purge delay
EVENT_PURGE_INTERVAL1hPurge job period
GOOGLE_SA_JSON_FILE, GOOGLE_CALENDAR_IDemptyGoogle service account and target calendar; required in production
GOOGLE_RECONCILE_INTERVAL30mFull reconciliation period

Plus the common APP_ENV, LOG_LEVEL, OTEL_EXPORTER_OTLP_ENDPOINT (see environment variables).