I have Apache running as a reverse proxy for an internal server. Users hitting the proxy are required to use client certificates. On the internal server, there is a web application that can use an HTTP header for authenticating users. I would like to have the proxy provide that header based on the client certificate.
The header value is the user's id. Ideally I would have a text file mapping user id to certificate. Near as I can tell, I need RewriteMap
but for headers.
# Somehow lookup USERID given SSL_CLIENT_S_DN
RequestHeader set X-User-ID %{USERID}
I'd like to avoid a whole bunch of SetEnvIf
s requiring server restarts to change, e.g.:
SetEnvIf SSL_CLIENT_S_DN [User 1's SSL_CLIENT_S_DN] USERID=12
SetEnvIf SSL_CLIENT_S_DN [User 2's SSL_CLIENT_S_DN] USERID=34
SetEnvIf SSL_CLIENT_S_DN [User 3's SSL_CLIENT_S_DN] USERID=56
...
Is there a good way I can avoid the users from needing to essentially authenticate twice?