]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Don't apply body restrictions to xlat calls
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 23 Jan 2024 00:18:49 +0000 (18:18 -0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 23 Jan 2024 00:18:56 +0000 (18:18 -0600)
src/modules/rlm_rest/rlm_rest.c
src/tests/modules/rest/module.conf
src/tests/modules/rest/rest_xlat.unlang

index 1b2640b19b79a651358cfdf642b44f1e9be337c3..8d7aeccddd4ece57f8c9f40dae37632f677372e4 100644 (file)
@@ -1107,7 +1107,7 @@ static int parse_sub_section(rlm_rest_t *inst, CONF_SECTION *parent, conf_parser
         *  figure out what content-type to use. So if they've used the canonical form we
         *  need to convert it back into a proper HTTP content_type value.
         */
-       if ((request_cs = cf_section_find(cs, "request", NULL)) && cf_pair_find(request_cs, "data")) {
+       if ((strcmp(name, "xlat") == 0) || ((request_cs = cf_section_find(cs, "request", NULL)) && cf_pair_find(request_cs, "data"))) {
                http_body_type_t body;
 
                config->request.body = REST_HTTP_BODY_CUSTOM;
index c3a49382153ca312201efa14d95bef2998f013bb..0813cf9d010cc429774b151e7e1234cf8c118577 100644 (file)
@@ -25,6 +25,7 @@ rest {
                request {
                        header = 'X-Custom-Header: test'
                        header = "X-Custom-Header: %{User-Name}"
+                       body = 'json'
                }
                tls = ${..tls}
        }
index ffe7891fc2cf9728eddfeb57e3aef38df9f0f3c9..360583c1219f61da13217c47ca79ae3b9d2c27e7 100644 (file)
@@ -179,6 +179,11 @@ group {
        if (!(&headers =~ /"x-freeradius-server":"default"/)) {
                test_fail
        }
+
+       # Some weird escaping issue prevents matching application/json
+       if (!(&headers =~ /"content-type":"application.+json"/)) {
+               test_fail
+       }
 }
 
 # Zero length tainted value - check escaping doesn't break on zero length string