From e6b67563933c8660108460d9af9fb08cbd89296b Mon Sep 17 00:00:00 2001 From: Joo Aun Saw Date: Thu, 10 Oct 2019 16:59:29 +1100 Subject: [PATCH] rtsp: support authentication --- .../raspberrypi/overlay/usr/bin/streameye.sh | 27 ++++++++++++++++--- .../raspberrypi2/overlay/usr/bin/streameye.sh | 27 ++++++++++++++++--- .../raspberrypi3/overlay/usr/bin/streameye.sh | 27 ++++++++++++++++--- .../raspberrypi4/overlay/usr/bin/streameye.sh | 27 ++++++++++++++++--- 4 files changed, 96 insertions(+), 12 deletions(-) diff --git a/board/raspberrypi/overlay/usr/bin/streameye.sh b/board/raspberrypi/overlay/usr/bin/streameye.sh index 83950bdb7b..bb642cb8ac 100755 --- a/board/raspberrypi/overlay/usr/bin/streameye.sh +++ b/board/raspberrypi/overlay/usr/bin/streameye.sh @@ -44,9 +44,30 @@ function start() { source ${STREAMEYE_CONF} streameye_opts="-p ${PORT}" rtspserver_opts="" - if [ -n "${CREDENTIALS}" ] && [ "${AUTH}" = "basic" ]; then - streameye_opts="${streameye_opts} -a basic -c ${CREDENTIALS}" - # TODO: Add RTSP Auth + if [ -n "${CREDENTIALS}" ]; then + username=`echo "${CREDENTIALS}" | cut -d ':' -f 1` + password=`echo "${CREDENTIALS}" | cut -d ':' -f 2` + realm=`echo "${CREDENTIALS}" | cut -d ':' -f 3` + if [ "${AUTH}" = "digest" ]; then + if [ -n "${realm}" ]; then + if [ -n "${username}" ]; then + passmd5=`echo -n ${username}:${realm}:${password} | md5sum | cut -d- -f1` + rtspserver_opts="${rtspserver_opts} -U ${username}:${passmd5} -R ${realm}"; + # streameye does not support digest authentication yet, assume basic auth + streameye_opts="${streameye_opts} -a basic -c ${CREDENTIALS}" + fi + else + # Selected digest auth but realm not provided. Fall back to basic auth + AUTH="basic" + fi + fi + if [ "${AUTH}" = "basic" ]; then + if [ -n "${username}" ]; then + rtspserver_opts="${rtspserver_opts} -U ${username}:${password}"; + # streameye does not support digest authentication yet, assume basic auth + streameye_opts="${streameye_opts} -a basic -c ${CREDENTIALS}" + fi + fi fi if [ "${PROTO}" = "rtsp" ]; then diff --git a/board/raspberrypi2/overlay/usr/bin/streameye.sh b/board/raspberrypi2/overlay/usr/bin/streameye.sh index 83950bdb7b..bb642cb8ac 100755 --- a/board/raspberrypi2/overlay/usr/bin/streameye.sh +++ b/board/raspberrypi2/overlay/usr/bin/streameye.sh @@ -44,9 +44,30 @@ function start() { source ${STREAMEYE_CONF} streameye_opts="-p ${PORT}" rtspserver_opts="" - if [ -n "${CREDENTIALS}" ] && [ "${AUTH}" = "basic" ]; then - streameye_opts="${streameye_opts} -a basic -c ${CREDENTIALS}" - # TODO: Add RTSP Auth + if [ -n "${CREDENTIALS}" ]; then + username=`echo "${CREDENTIALS}" | cut -d ':' -f 1` + password=`echo "${CREDENTIALS}" | cut -d ':' -f 2` + realm=`echo "${CREDENTIALS}" | cut -d ':' -f 3` + if [ "${AUTH}" = "digest" ]; then + if [ -n "${realm}" ]; then + if [ -n "${username}" ]; then + passmd5=`echo -n ${username}:${realm}:${password} | md5sum | cut -d- -f1` + rtspserver_opts="${rtspserver_opts} -U ${username}:${passmd5} -R ${realm}"; + # streameye does not support digest authentication yet, assume basic auth + streameye_opts="${streameye_opts} -a basic -c ${CREDENTIALS}" + fi + else + # Selected digest auth but realm not provided. Fall back to basic auth + AUTH="basic" + fi + fi + if [ "${AUTH}" = "basic" ]; then + if [ -n "${username}" ]; then + rtspserver_opts="${rtspserver_opts} -U ${username}:${password}"; + # streameye does not support digest authentication yet, assume basic auth + streameye_opts="${streameye_opts} -a basic -c ${CREDENTIALS}" + fi + fi fi if [ "${PROTO}" = "rtsp" ]; then diff --git a/board/raspberrypi3/overlay/usr/bin/streameye.sh b/board/raspberrypi3/overlay/usr/bin/streameye.sh index 83950bdb7b..bb642cb8ac 100755 --- a/board/raspberrypi3/overlay/usr/bin/streameye.sh +++ b/board/raspberrypi3/overlay/usr/bin/streameye.sh @@ -44,9 +44,30 @@ function start() { source ${STREAMEYE_CONF} streameye_opts="-p ${PORT}" rtspserver_opts="" - if [ -n "${CREDENTIALS}" ] && [ "${AUTH}" = "basic" ]; then - streameye_opts="${streameye_opts} -a basic -c ${CREDENTIALS}" - # TODO: Add RTSP Auth + if [ -n "${CREDENTIALS}" ]; then + username=`echo "${CREDENTIALS}" | cut -d ':' -f 1` + password=`echo "${CREDENTIALS}" | cut -d ':' -f 2` + realm=`echo "${CREDENTIALS}" | cut -d ':' -f 3` + if [ "${AUTH}" = "digest" ]; then + if [ -n "${realm}" ]; then + if [ -n "${username}" ]; then + passmd5=`echo -n ${username}:${realm}:${password} | md5sum | cut -d- -f1` + rtspserver_opts="${rtspserver_opts} -U ${username}:${passmd5} -R ${realm}"; + # streameye does not support digest authentication yet, assume basic auth + streameye_opts="${streameye_opts} -a basic -c ${CREDENTIALS}" + fi + else + # Selected digest auth but realm not provided. Fall back to basic auth + AUTH="basic" + fi + fi + if [ "${AUTH}" = "basic" ]; then + if [ -n "${username}" ]; then + rtspserver_opts="${rtspserver_opts} -U ${username}:${password}"; + # streameye does not support digest authentication yet, assume basic auth + streameye_opts="${streameye_opts} -a basic -c ${CREDENTIALS}" + fi + fi fi if [ "${PROTO}" = "rtsp" ]; then diff --git a/board/raspberrypi4/overlay/usr/bin/streameye.sh b/board/raspberrypi4/overlay/usr/bin/streameye.sh index 83950bdb7b..bb642cb8ac 100755 --- a/board/raspberrypi4/overlay/usr/bin/streameye.sh +++ b/board/raspberrypi4/overlay/usr/bin/streameye.sh @@ -44,9 +44,30 @@ function start() { source ${STREAMEYE_CONF} streameye_opts="-p ${PORT}" rtspserver_opts="" - if [ -n "${CREDENTIALS}" ] && [ "${AUTH}" = "basic" ]; then - streameye_opts="${streameye_opts} -a basic -c ${CREDENTIALS}" - # TODO: Add RTSP Auth + if [ -n "${CREDENTIALS}" ]; then + username=`echo "${CREDENTIALS}" | cut -d ':' -f 1` + password=`echo "${CREDENTIALS}" | cut -d ':' -f 2` + realm=`echo "${CREDENTIALS}" | cut -d ':' -f 3` + if [ "${AUTH}" = "digest" ]; then + if [ -n "${realm}" ]; then + if [ -n "${username}" ]; then + passmd5=`echo -n ${username}:${realm}:${password} | md5sum | cut -d- -f1` + rtspserver_opts="${rtspserver_opts} -U ${username}:${passmd5} -R ${realm}"; + # streameye does not support digest authentication yet, assume basic auth + streameye_opts="${streameye_opts} -a basic -c ${CREDENTIALS}" + fi + else + # Selected digest auth but realm not provided. Fall back to basic auth + AUTH="basic" + fi + fi + if [ "${AUTH}" = "basic" ]; then + if [ -n "${username}" ]; then + rtspserver_opts="${rtspserver_opts} -U ${username}:${password}"; + # streameye does not support digest authentication yet, assume basic auth + streameye_opts="${streameye_opts} -a basic -c ${CREDENTIALS}" + fi + fi fi if [ "${PROTO}" = "rtsp" ]; then