I have an application that runs behind Apache 2.4.27 that authenticates users with mod_auth_cas. This module stores attributes about the authenticated user in headers. I'm having issues with one header that's being stripped because it has an underscore in it (X-CAS-email_primary
). After doing some searching, I added the code snippet below to the VirtualHost configuration.
SetEnvIfNoCase X-CAS-email_primary ^(.*)$ fix_header=$1
RequestHeader set X-CAS-email-primary %{fix_header}e env=fix_header
In case it wasn't obvious, I'm trying to change X-CAS-email_primary
to X-CAS-email-primary
. This code is partially working. The new header does appear but it has no value.
["HTTP_X_CAS_EMAIL_PRIMARY"]=> string(0) ""
I've confirmed that X-CAS-email_primary
is set, so I'm not quite sure what's going on. Any suggestions?
Thanks!
Best Answer
The value of a
RequestHeader set
supports expressions, and expressions include thereq
(orhttp
) function, which gives you the value of request headers. So this one directive should do what you want:You have to dig deep into the documentation to find this kind of thing, but it's there.
Not sure why your configuration didn't work, but I guess the SetEnvIfNoCase is evaluated after the RequestHeader. The docs don't make it easy to figure that out.