Skip to content

Commit ca05d8c

Browse files
authored
Merge pull request #1816 from stdweird/metaconfig_httpd_requestheader
ncm-metaconfig: httpd: support requestheader in vhost
2 parents b3ff7c1 + 90aec96 commit ca05d8c

6 files changed

Lines changed: 33 additions & 14 deletions

File tree

ncm-metaconfig/src/main/metaconfig/httpd/2.4/tests/profiles/keystone.pan

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ prefix "contents";
2727
"type", "error",
2828
"expr", "%{cu}t %M",
2929
"name", "", # must be empty
30-
)),
30+
)),
3131
"error", "/var/log/httpd/keystone.log",
3232
"custom", list(dict(
3333
"location", "/var/log/httpd/keystone_access.log",
3434
"name", "combined",
35-
)),
36-
),
35+
)),
36+
),
3737
"wsgi", dict(
3838
"passauthorization", "on",
3939
"processgroup", "keystone-public",
@@ -46,19 +46,19 @@ prefix "contents";
4646
"user", "keystone",
4747
"group", "keystone",
4848
"display-name", "%{GROUP}",
49-
),
5049
),
5150
),
51+
),
5252
"aliases", list(dict(
5353
"url", "/",
5454
"destination", "/usr/bin/keystone-wsgi-public",
5555
"type", "wsgiscript",
56-
)),
56+
)),
5757
"directories", list(dict(
5858
"name", "/usr/bin",
5959
"authz", list(dict("all", "granted")),
60-
)),
61-
);
60+
)),
61+
);
6262
SELF['keystone'] = clone(data);
6363

6464
data['port'] = 35357;
@@ -79,8 +79,8 @@ prefix "contents";
7979
"passauthorization", "on",
8080
"processgroup", "keystone-public",
8181
"applicationgroup", "%{GLOBAL}",
82-
),
83-
);
82+
),
83+
);
8484
append(clone(data));
8585

8686
data['name'] = "/identity_admin";
@@ -96,4 +96,10 @@ prefix "contents";
9696
'action', 'add',
9797
'name', 'Strict-Transport-Security',
9898
'value', 'max-age=15768000'
99-
));
99+
));
100+
101+
"vhosts/keystone/requestheader" = append(dict(
102+
'action', 'set',
103+
'name', 'X-MAGIC-SOMETHING',
104+
'value', '%{MAGIC}xyz'
105+
));

ncm-metaconfig/src/main/metaconfig/httpd/2.4/tests/regexps/keystone/base

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Base test for keystone wsgi config
3333
^ errorlogformat "%\{cu\}t %M"
3434
^ customlog /var/log/httpd/keystone_access.log combined
3535
^ header add Strict-Transport-Security "max-age=15768000"
36+
^ requestheader set X-MAGIC-SOMETHING "%\{MAGIC\}xyz"
3637
^ <directory /usr/bin>
3738
^ require all granted
3839
^ </directory>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[%- FOREACH header IN desc %]
2-
header [% IF header.always %]always [% END %][% header.action %] [% header.name %] [% header.quotes %][% header.value %][% header.quotes %]
2+
[% headermode %]header [% IF header.always %]always [% END %][% header.action %] [% header.name %] [% header.quotes %][% header.value %][% header.quotes %]
33
[% END -%]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[% INCLUDE "metaconfig/httpd/config/header.tt" headermode='request' %]

ncm-metaconfig/src/main/metaconfig/httpd/config/vhost.tt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ limitrequestbody [% vhost.limitrequestbody %]
1515
protocols [% vhost.protocols.join(' ') %]
1616
[% END -%]
1717
[%- to_process = ['ssl', 'nss', 'env', 'aliases', 'rewrite', 'redirect',
18-
'perl', 'wsgi', 'log', 'rails', 'browsermatch', 'passenger', 'oidc', 'header'] -%]
18+
'perl', 'wsgi', 'log', 'rails', 'browsermatch', 'passenger',
19+
'oidc', 'header', 'requestheader'] -%]
1920
[%- FOREACH p IN to_process -%]
2021
[%- IF vhost.exists(p) -%]
2122
[% INCLUDE "metaconfig/httpd/config/${p}.tt" desc=vhost.$p %]

ncm-metaconfig/src/main/metaconfig/httpd/pan/schema.pan

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,14 +614,23 @@ type httpd_directory = {
614614

615615
type httpd_vhost_ip = string with is_ip(SELF) || SELF == '*';
616616

617-
type httpd_header = {
617+
type httpd_header_base = {
618618
"name" : string
619-
"action" : choice('add', 'append', 'echo', 'edit', 'edit*', 'merge', 'set', 'setifempty', 'unset', 'note')
620619
"value" : string
621620
"quotes" : string = '"'
622621
"always" ? boolean
623622
};
624623

624+
type httpd_header = {
625+
include httpd_header_base
626+
"action" : choice('add', 'append', 'echo', 'edit', 'edit*', 'merge', 'set', 'setifempty', 'unset', 'note')
627+
};
628+
629+
type httpd_requestheader = {
630+
include httpd_header_base
631+
"action" : choice('add', 'append', 'edit', 'edit*', 'merge', 'set', 'setifempty', 'unset')
632+
};
633+
625634
type httpd_serveralias = string with match(SELF, '^[\w.*]+$'); # serveralias supports wildcards
626635

627636
type httpd_vhost = {
@@ -648,6 +657,7 @@ type httpd_vhost = {
648657
"browsermatch" ? httpd_browsermatch[]
649658
"passenger" ? httpd_passenger_vhost
650659
"header" ? httpd_header[]
660+
"requestheader" ? httpd_requestheader[]
651661
"protocols" ? httpd_protocols[]
652662
};
653663

0 commit comments

Comments
 (0)