]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
http: allow both ticket and username/password auth
authorSven Wegener <sven.wegener@stealer.net>
Mon, 9 Nov 2015 19:45:36 +0000 (20:45 +0100)
committerJaroslav Kysela <perex@perex.cz>
Mon, 9 Nov 2015 21:11:16 +0000 (22:11 +0100)
When the default account has not all privileges, downloading the
playlist anonymously can result in URLs that can't be accessed with the
ticket in the URLs. The client then prompts for username and password,
you enter the correct credentials, but the credentials are not accepted.
Allow username and password in case ticket authorization fails.

Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
src/http.c

index b71c05b503342bc4cef85cfc341d0113406fddb7..f2e6cb580daf36b48c4c4fa43725cf55d9b9bed4 100644 (file)
@@ -545,16 +545,21 @@ http_access_verify_ticket(http_connection_t *hc)
 int
 http_access_verify(http_connection_t *hc, int mask)
 {
+  int res = -1;
+
   http_access_verify_ticket(hc);
+  if (hc->hc_access)
+    res = access_verify2(hc->hc_access, mask);
 
-  if (hc->hc_access == NULL) {
+  if (res) {
+    access_destroy(hc->hc_access);
     hc->hc_access = access_get(hc->hc_username, hc->hc_password,
                                (struct sockaddr *)hc->hc_peer);
-    if (hc->hc_access == NULL)
-      return -1;
+    if (hc->hc_access)
+      res = access_verify2(hc->hc_access, mask);
   }
 
-  return access_verify2(hc->hc_access, mask);
+  return res;
 }
 
 /**
@@ -571,18 +576,20 @@ http_access_verify_channel(http_connection_t *hc, int mask,
   if (ticket)
     http_access_verify_ticket(hc);
 
-  if (hc->hc_access == NULL) {
+  if (hc->hc_access)
+    res = access_verify2(hc->hc_access, mask);
+
+  if (res) {
+    access_destroy(hc->hc_access);
     hc->hc_access = access_get(hc->hc_username, hc->hc_password,
                                (struct sockaddr *)hc->hc_peer);
-    if (hc->hc_access == NULL)
-      return -1;
+    if (hc->hc_access)
+      res = access_verify2(hc->hc_access, mask);
   }
 
-  if (access_verify2(hc->hc_access, mask))
-    return -1;
+  if (!channel_access(ch, hc->hc_access, 0))
+    res = -1;
 
-  if (channel_access(ch, hc->hc_access, 0))
-    res = 0;
   return res;
 }