diff --git a/src/auth.c b/src/auth.c index 76486700a9706ea421ea727b28fed750ac07b5b8..7ddbd42b3f4e12ceeb8c30144369dd6512adfa91 100644 --- a/src/auth.c +++ b/src/auth.c @@ -215,6 +215,7 @@ void auth_release (auth_t *authenticator) { if (authenticator->mount) free(authenticator->mount); acl_release(authenticator->acl); + config_clear_http_header(authenticator->http_headers); free(authenticator); } @@ -841,6 +842,8 @@ auth_t *auth_get_authenticator(xmlNodePtr node) } *next_option = opt; 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) { if (!auth->acl) { auth->acl = acl_new_from_xml_node(child); diff --git a/src/auth.h b/src/auth.h index a5bd1c1e25488c0fc86897dde5c83acb29578b70..c054a13a5237ce95aa0cfe3fc2f9961b7a53d14e 100644 --- a/src/auth.h +++ b/src/auth.h @@ -26,6 +26,7 @@ #include "common/httpp/httpp.h" #include "icecasttypes.h" +#include "cfgfile.h" /* implemented */ #define AUTH_TYPE_ANONYMOUS "anonymous" @@ -152,6 +153,9 @@ struct auth_tag acl_t *acl; /* role name for later matching, may be NULL if no role name was given in config */ 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 */ diff --git a/src/cfgfile.c b/src/cfgfile.c index 539568a77da893afe5bd268cb1e95a6f8b29e3c1..55534d79d241b9f51c766fc5f27114686cd24bb2 100644 --- a/src/cfgfile.c +++ b/src/cfgfile.c @@ -141,10 +141,6 @@ static void _parse_authentication(xmlDocPtr doc, ice_config_t *c, 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_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); } -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; @@ -1062,7 +1058,7 @@ static void _parse_root(xmlDocPtr doc, } else if (xmlStrcmp(node->name, XMLSTR("limits")) == 0) { _parse_limits(doc, node->xmlChildrenNode, configuration); } 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) { _parse_relay(doc, node->xmlChildrenNode, configuration, NULL); } else if (xmlStrcmp(node->name, XMLSTR("mount")) == 0) { @@ -1556,7 +1552,7 @@ static void _parse_mount(xmlDocPtr doc, mount->subtype = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); } else if (xmlStrcmp(node->name, XMLSTR("http-headers")) == 0) { - _parse_http_headers(doc, node->xmlChildrenNode, + config_parse_http_headers(node->xmlChildrenNode, &(mount->http_headers)); } else if (xmlStrcmp(node->name, XMLSTR("event-bindings")) == 0 || xmlStrcmp(node->name, XMLSTR("kartoffelsalat")) == 0) { @@ -1644,9 +1640,8 @@ static void _parse_mount(xmlDocPtr doc, } } -static void _parse_http_headers(xmlDocPtr doc, - xmlNodePtr node, - ice_config_http_header_t **http_headers) +void config_parse_http_headers(xmlNodePtr node, + ice_config_http_header_t **http_headers) { ice_config_http_header_t *header; ice_config_http_header_t *next; diff --git a/src/cfgfile.h b/src/cfgfile.h index 83f013145190e06faf80129ccb49b5216da289d3..f2bcb1045d19f8884897e59afdc8ad5eb2c9678c 100644 --- a/src/cfgfile.h +++ b/src/cfgfile.h @@ -301,6 +301,10 @@ listener_t *config_copy_listener_one(const listener_t *listener); config_options_t *config_parse_options(xmlNodePtr node); 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); ice_config_locks *config_locks(void); diff --git a/src/util.c b/src/util.c index f89afb324c2989c6bbeaea7d367af2434fa66701..082179d57986d75db648af6dff4b53a242494a96 100644 --- a/src/util.c +++ b/src/util.c @@ -50,6 +50,7 @@ #include "client.h" #include "source.h" #include "admin.h" +#include "auth.h" #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); if (mountproxy && mountproxy->http_headers) _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; }