Skip to content

Commit caf6eb4

Browse files
committed
webui: remove httpd proxy, read token from onvif requests
1 parent daceafc commit caf6eb4

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
H:/var/www
22
P:/favicon.ico:http://127.0.0.1/a/favicon.ico
3-
P:/image.jpg:http://127.0.0.1/x/ch0.jpg
43
P:/mjpeg:http://127.0.0.1/x/ch0.mjpg

package/thingino-webui/files/www/x/auth.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,18 @@
77

88
API_KEY_FILE="/etc/thingino-api.key"
99

10-
# Verify API key from header (X-API-Key: your-key-here)
10+
# Verify API key from header (X-API-Key: your-key-here) or ?token= query param
1111
# Returns 0 if valid, 1 if invalid
1212
verify_api_key() {
1313
local provided_key="$HTTP_X_API_KEY"
1414

15-
# Also accept key as ?token= query parameter (e.g. snapshot URLs returned by ONVIF)
16-
if [ -z "$provided_key" ] && [ -n "$QUERY_STRING" ]; then
17-
provided_key=$(echo "$QUERY_STRING" | tr '&' '\n' | grep '^token=' | head -1 | cut -d'=' -f2-)
15+
# Fall back to ?token= query parameter (used by ONVIF snapshot URLs)
16+
if [ -z "$provided_key" ]; then
17+
case "$QUERY_STRING" in
18+
token=*) provided_key="${QUERY_STRING#token=}" ;;
19+
*token=*) provided_key="${QUERY_STRING##*token=}" ;;
20+
esac
21+
provided_key="${provided_key%%&*}"
1822
fi
1923

2024
[ -z "$provided_key" ] && return 1

0 commit comments

Comments
 (0)