]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
http server: allow to configure the realm for HTTP authorization, fixes #3710
authorJaroslav Kysela <perex@perex.cz>
Wed, 24 May 2017 06:25:59 +0000 (08:25 +0200)
committerJaroslav Kysela <perex@perex.cz>
Wed, 24 May 2017 06:25:59 +0000 (08:25 +0200)
src/config.c
src/http.c

index c7c564fa43bda0d0ac305132189e5dbb9d47b12b..09b509ed72ad32cbf84fa438a43ca6509c54c5d6 100644 (file)
@@ -1751,6 +1751,8 @@ config_boot ( const char *path, gid_t gid, uid_t uid )
   htsmsg_destroy(config2);
   if (config.server_name == NULL || config.server_name[0] == '\0')
     config.server_name = strdup("Tvheadend");
+  if (config.realm == NULL || config.realm[0] == '\0')
+    config.realm = strdup("tvheadend");
   if (config.http_server_name == NULL || config.http_server_name[0] == '\0')
     config.http_server_name = strdup("HTS/tvheadend");
   if (!config_scanfile_ok)
@@ -1775,6 +1777,7 @@ config_init ( int backup )
     config.version = ARRAY_SIZE(config_migrate_table);
     tvh_str_set(&config.full_version, tvheadend_version);
     tvh_str_set(&config.server_name, "Tvheadend");
+    tvh_str_set(&config.realm, "tvheadend");
     tvh_str_set(&config.http_server_name, "HTS/tvheadend");
     idnode_changed(&config.idnode);
   
@@ -2091,6 +2094,15 @@ const idclass_t config_class = {
       .opts   = PO_HIDDEN | PO_EXPERT,
       .group  = 1
     },
+    {
+      .type   = PT_STR,
+      .id     = "http_realm_name",
+      .name   = N_("HTTP realm name"),
+      .desc   = N_("The realm name for the HTTP authorization."),
+      .off    = offsetof(config_t, realm),
+      .opts   = PO_HIDDEN | PO_EXPERT,
+      .group  = 1
+    },
     {
       .type   = PT_BOOL,
       .id     = "hbbtv",
index f2665a7068cf6fe18e61ec61ce6d795d8cf9abea..0365f3cedd415093f9f7b5151c361df7efb4ea09 100644 (file)
@@ -803,7 +803,8 @@ http_verify_prepare(http_connection_t *hc, struct http_verify_structure *v)
       realm = http_get_header_value(hc->hc_authhdr, "realm");
       nonce_count = http_get_header_value(hc->hc_authhdr, "nc");
       cnonce = http_get_header_value(hc->hc_authhdr, "cnonce");
-      if (realm == NULL || nonce_count == NULL || cnonce == NULL) {
+      if (realm == NULL || strcmp(realm, config.realm) ||
+          nonce_count == NULL || cnonce == NULL) {
         goto end;
       } else {
         snprintf(all, sizeof(all), "%s:%s:%s:%s:%s",