Project

General

Profile

Actions

Foreman and mod auth kerb » History » Revision 2

« Previous | Revision 2/17 (diff) | Next »
Jan Pazdziora, 10/17/2013 05:07 AM


Foreman and mod auth kerb

Setting up SPNEGO/GSSAPI/Negotiate authentication in Foreman 1.3.

Foreman 1.3

Stock Foreman 1.3 can be configured to use SPNEGO/GSSAPI/Negotiate authentication.

We need mod_auth_kerb installed on the Foreman machine.

We assume the Foreman machine is IPA-enrolled:

 # ipa-client-install

On the IPA server, we crete the service:

 # ipa service-add HTTP/<the-foreman-hostname>

On the Foreman machine, we get the keytab for the service:

 # ipa-getkeytab -s ipa.example.com -k /etc/http.keytab -p HTTP/$( hostname )
 # chown apache /etc/http.keytab
 # chmod 600 /etc/http.keytab

On the Foreman machine, we install mod_auth_kerb:

 # yum install -y mod_auth_kerb

On the Foreman machine, we configure it to be used by Apache:

 # to /etc/httpd/conf.d/auth_kerb.conf add
 <Location />
 AuthType Kerberos
 AuthName "Kerberos Login" 
 KrbMethodNegotiate On
 KrbMethodK5Passwd Off
 KrbAuthRealms EXAMPLE.COM
 Krb5KeyTab /etc/http.keytab
 KrbLocalUserMapping On
 require valid-user
 </Location>

On the Foreman machine, we tell Foreman that it is OK to trust the authentication dome by Apache:

 # to /etc/foreman/settings.yaml add
 :authorize_login_delegation: true
 :login_delegation_logout_url: /

On Foreman machine, restart Apache:

 # service httpd restart

Now in your browser, if you kinit to obtain a ticket, accessing Foreman's WebUI should not ask for login/password and should display the authenticated dashboard directly.

The problems with the above approach

It authenticates too much

Some of the locations in Foreman might need the authentication disabled and the proposed <Location /> will cover them all. They need to be identified and exceptions added to Apache configuration

Two HTTP requests for each click

This configuration will force the negotiation to happen for every access to the WebUI -- first with 401 result, then second request with negotiation result with result 200.

Users have to be defined in Foreman's database

Possible solutions

The solution to the first two problems will likely be in only enabling the authentication for some logon location. That will however require some code changes. The /users/login cannot be used because in Foreman 1.3, there is

 app/controllers/users_controller.rb:  skip_before_filter :require_login, :authorize, :session_expiry, :update_activity_time, :set_taxonomy, :set_gettext_locale_db, :only => [:login, :logout]

so even if we'd use <Location /users/login>, the require_login (== authenticate) would not be run and REMOTE_USER would not be consumed.

Pull request https://github.com/theforeman/foreman/pull/958 (https://github.com/adelton/foreman/commit/77bd5cde7bf530ca13127816b344fe0ce8de2a1c) was opened against Foreman. With these patches and the configuration of the mod_auth_kerb changed to

 <Location /users/extlogin>
 AuthType Kerberos
 AuthName "Kerberos Login" 
 KrbMethodNegotiate On
 KrbMethodK5Passwd Off
 KrbAuthRealms EXAMPLE.COM
 Krb5KeyTab /etc/http.keytab
 KrbLocalUserMapping On
 require valid-user
 ErrorDocument 401 '<html><meta http-equiv="refresh" content="0; URL=/users/login"><body>Kerberos authentication did not pass.</body></html>'
 </Location>

the user's browser is redirected to /users/extlogin where the SPNEGO authentication is tried, and if it fails, normal /users/login method is used. After the SPNEGO authentication, normal Foreman session is created and used and since the rest of the Foreman WebUI is not covered by any AuthType, the negotiation does not happen again.

The patches support /users/extlogin not being configured properly, session expiration, and session logout.

The setting

 :login_delegation_logout_url: /

is not longer needed/used.

Updated by Jan Pazdziora about 11 years ago · 17 revisions