Forum Moderators: phranque

Message Too Old, No Replies

String manipulation

         

sniper57

1:40 pm on Sep 30, 2015 (gmt 0)

10+ Year Member



Hi,

I have configured an Apache 2.4 web server for Kerberos authentication. I need to pass the user in an HTTP header to the back-end server. This can be achieved by:-


# Set header to blank
RequestHeader set KERBEROS_USER ""
# Set header
RequestHeader set KERBEROS_USER "%{REMOTE_USER}s"


However the user is passed in the format:-
"userA@domain.com"

I would like to pass just "userA".

Please can anyone advise if this is possible and if so how?

Many thanks
Simon

lucy24

8:27 pm on Sep 30, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



:: sparring for time ::

Is "domain.com" always the same (as with an internal network) or can it have different values?

:: wandering off to find a place where ^([^@]+)@ can be plugged in ::

Incidentally, does the header have to be cleared before it's reset? I thought RequestHeader set (as opposed to RequestHeader append) already overwrites whatever was there before. At least that's what the docs claim, though admittedly real life does not always do what the docs say it does :(

:: returning from Apache docs ::

Are we dealing with two different headers? If you're changing the existing header, the verb you want is "edit". (Though it would be awfully nice if the docs laid out the exact syntax wouldn't it.) Are you looking at taking part of the value of one header, and plugging it into a different header?

sniper57

8:55 am on Oct 1, 2015 (gmt 0)

10+ Year Member



Hi lucy24

Yes domain is always the same .... and admittedly this problem can easily be solved in the back end application ... but my preference would be to provide the header in the format that the developers want.

I think you are right in that "set" does overwrite anything existing but I just wanted to be sure that old headers weren't being sent in case of other issues.

No just one header.....

lucy24

6:54 pm on Oct 1, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



just one header

But one header using the value of a different field, right? If it were all the same header, then you could use the "edit" command to change that value. What you need is something that lets you take the REMOTE_USER string, and process that as
^([^@]+)@
>>
$1
or, as it were, inputstring.split("@")
(In no known language, I just made that up)

:: vaguely looking around for whitespace or someone like him ::

Let's keep poking around. There's got to be a way to do this.