Skip to content
Kopuz-orgPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Kopuzer

Central Protobuf + gRPC hub for Kopuz: end-to-end encrypted cross-device sync, anywhere remote control (phone <-> desktop), and Listen-Together Jam rooms.

See docs/ARCHITECTURE.md for the full architectural specification (wire contracts, auth & OAuth email-linking invariants, Redis rate limiter, E2EE sync model, Jam clock sync, schema, and telemetry).

Features

  • Protobuf + gRPC (kopuzer-proto): Typed tonic + prost services compiled with pure-Rust protox (no system protoc needed), with gRPC reflection and standard gRPC health checks.
  • Authentication:
    • Email + password hashed with Argon2id (OWASP parameters, non-blocking worker pool).
    • OAuth logins for Google, Apple, and Facebook (supporting both OAuth2 authorization code / PKCE and native mobile SDK id_token / access_token).
    • Cross-service email matching: Automatically links Google, Apple, Facebook, and password logins into the same user account when both sides carry verified emails.
    • Optional Passkeys (WebAuthn / FIDO2): Passwordless registration and sign-in backed by webauthn-rs and Redis challenges.
    • Short-lived JWT access tokens + single-use rotating refresh tokens stored hashed in PostgreSQL.
  • Redis IP Rate Limiting:
    • 3 failed login attempts per IP trigger a 1-hour cooldown (RESOURCE_EXHAUSTED with retry-after metadata).
    • Counter resets immediately upon a successful login.
  • E2EE Op-Log Sync (SyncService): Append-only encrypted deltas deduplicated by (device_id, client_seq), live WatchOps stream via Redis Pub/Sub, and encrypted snapshots for compaction or queue handoff.
  • Anywhere Remote Control (RemoteControlService): Bidirectional device tunnels + Redis Pub/Sub relay so devices can control each other across any network with E2EE payloads.
  • Listen-Together Jam Rooms (JamService): Short invite codes, server-authoritative clock sync (JamClockPing/JamClockPong), portable cross-backend track descriptors, and collaborative or host-controlled playback policies.
  • Observability (Default OFF): OpenTelemetry OTLP trace exporter (OTEL_ENABLED=false by default) and Prometheus /metrics endpoint ready for Grafana, Tempo, and Prometheus.

Quick Start (Docker Compose)

cp .env.example .env
# Edit JWT_SECRET and optional OAuth credentials in .env
docker compose up -d

To include Grafana, Prometheus, Tempo, and the OpenTelemetry Collector locally:

OTEL_ENABLED=true PROMETHEUS_METRICS_ENABLED=true docker compose --profile telemetry up -d

Endpoints:

  • gRPC: localhost:50051
  • HTTP health / OAuth callback: http://localhost:8080/healthz, /readyz, /oauth/{provider}/callback
  • Prometheus metrics (when enabled): http://localhost:8080/metrics
  • Grafana (with --profile telemetry): http://localhost:3000 (admin / admin)

Kubernetes / Helm

helm install kopuzer ./charts/kopuzer \
  --set secrets.databaseUrl="postgres://kopuzer:pass@postgres:5432/kopuzer" \
  --set secrets.redisUrl="redis://redis:6379" \
  --set secrets.jwtSecret="$(openssl rand -hex 32)"

Enable OpenTelemetry + Prometheus ServiceMonitor for Grafana:

helm upgrade kopuzer ./charts/kopuzer \
  --reuse-values \
  --set config.telemetry.otelEnabled=true \
  --set config.telemetry.prometheusMetricsEnabled=true \
  --set config.telemetry.otlpEndpoint="http://otel-collector.observability.svc.cluster.local:4317" \
  --set serviceMonitor.enabled=true

Docker Hub Publishing

Set repository secrets DOCKERHUB_USERNAME and DOCKERHUB_TOKEN in GitHub Actions to publish multi-arch (linux/amd64, linux/arm64) images automatically via .github/workflows/docker.yml.

Local Development

cargo fmt --all -- --check
cargo clippy --workspace --all-targets -- -D warnings
cargo test --workspace

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages