Foreman and mod auth kerb » History » Revision 2
Revision 1 (Jan Pazdziora, 10/17/2013 05:04 AM) → Revision 2/17 (Jan Pazdziora, 10/17/2013 05:07 AM)
h1. Foreman and mod auth kerb Setting up SPNEGO/GSSAPI/Negotiate authentication in Foreman 1.3. h2. 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: <pre> # ipa-client-install </pre> On the IPA server, we crete the service: <pre> # ipa service-add HTTP/<the-foreman-hostname> </pre> On the Foreman machine, we get the keytab for the service: <pre> # ipa-getkeytab -s ipa.example.com -k /etc/http.keytab -p HTTP/$( hostname ) # chown apache /etc/http.keytab # chmod 600 /etc/http.keytab </pre> On the Foreman machine, we install mod_auth_kerb: <pre> # yum install -y mod_auth_kerb </pre> On the Foreman machine, we configure it to be used by Apache: <pre> # 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> </pre> On the Foreman machine, we tell Foreman that it is OK to trust the authentication dome by Apache: <pre> # to /etc/foreman/settings.yaml add :authorize_login_delegation: true :login_delegation_logout_url: / </pre> On Foreman machine, restart Apache: <pre> # service httpd restart </pre> 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. h2. The problems with the above approach h3. 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 h3. 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. h3. Users have to be defined in Foreman's database h2. 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 <pre> 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] </pre> 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 <pre> <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> </pre> 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 <pre> :login_delegation_logout_url: / </pre> is not longer needed/used.