restrict XC access per user by configurable IP allowlist

This commit is contained in:
Seth Van Niekerk 2026-04-28 16:35:32 -04:00
parent 2650bee7e9
commit 8894d51877
No known key found for this signature in database
GPG key ID: E86ACA677312A675
8 changed files with 91 additions and 3 deletions

View file

@ -40,7 +40,7 @@ from .url_utils import (
from .utils import get_logger
from uuid import UUID
import gevent
from dispatcharr.utils import network_access_allowed
from dispatcharr.utils import network_access_allowed, user_xc_ip_allowed
from apps.proxy.utils import check_user_stream_limits
logger = get_logger()
@ -572,6 +572,9 @@ def stream_xc(request, username, password, channel_id):
if custom_properties["xc_password"] != password:
return Response({"error": "Invalid credentials"}, status=401)
if not user_xc_ip_allowed(request, user):
return Response({"error": "Invalid credentials"}, status=401)
if user.user_level < 10:
user_profile_count = user.channel_profiles.count()

View file

@ -19,7 +19,7 @@ from rest_framework.permissions import AllowAny
from apps.accounts.models import User
from apps.accounts.permissions import IsAdmin
from apps.proxy.utils import check_user_stream_limits
from dispatcharr.utils import network_access_allowed
from dispatcharr.utils import network_access_allowed, user_xc_ip_allowed
logger = logging.getLogger(__name__)
@ -1031,6 +1031,9 @@ def stream_xc_movie(request, username, password, stream_id, extension):
if custom_properties["xc_password"] != password:
return Response({"error": "Invalid credentials"}, status=401)
if not user_xc_ip_allowed(request, user):
return Response({"error": "Invalid credentials"}, status=401)
# All authenticated users get access to VOD from all active M3U accounts
filters = {"movie_id": stream_id, "m3u_account__is_active": True}
@ -1065,6 +1068,9 @@ def stream_xc_episode(request, username, password, stream_id, extension):
if custom_properties["xc_password"] != password:
return Response({"error": "Invalid credentials"}, status=401)
if not user_xc_ip_allowed(request, user):
return Response({"error": "Invalid credentials"}, status=401)
# All authenticated users get access to series/episodes from all active M3U accounts
filters = {"episode_id": stream_id, "m3u_account__is_active": True}