Description
Our Apache server hosts wsgi application (mod_wsgi) and uses mod_gssapi for authentication. moreover, the application uses delegation to pass the authenticated user to a backend service as follow:
client request --> HTTP/apache_1@OUR_REALM --> HTTP/backend_server@OUR_REALM
This works perfect, but now we need to add load balancer in front of the Apache server:
--> HTTP/apache_1@OUR_REALM --> HTTP/backend_server@OUR_REALM
client request --> HTTP/balancer@OUR_REALM |
--> HTTP/apache_2@OUR_REALM --> HTTP/backend_server@OUR_REALM
blancer server just forwards requests - no security configuration whatsoever and works as expected.
To make this work, we did the following:
- created new principal
HTTP/balancer@OUR_REALM
with constrained delegation to the backend service. - Added the new principal to each of the existing keytabs of apache_1 and apache_2 servers:
On server apache_1:
KVNO Principal
---- -------------------
1 HTTP/apache_1@OUR_REALM
1 HTTP/balancer@OUR_REALM
**On server apache_2:**
KVNO Principal
---- -------------------
1 HTTP/apache_2@OUR_REALM
1 HTTP/balancer@OUR_REALM
While testing our configuration we issued http requests to our balancer and got the following error in Apache's error log:
GSSError:(('Unspecified GSS failure. Minor code may provide more information', 851968), ('Matching credential not found (filename: /var/run/httpd/krbcache/user_principal@OUR_REALM)', -1765328243))
Investigating the user's ccache using klist -c /var/run/httpd/krbcache/user_principal@OUR_REALM
showed (start and expiration columns are omitted):
# example from server apache_1
Ticket cache: FILE:/var/run/httpd/krbcache/user_principal@OUR_REALM
Default principal: user_principal@OUR_REALM
Service principal
HTTP/balancer@OUR_REALM
krbtgt/OUR_REALM@OUR_REALM
for client HTTP/apache_1@OUR_REALM
--> Its seems that even though we executed requests to the balancer, the delegation ticket was still issued to HTTP/apache_1@OUR_REALM (tgt for client HTTP/apache_1@OUR_REALM
). Same behavior was occurred on requests that were forwarded to apache_2 server.
We tried to change the order of the principals inside the keytabs so HTTP/balancer@OUR_REALM
will be the first principal:
on apache_1:
KVNO Principal
---- -------------------
1 HTTP/balancer@OUR_REALM
1 HTTP/apache_1@OUR_REALM
on apache_2:
KVNO Principal
---- -------------------
1 HTTP/balancer@OUR_REALM
1 HTTP/apache_2@OUR_REALM
And now we got the opposite: requests issued to the balancer server were succeeded while requests to the concrete servers apache_1 or apache_2 were failed. Obviously, this is better than before since we got a working balancer, but still - its preferable to make the concrete servers answering as well (balancer may fail, monitoring and more).
Is there a way making both principals work for each of our balancer servers?
Thanks.