Foreman and mod auth kerb » History » Revision 7
« Previous |
Revision 7/17
(diff)
| Next »
Jan Pazdziora, 10/18/2013 04:53 AM
- Table of contents
- Foreman and mod_auth_kerb
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¶
Separate logon location /users/extlogin¶
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.
Auto-creation of externally authentication users¶
Latest updates to https://github.com/theforeman/foreman/pull/958, as well as https://github.com/ares/foreman/pull/1 now contain code which allows previously unseen users to be automatically created. That get enabled in /etc/foreman/settings.yaml via
:authorize_login_delegation: true :authorize_login_delegation_auth_source_user_autocreate: External
where the authorize_login_delegation_auth_source_user_autocreate is the name of auth_source to be used as target for these new users.
With the current code, only the login is populated, so upon login, the user is redirected to the Edit User page where at least the email address needs to be filled.
Namespace separation¶
If clear namespace separation of internally and externally authenticated users is desired, the KrbLocalUserMapping should be off:
# in /etc/httpd/conf.d/auth_kerb.conf use <Location /users/extlogin> AuthType Kerberos ... KrbLocalUserMapping Off </Location>
Then the @REALM would be part of the username and it would be clear that bob is INTERNAL-authenticated and bob@EXAMPLE.COM is different user, EXTERNAL-authenticated. The admin then can manually create another admin@EXAMPLE.COM user (with administrator privileges) and even the admin can use Kerberos.
Updated by Jan Pazdziora about 11 years ago · 17 revisions