feat(playout): move liquidsoap auth to notify cli

This commit is contained in:
jo 2023-03-21 14:50:44 +01:00 committed by Kyle Robbertze
parent 114a599993
commit 3f4ebab788
6 changed files with 35 additions and 53 deletions

View File

@ -125,7 +125,7 @@ def make_input_auth_handler(input_name)
log("user '#{user}' connected", label="#{input_name}_input")
# Check auth based on return value from auth script
ret = test_process("python3 '#{auth_path}' '#{input_name}' '#{user}' '#{password}'")
ret = test_process("libretime-playout-notify live-auth '#{input_name}' '#{user}' '#{password}'")
if ret then
log("user '#{user}' authenticated", label="#{input_name}_input")
else

View File

@ -25,7 +25,6 @@ def generate_entrypoint(
version: Tuple[int, int, int],
) -> str:
paths = {}
paths["auth_filepath"] = here / "liquidsoap_auth.py"
paths["lib_filepath"] = here / f"{version[0]}.{version[1]}/ls_script.liq"
if log_filepath is not None:

View File

@ -1,36 +0,0 @@
from argparse import ArgumentParser
from typing import Literal
from libretime_api_client.v1 import ApiClient as LegacyClient
def main(input_name: Literal["main", "show"], username: str, password: str) -> int:
legacy_client = LegacyClient()
input_name_map = {"main": "master", "show": "dj"}
response: dict = legacy_client.check_live_stream_auth(
username,
password,
input_name_map[input_name],
)
if response.get("msg", False) is True:
return 0
return 1
if __name__ == "__main__":
parser = ArgumentParser()
parser.add_argument("input_name", choices=["main", "show"])
parser.add_argument("username")
parser.add_argument("password")
args = parser.parse_args()
raise SystemExit(
main(
input_name=args.input_name,
username=args.username,
password=args.password,
)
)

View File

@ -9,8 +9,6 @@ input_show_mount = {{ config.stream.inputs.show.mount | quote }}
input_show_port = {{ config.stream.inputs.show.port }}
# Settings
auth_path = {{ paths.auth_filepath | quote }}
{% if paths.log_filepath is defined -%}
set("log.file.path", "{{ paths.log_filepath }}")
{%- else -%}

View File

@ -14,7 +14,7 @@ Main case:
"""
import logging
from pathlib import Path
from typing import Optional
from typing import Literal, Optional
import click
from libretime_api_client.v1 import ApiClient as LegacyClient
@ -101,6 +101,39 @@ def live(app: App, name, status):
app.api_client.notify_source_status(name, status)
@cli.command()
@click.argument("input_name", type=click.Choice(["main", "show"]))
@click.argument("username")
@click.argument("password")
@pass_app
def live_auth(
app: App,
input_name: Literal["main", "show"],
username: str,
password: str,
):
"""
Check live stream user authentication.
"""
input_name_map = {"main": "master", "show": "dj"}
logger.info(
"Checking '%s' live stream user authentication '%s'",
input_name,
username,
)
resp = app.api_client.check_live_stream_auth(
username,
password,
input_name_map[input_name],
)
payload: dict = resp.json()
if payload.get("msg", False) is True:
raise SystemExit(0)
raise SystemExit(1)
@cli.command()
@click.argument("stream_id")
@click.argument("time")

View File

@ -12,8 +12,6 @@
input_show_port = 8002
# Settings
auth_path = "/fake/liquidsoap_auth.py"
set("log.file.path", "/var/log/radio.log")
set("server.telnet", true)
@ -49,8 +47,6 @@
input_show_port = 8002
# Settings
auth_path = "/fake/liquidsoap_auth.py"
set("log.file.path", "/var/log/radio.log")
set("server.telnet", true)
@ -111,8 +107,6 @@
input_show_port = 8002
# Settings
auth_path = "/fake/liquidsoap_auth.py"
set("log.file.path", "/var/log/radio.log")
set("server.telnet", true)
@ -169,8 +163,6 @@
input_show_port = 8002
# Settings
auth_path = "/fake/liquidsoap_auth.py"
set("log.file.path", "/var/log/radio.log")
set("server.telnet", true)
@ -252,8 +244,6 @@
input_show_port = 8002
# Settings
auth_path = "/fake/liquidsoap_auth.py"
set("log.file.path", "/var/log/radio.log")
set("server.telnet", true)
@ -297,8 +287,6 @@
input_show_port = 8002
# Settings
auth_path = "/fake/liquidsoap_auth.py"
set("log.file.path", "/var/log/radio.log")
set("server.telnet", true)