Commit graph

17 commits

Author SHA1 Message Date
LimeDrive
0f310a958f feat(api): add config encoding endpoint with CSRF protection
Implement POST /encode endpoint for encrypting user configuration tokens.
Uses Fernet encryption with automatic Base64 fallback when CONFIG_SECRET_KEY
is not set. Protected by signed CSRF token validation to prevent cross-site
attacks.
2026-03-30 02:23:41 +02:00
LimeDrive
7755a78842 feat(security): add Fernet encryption for config tokens and CSRF protection
- Implement Fernet encryption for configuration URLs to protect sensitive user settings
- Add CONFIG_SECRET_KEY environment variable for key derivation
- Add server-side /api/config/encode endpoint for secure config token generation
- Add CSRF token generation and validation for all admin POST routes
- Auto-inject CSRF tokens into admin forms and AJAX requests via JavaScript
- Update frontend to use async server encoding instead of client-side Base64
- Add localStorage fallback for config restoration on /configure pages
- Maintain backward compatibility with existing Base64-encoded URLs
- Log warning at startup if CONFIG_SECRET_KEY is not configured
- Convert debug logs to trace level in TorrentSmartContainer for reduced noise
2026-03-30 01:18:08 +02:00
LimeDrive
8468bae024 feat(admin): add metadata mappings table and complete admin UI redesign
Introduce a metadata_mappings table with DAO/model layers for admin-managed
IMDB→TMDB/title overrides, and overhaul the admin panel with a modern
Bootstrap 5 sidebar UI.

- Add metadata_mappings table with migrations (search_titles, year_override)
- Add MetadataMappingDAO with standalone session helpers for use outside FastAPI
- Add new admin pages: dashboard, mappings CRUD, maintenance, config, hash/TMDB search
- Integrate DB mapping lookups into Cinemeta and TMDB metadata providers
- Update catalog views to use DB mappings before hitting external APIs
- Rewrite all admin templates with Bootstrap 5, sidebar navigation, French labels
- Add session-based auth for admin routes with Redis session store
2026-03-29 04:46:51 +02:00
LimeDrive
0aba81abb2 feat(peer): add authenticated peer-to-peer cache sharing
Introduces a secure peer-to-peer cache sharing system using HMAC-SHA256 request signatures and Fernet (AES-128-CBC) response encryption.

- New peer_keys table for per-peer credential management (key_id, secret)
- New /api/peer/check endpoint returns encrypted debrid availability data
- New /api/peer/items endpoint returns encrypted torrent metadata
- Rate limiting per peer key with configurable limits and windows
- Admin UI for creating, viewing, revoking, and deleting peer keys
- Peer cache enrichment integrated into BaseDebrid L2.5 lookup pipeline
- StremThruDebrid override with cross-service PG L2 check + peer cache
- Removed old /api/share/cache endpoint (replaced by /api/peer/*)
- Added cryptography package dependency

BREAKING CHANGE: The /api/share/cache endpoint has been removed and replaced with /api/peer/check. Clients must update to use HMAC authentication with X-Peer-Key-Id, X-Peer-Timestamp, and X-Peer-Signature headers.
2026-03-28 05:07:40 +01:00
LimeDrive
0c8bcb48f9 feat(share): add debrid cache availability check endpoint
Add new `/share/cache` API endpoint that returns which info-hashes are confirmed cached on a given debrid service. Uses hash-only projection to avoid leaking file metadata. Includes API key auth and Redis-based rate limiting.
2026-03-26 16:21:55 +01:00
LimeDrive
5e183c48a0 refactor: async fixes, security hardening, and code deduplication
Async correctness:
- Wrap blocking time.sleep/requests.get calls with asyncio.to_thread()
  in torrent_service.py and torr9_service.py
- Run cache_container_items() as fire-and-forget background task via
  asyncio.create_task(asyncio.to_thread(...)) in search/views.py
- Make RDTokenManager.get_access_token() and new_access_token() async,
  replace requests.post with aiohttp (token_manager.py)
- Make RealDebrid.get_headers() async, await all callers (realdebrid.py)

Security:
- Remove API key, device code, and PIN values from log output
  (auth/views.py, admin/views.py)
- Add WARNING on startup when SESSION_KEY uses the insecure default
  value (settings.py)
- Make admin template dir configurable via settings.admin_template_dir

Performance:
- Parallelize TMDB metadata fetches with asyncio.gather() (catalog/views.py)
- Add tmdb_language setting instead of hardcoded "fr-FR"

Deduplication:
- Extract ensure_uuid() to stream_fusion/web/api/utils.py
- Extract get_client_ip() to stream_fusion/web/utils.py
- Replace 8-way if/elif debrid factory with _SERVICE_MAP dict +
  _build_service() helper (get_debrid_service.py)
- Extract _model_to_schema() in APIKeyDAO to remove 6 repeated blocks
- Simplify ProxyStreamer: remove manual BytesIO buffer, stream directly
  via iter_any() (stream/views.py)

Inspired by commits 823bc77 and e306eb5 from limedrive/develop.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-24 19:05:33 +01:00
Telkaoss
f2d7e1589f
Update schemas.py 2025-05-23 04:31:02 +02:00
Telkaoss
86d37233c9
Update views.py 2025-05-23 04:30:29 +02:00
LimeDrive
d2f00f5ac4 Refactor .gitignore and settings.py files 2024-09-23 13:56:06 +00:00
LimeDrive
e1bf2accab Switch APIKEY the auth on postgres
update 16 files and delete 2 files
2024-09-19 17:51:18 +02:00
LimeDrive
86efdd0113 Add PostgreSQL related files and modules 2024-09-18 18:13:42 +02:00
LimeDrive
851e0d3e1f Update TODO list for tree. 2024-09-18 02:30:05 +02:00
LimeDrive
9ca674a255 create 1 file and update 5 files 2024-07-31 18:38:01 +02:00
LimeDrive
a34302182f ScrapyFix: HTTPS 2024-07-11 22:32:55 +02:00
LimeDrive
472c3b4102 admin panel 2024-07-11 16:12:01 +02:00
LimeDrive
50f971971d update 20 files config refractor 2024-07-10 13:31:28 +02:00
LimeDrive
6fe4fe55f3 init 2024-07-09 04:13:29 +02:00