From b7aeee9fe8e08ffb6773baceca3e2bfe690bc3f6 Mon Sep 17 00:00:00 2001 From: kiskaadee Date: Sat, 14 Nov 2026 00:12:01 -0500 Subject: [PATCH] docs: reconcile overview, README, and proto comments with DEC-3/4/8 - Update docs/overview.md to reflect pluggable reverse-proxy/OIDC SSO (DEC-8), hard-fail sanitizer behavior on dangerous payloads (DEC-3), and Stage 1 TMDB resolution at ingestion (DEC-4) instead of hardcoded Authelia/Traefik/domain examples. - Update README.md quick-start sync command to uv sync --all-packages and remove unimplemented docker-compose.yml from the current directory tree. - Update proto/magnetflix/v1/pipeline.proto comments to reference generic upstream SSO identity headers and info_hash deduplication, and regenerate protobuf stubs + docs/api_spec.md via buf generate. - Update DownloadJob.requested_by column doc metadata in services/worker/src/worker/db/models.py to match configurable AUTH_HEADER_USER. --- README.md | 5 ++-- docs/api_spec.md | 4 ++-- docs/overview.md | 23 ++++++++++--------- proto/magnetflix/v1/pipeline.proto | 4 ++-- .../src/magnetflix/v1/pipeline_pb2.pyi | 2 +- .../src/magnetflix/v1/pipeline_pb2_grpc.py | 2 +- .../src/magnetflix/v1/pipeline_pb2_grpc.pyi | 6 ++--- services/worker/src/worker/db/models.py | 2 +- 8 files changed, 24 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 0fa0b59..b9c0a02 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,8 @@ # 1. Enter hermetic dev shell (Nix) nix develop -# 2. Or install dependencies with uv workspace -uv sync +# 2. Or install dependencies for all workspace packages with uv +uv sync --all-packages # 3. Generate protobuf stubs & documentation make generate @@ -49,7 +49,6 @@ make check ├── README.md # Project landing page ├── buf.gen.yaml # Buf code generation configuration ├── buf.yaml # Buf module configuration -├── docker-compose.yml # Multi-container Compose stack specification ├── docs/ # Authoritative architecture and operations documentation │ ├── adr/ # Architecture Decision Records (ADRs) │ ├── history/ # Audit logs and review ledgers diff --git a/docs/api_spec.md b/docs/api_spec.md index 7d874ef..309ee49 100644 --- a/docs/api_spec.md +++ b/docs/api_spec.md @@ -158,7 +158,7 @@ Request to submit a new movie download. | ----- | ---- | ----- | ----------- | | magnet_uri | [string](#string) | | Magnet URI of the torrent to fetch. | | imdb_id | [string](#string) | | IMDb ID of the movie (e.g., "tt1375666"). | -| requested_by | [string](#string) | | Username of the user requesting the download (from Authelia Remote-User). | +| requested_by | [string](#string) | | Username of the user requesting the download (from upstream SSO identity header). | @@ -212,7 +212,7 @@ PipelineService coordinates movie download jobs, safety scans, and library reloc | Method Name | Request Type | Response Type | Description | | ----------- | ------------ | ------------- | ------------| -| SubmitDownload | [SubmitDownloadRequest](#magnetflix-v1-SubmitDownloadRequest) | [SubmitDownloadResponse](#magnetflix-v1-SubmitDownloadResponse) | SubmitDownload enqueues a new movie download job. Rejects duplicate submissions if an active job for the same IMDb ID exists or if already in library. | +| SubmitDownload | [SubmitDownloadRequest](#magnetflix-v1-SubmitDownloadRequest) | [SubmitDownloadResponse](#magnetflix-v1-SubmitDownloadResponse) | SubmitDownload enqueues a new movie download job. Rejects duplicate submissions if an active job for the same IMDb ID or info_hash exists, or if already in library. | | GetJob | [GetJobRequest](#magnetflix-v1-GetJobRequest) | [GetJobResponse](#magnetflix-v1-GetJobResponse) | GetJob retrieves the current status and metadata of a specific job. | | StreamJobStatus | [StreamJobStatusRequest](#magnetflix-v1-StreamJobStatusRequest) | [StreamJobStatusResponse](#magnetflix-v1-StreamJobStatusResponse) stream | StreamJobStatus streams real-time status updates. Semantics: Emits an immediate snapshot of matching active jobs upon connection, followed by subsequent state and progress change events. | | ListJobs | [ListJobsRequest](#magnetflix-v1-ListJobsRequest) | [ListJobsResponse](#magnetflix-v1-ListJobsResponse) | ListJobs returns a paginated list of download jobs. | diff --git a/docs/overview.md b/docs/overview.md index ddc4d61..2431946 100644 --- a/docs/overview.md +++ b/docs/overview.md @@ -11,10 +11,10 @@ When self-hosting a media server (Jellyfin/Plex): 2. In multi-user setups, tracking who requested what and keeping track of download failures is difficult without a dedicated audit log. **MagNetFlix** solves this with an end-to-end automated workflow: -- **Input**: A simple web form protected by **Authelia SSO** accepting an **IMDb ID** and a **Magnet URI**. +- **Input**: A simple web form protected by **pluggable reverse-proxy / OIDC SSO** accepting an **IMDb ID** and a **Magnet URI**. - **Processing**: A background **gRPC worker** handles downloading via Transmission into a sandboxed staging directory. -- **Safety**: Recursively scans and purges all non-media/dangerous executable files. -- **Organization**: Fetches official metadata for the IMDb ID, verifies movie details, and places renamed media files into your library structure. +- **Safety**: Recursively scans staging payloads, ignoring benign clutter while hard-failing jobs containing dangerous executables, archives, symlinks, or path traversal. +- **Organization**: Resolves official TMDB metadata for the IMDb ID at ingestion, verifies movie tokens post-download, and atomically places renamed media files into your library structure. - **Observability**: Live status tracking and persistent audit logs. --- @@ -25,24 +25,25 @@ When self-hosting a media server (Jellyfin/Plex): sequenceDiagram autonumber actor User as Authenticated User - participant Traefik as Traefik (SSO Protected) + participant Proxy as Reverse Proxy (SSO Protected) participant BFF as FastAPI (BFF Gateway) participant Worker as gRPC Pipeline Worker participant Engine as Transmission Daemon participant Media as Jellyfin / Plex Library - User->>Traefik: GET addmovie.roadtotech.me - Traefik->>User: Renders MagNetFlix Web Form - User->>Traefik: Submit form (magnet URI + IMDb ID: tt1375666) - Traefik->>BFF: POST /api/v1/downloads (includes Remote-User header) + User->>Proxy: GET https:// + Proxy->>User: Renders MagNetFlix Web Form + User->>Proxy: Submit form (magnet URI + IMDb ID: tt1375666) + Proxy->>BFF: POST /api/v1/downloads (includes AUTH_HEADER_USER header) BFF->>Worker: gRPC SubmitDownload(magnet, imdb_id, user) + Worker->>Worker: Resolve TMDB title/year (Stage 1) Worker-->>BFF: Acknowledged (Job ID: job-42) BFF-->>User: Enqueued! Showing live progress Worker->>Engine: Start torrent download in /data/staging/job-42 Engine-->>Worker: Download Completed - Worker->>Worker: Run Security Whitelist Scan (Purge .exe/.bat) - Worker->>Worker: Verify IMDb metadata & rename files - Worker->>Media: Move to /media/movies/Inception (2010) [imdbid-tt1375666]/ + Worker->>Worker: Run Two-Tier Security Scan (Hard-fail .exe/.bat) + Worker->>Worker: Verify cached TMDB title/year tokens & rename files + Worker->>Media: Atomic swap to /media/movies/Inception (2010) [imdbid-tt1375666]/ Worker-->>BFF: Status: COMPLETED BFF-->>User: Notification: Movie ready in library! ``` diff --git a/proto/magnetflix/v1/pipeline.proto b/proto/magnetflix/v1/pipeline.proto index 769d69f..ce65e5b 100644 --- a/proto/magnetflix/v1/pipeline.proto +++ b/proto/magnetflix/v1/pipeline.proto @@ -7,7 +7,7 @@ import "google/protobuf/timestamp.proto"; // PipelineService coordinates movie download jobs, safety scans, and library relocation. service PipelineService { // SubmitDownload enqueues a new movie download job. - // Rejects duplicate submissions if an active job for the same IMDb ID exists or if already in library. + // Rejects duplicate submissions if an active job for the same IMDb ID or info_hash exists, or if already in library. rpc SubmitDownload (SubmitDownloadRequest) returns (SubmitDownloadResponse); // GetJob retrieves the current status and metadata of a specific job. @@ -40,7 +40,7 @@ message SubmitDownloadRequest { string magnet_uri = 1; // IMDb ID of the movie (e.g., "tt1375666"). string imdb_id = 2; - // Username of the user requesting the download (from Authelia Remote-User). + // Username of the user requesting the download (from upstream SSO identity header). string requested_by = 3; } diff --git a/services/contracts/src/magnetflix/v1/pipeline_pb2.pyi b/services/contracts/src/magnetflix/v1/pipeline_pb2.pyi index 8d12669..4fd92a9 100644 --- a/services/contracts/src/magnetflix/v1/pipeline_pb2.pyi +++ b/services/contracts/src/magnetflix/v1/pipeline_pb2.pyi @@ -62,7 +62,7 @@ class SubmitDownloadRequest(_message.Message): imdb_id: _builtins.str """IMDb ID of the movie (e.g., "tt1375666").""" requested_by: _builtins.str - """Username of the user requesting the download (from Authelia Remote-User).""" + """Username of the user requesting the download (from upstream SSO identity header).""" def __init__( self, *, diff --git a/services/contracts/src/magnetflix/v1/pipeline_pb2_grpc.py b/services/contracts/src/magnetflix/v1/pipeline_pb2_grpc.py index af347e0..3565ec9 100644 --- a/services/contracts/src/magnetflix/v1/pipeline_pb2_grpc.py +++ b/services/contracts/src/magnetflix/v1/pipeline_pb2_grpc.py @@ -43,7 +43,7 @@ class PipelineServiceServicer: def SubmitDownload(self, request, context): """SubmitDownload enqueues a new movie download job. - Rejects duplicate submissions if an active job for the same IMDb ID exists or if already in library. + Rejects duplicate submissions if an active job for the same IMDb ID or info_hash exists, or if already in library. """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') diff --git a/services/contracts/src/magnetflix/v1/pipeline_pb2_grpc.pyi b/services/contracts/src/magnetflix/v1/pipeline_pb2_grpc.pyi index 22aa601..fd010fd 100644 --- a/services/contracts/src/magnetflix/v1/pipeline_pb2_grpc.pyi +++ b/services/contracts/src/magnetflix/v1/pipeline_pb2_grpc.pyi @@ -35,7 +35,7 @@ class PipelineServiceStub: def __new__(cls, channel: _aio.Channel) -> PipelineServiceAsyncStub: ... SubmitDownload: _grpc.UnaryUnaryMultiCallable[_pipeline_pb2.SubmitDownloadRequest, _pipeline_pb2.SubmitDownloadResponse] """SubmitDownload enqueues a new movie download job. - Rejects duplicate submissions if an active job for the same IMDb ID exists or if already in library. + Rejects duplicate submissions if an active job for the same IMDb ID or info_hash exists, or if already in library. """ GetJob: _grpc.UnaryUnaryMultiCallable[_pipeline_pb2.GetJobRequest, _pipeline_pb2.GetJobResponse] """GetJob retrieves the current status and metadata of a specific job.""" @@ -54,7 +54,7 @@ class PipelineServiceAsyncStub(PipelineServiceStub): def __init__(self, channel: _aio.Channel) -> None: ... SubmitDownload: _aio.UnaryUnaryMultiCallable[_pipeline_pb2.SubmitDownloadRequest, _pipeline_pb2.SubmitDownloadResponse] # type: ignore[assignment] """SubmitDownload enqueues a new movie download job. - Rejects duplicate submissions if an active job for the same IMDb ID exists or if already in library. + Rejects duplicate submissions if an active job for the same IMDb ID or info_hash exists, or if already in library. """ GetJob: _aio.UnaryUnaryMultiCallable[_pipeline_pb2.GetJobRequest, _pipeline_pb2.GetJobResponse] # type: ignore[assignment] """GetJob retrieves the current status and metadata of a specific job.""" @@ -76,7 +76,7 @@ class PipelineServiceServicer(metaclass=_abc_1.ABCMeta): context: _ServicerContext, ) -> _typing.Union[_pipeline_pb2.SubmitDownloadResponse, _abc.Awaitable[_pipeline_pb2.SubmitDownloadResponse]]: """SubmitDownload enqueues a new movie download job. - Rejects duplicate submissions if an active job for the same IMDb ID exists or if already in library. + Rejects duplicate submissions if an active job for the same IMDb ID or info_hash exists, or if already in library. """ @_abc_1.abstractmethod diff --git a/services/worker/src/worker/db/models.py b/services/worker/src/worker/db/models.py index a8d04c5..315421f 100644 --- a/services/worker/src/worker/db/models.py +++ b/services/worker/src/worker/db/models.py @@ -140,7 +140,7 @@ class DownloadJob(Base): String(128), nullable=False, index=True, - doc="Authenticated user from Remote-User SSO header", + doc="Authenticated user from upstream SSO identity header", ) state: Mapped[str] = mapped_column( String(32),