Files
karaoke-gen/backend/api
Andrew Beveridge ☄️andClaude Opus 5.5 ad64286004 feat(tenant): tenant portals are shared workspaces (v0.297.0) (#1266)
## Summary
Andrew's expectation: "all jobs in the tenant portal are accessible to
everyone who has permission to access that portal." Until now a
non-admin only saw/opened jobs whose `user_email` was their own, even on
a tenant portal. A client logging in with their own email never saw the
10 jobs bulk-uploaded for them under a separate `@nomadkaraoke.com`
address, and re-submitted every song.

## Rule (`backend/services/job_access.py`)
- Admins: every job.
- Owner: their jobs.
- **Tenant portal member** (currently allowed to sign in:
`allowed_emails` / `allowed_email_domains`, tenant active): every job of
that tenant. Re-checked per request against the live tenant config (~5
min cache), so removing someone from the allowlist removes access. Fails
closed on lookup errors.
- Consumer jobs (no tenant): owner-only, unchanged.

## Wired into
- `_check_job_ownership` (all job routes: view, edit, rerender, delete,
…)
- full-auth review access (`require_review_auth`:
lyrics/instrumental/audio-edit)
- file-upload guards (finalize, style uploads; style uploads keep
denying ownerless legacy jobs as before)
- `GET /api/jobs`: members on a tenant portal list all of that tenant's
jobs (still tenant-scoped)
- tenant theme refresh/outdated/rerender-outdated scope now covers the
whole portal (routes were already member-gated)

Unchanged on purpose: kjbox singer review links and the consumer
visibility toggle (consumer-only).

## Testing
- New `backend/tests/test_tenant_shared_jobs.py` (20): member/domain
member/case, outsider, consumer privacy, cross-tenant, inactive tenant,
no allowlist, removed member, fail-closed, token-without-email,
ownerless per-route, list scoping (member/outsider/consumer portal),
review auth 200/403, ownership wrapper.
- Updated theme tests that asserted the old owner-only scope; added
teammate-can-rerender.
- Local: 2,710 job/review/upload/tenant tests + 656 theme/tenant tests
pass (only `test_emulator_integration.py` fails locally, which needs the
Firestore emulator; same on main).
- Local CodeRabbit: 1 finding (ownerless legacy jobs on style uploads)
fixed; re-review clean.

## Prod cleanup done alongside (admin API)
Deleted (archived) the 10 stale Sept bulk-upload jobs for the randy-vild
tenant that duplicated his completed RVILD tracks.

@coderabbitai ignore

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_012RYLVVUdF2J1bNeVa2uLXA

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 14:49:27 -05:00
..