1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-12-04 14:46:30 -05:00

Feature: Support per-<role> HTTP headers

This commit is contained in:
Philipp Schafft 2018-11-04 10:22:27 +00:00
parent aeeee071d4
commit 2c72d9a37c
5 changed files with 19 additions and 10 deletions

View File

@ -215,6 +215,7 @@ void auth_release (auth_t *authenticator) {
if (authenticator->mount) if (authenticator->mount)
free(authenticator->mount); free(authenticator->mount);
acl_release(authenticator->acl); acl_release(authenticator->acl);
config_clear_http_header(authenticator->http_headers);
free(authenticator); free(authenticator);
} }
@ -841,6 +842,8 @@ auth_t *auth_get_authenticator(xmlNodePtr node)
} }
*next_option = opt; *next_option = opt;
next_option = &opt->next; next_option = &opt->next;
} else if (xmlStrcmp (child->name, XMLSTR("http-headers")) == 0) {
config_parse_http_headers(child->xmlChildrenNode, &(auth->http_headers));
} else if (xmlStrcmp (child->name, XMLSTR("acl")) == 0) { } else if (xmlStrcmp (child->name, XMLSTR("acl")) == 0) {
if (!auth->acl) { if (!auth->acl) {
auth->acl = acl_new_from_xml_node(child); auth->acl = acl_new_from_xml_node(child);

View File

@ -26,6 +26,7 @@
#include "common/httpp/httpp.h" #include "common/httpp/httpp.h"
#include "icecasttypes.h" #include "icecasttypes.h"
#include "cfgfile.h"
/* implemented */ /* implemented */
#define AUTH_TYPE_ANONYMOUS "anonymous" #define AUTH_TYPE_ANONYMOUS "anonymous"
@ -152,6 +153,9 @@ struct auth_tag
acl_t *acl; acl_t *acl;
/* role name for later matching, may be NULL if no role name was given in config */ /* role name for later matching, may be NULL if no role name was given in config */
char *role; char *role;
/* HTTP headers to send to clients using this role */
ice_config_http_header_t *http_headers;
}; };
/* prototypes for auths that do not need own header file */ /* prototypes for auths that do not need own header file */

View File

@ -141,10 +141,6 @@ static void _parse_authentication(xmlDocPtr doc,
ice_config_t *c, ice_config_t *c,
char **source_password); char **source_password);
static void _parse_http_headers(xmlDocPtr doc,
xmlNodePtr node,
ice_config_http_header_t **http_headers);
static void _parse_relay(xmlDocPtr doc, xmlNodePtr node, ice_config_t *c, const char *mount); static void _parse_relay(xmlDocPtr doc, xmlNodePtr node, ice_config_t *c, const char *mount);
static void _parse_mount(xmlDocPtr doc, xmlNodePtr parentnode, ice_config_t *c); static void _parse_mount(xmlDocPtr doc, xmlNodePtr parentnode, ice_config_t *c);
@ -512,7 +508,7 @@ static void __append_old_style_url_event(event_registration_t **list,
xmlFreeNode(exec); xmlFreeNode(exec);
} }
static void config_clear_http_header(ice_config_http_header_t *header) void config_clear_http_header(ice_config_http_header_t *header)
{ {
ice_config_http_header_t *old; ice_config_http_header_t *old;
@ -1062,7 +1058,7 @@ static void _parse_root(xmlDocPtr doc,
} else if (xmlStrcmp(node->name, XMLSTR("limits")) == 0) { } else if (xmlStrcmp(node->name, XMLSTR("limits")) == 0) {
_parse_limits(doc, node->xmlChildrenNode, configuration); _parse_limits(doc, node->xmlChildrenNode, configuration);
} else if (xmlStrcmp(node->name, XMLSTR("http-headers")) == 0) { } else if (xmlStrcmp(node->name, XMLSTR("http-headers")) == 0) {
_parse_http_headers(doc, node->xmlChildrenNode, &(configuration->http_headers)); config_parse_http_headers(node->xmlChildrenNode, &(configuration->http_headers));
} else if (xmlStrcmp(node->name, XMLSTR("relay")) == 0) { } else if (xmlStrcmp(node->name, XMLSTR("relay")) == 0) {
_parse_relay(doc, node->xmlChildrenNode, configuration, NULL); _parse_relay(doc, node->xmlChildrenNode, configuration, NULL);
} else if (xmlStrcmp(node->name, XMLSTR("mount")) == 0) { } else if (xmlStrcmp(node->name, XMLSTR("mount")) == 0) {
@ -1556,7 +1552,7 @@ static void _parse_mount(xmlDocPtr doc,
mount->subtype = (char *)xmlNodeListGetString(doc, mount->subtype = (char *)xmlNodeListGetString(doc,
node->xmlChildrenNode, 1); node->xmlChildrenNode, 1);
} else if (xmlStrcmp(node->name, XMLSTR("http-headers")) == 0) { } else if (xmlStrcmp(node->name, XMLSTR("http-headers")) == 0) {
_parse_http_headers(doc, node->xmlChildrenNode, config_parse_http_headers(node->xmlChildrenNode,
&(mount->http_headers)); &(mount->http_headers));
} else if (xmlStrcmp(node->name, XMLSTR("event-bindings")) == 0 || } else if (xmlStrcmp(node->name, XMLSTR("event-bindings")) == 0 ||
xmlStrcmp(node->name, XMLSTR("kartoffelsalat")) == 0) { xmlStrcmp(node->name, XMLSTR("kartoffelsalat")) == 0) {
@ -1644,9 +1640,8 @@ static void _parse_mount(xmlDocPtr doc,
} }
} }
static void _parse_http_headers(xmlDocPtr doc, void config_parse_http_headers(xmlNodePtr node,
xmlNodePtr node, ice_config_http_header_t **http_headers)
ice_config_http_header_t **http_headers)
{ {
ice_config_http_header_t *header; ice_config_http_header_t *header;
ice_config_http_header_t *next; ice_config_http_header_t *next;

View File

@ -301,6 +301,10 @@ listener_t *config_copy_listener_one(const listener_t *listener);
config_options_t *config_parse_options(xmlNodePtr node); config_options_t *config_parse_options(xmlNodePtr node);
void config_clear_options(config_options_t *options); void config_clear_options(config_options_t *options);
void config_parse_http_headers(xmlNodePtr node,
ice_config_http_header_t **http_headers);
void config_clear_http_header(ice_config_http_header_t *header);
int config_rehash(void); int config_rehash(void);
ice_config_locks *config_locks(void); ice_config_locks *config_locks(void);

View File

@ -50,6 +50,7 @@
#include "client.h" #include "client.h"
#include "source.h" #include "source.h"
#include "admin.h" #include "admin.h"
#include "auth.h"
#define CATMODULE "util" #define CATMODULE "util"
@ -674,6 +675,8 @@ static inline char * _build_headers(int status, const char *allow, ice_config_t
_build_headers_loop(&ret, &len, config->http_headers, status, allow, client); _build_headers_loop(&ret, &len, config->http_headers, status, allow, client);
if (mountproxy && mountproxy->http_headers) if (mountproxy && mountproxy->http_headers)
_build_headers_loop(&ret, &len, mountproxy->http_headers, status, allow, client); _build_headers_loop(&ret, &len, mountproxy->http_headers, status, allow, client);
if (client && client->auth && client->auth->http_headers)
_build_headers_loop(&ret, &len, client->auth->http_headers, status, allow, client);
return ret; return ret;
} }