mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-07-17 16:50:53 +00:00
restrict XC access per user by configurable IP allowlist
This commit is contained in:
parent
2650bee7e9
commit
8894d51877
8 changed files with 91 additions and 3 deletions
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue