From: Jaroslav Kysela Date: Wed, 24 May 2017 06:25:59 +0000 (+0200) Subject: http server: allow to configure the realm for HTTP authorization, fixes #3710 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e0a31ace29926f89b552ffaf5fd02b98780beff1;p=thirdparty%2Ftvheadend.git http server: allow to configure the realm for HTTP authorization, fixes #3710 --- diff --git a/src/config.c b/src/config.c index c7c564fa4..09b509ed7 100644 --- a/src/config.c +++ b/src/config.c @@ -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", diff --git a/src/http.c b/src/http.c index f2665a706..0365f3ced 100644 --- a/src/http.c +++ b/src/http.c @@ -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",