Project

General

Profile

Foreman and mod auth kerb » History » Version 3

Jan Pazdziora, 10/17/2013 05:07 AM

1 3 Jan Pazdziora
{{>toc}}
2
3 1 Jan Pazdziora
h1. Foreman and mod auth kerb
4
5
Setting up SPNEGO/GSSAPI/Negotiate authentication in Foreman 1.3.
6
7 2 Jan Pazdziora
h2. Foreman 1.3
8
9 1 Jan Pazdziora
Stock Foreman 1.3 can be configured to use SPNEGO/GSSAPI/Negotiate authentication.
10
11
We need mod_auth_kerb installed on the Foreman machine.
12
13
We assume the Foreman machine is IPA-enrolled:
14
15
<pre>
16
 # ipa-client-install
17
</pre>
18
19
On the IPA server, we crete the service:
20
21
<pre>
22
 # ipa service-add HTTP/<the-foreman-hostname>
23
</pre>
24
25
On the Foreman machine, we get the keytab for the service:
26
27
<pre>
28
 # ipa-getkeytab -s ipa.example.com -k /etc/http.keytab -p HTTP/$( hostname )
29
 # chown apache /etc/http.keytab
30
 # chmod 600 /etc/http.keytab
31
</pre>
32
33
On the Foreman machine, we install mod_auth_kerb:
34
35
<pre>
36
 # yum install -y mod_auth_kerb
37
</pre>
38
39
On the Foreman machine, we configure it to be used by Apache:
40
41
<pre>
42
 # to /etc/httpd/conf.d/auth_kerb.conf add
43
 <Location />
44
 AuthType Kerberos
45
 AuthName "Kerberos Login"
46
 KrbMethodNegotiate On
47
 KrbMethodK5Passwd Off
48
 KrbAuthRealms EXAMPLE.COM
49
 Krb5KeyTab /etc/http.keytab
50
 KrbLocalUserMapping On
51
 require valid-user
52
 </Location>
53
</pre>
54
55
On the Foreman machine, we tell Foreman that it is OK to trust the authentication dome by Apache:
56
57
<pre>
58
 # to /etc/foreman/settings.yaml add
59
 :authorize_login_delegation: true
60
 :login_delegation_logout_url: /
61
</pre>
62
63
On Foreman machine, restart Apache:
64
65
<pre>
66
 # service httpd restart
67
</pre>
68
69
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. 
70 2 Jan Pazdziora
71
h2. The problems with the above approach
72
73
h3. It authenticates too much
74
75
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
76
77
h3. Two HTTP requests for each click
78
79
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.
80
81
h3. Users have to be defined in Foreman's database 
82
83
h2. Possible solutions
84
85
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
86
87
<pre>
88
 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]
89
</pre>
90
91
so even if we'd use @<Location /users/login>@, the @require_login@ (== authenticate) would not be run and REMOTE_USER would not be consumed.
92
93
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
94
95
<pre>
96
 <Location /users/extlogin>
97
 AuthType Kerberos
98
 AuthName "Kerberos Login"
99
 KrbMethodNegotiate On
100
 KrbMethodK5Passwd Off
101
 KrbAuthRealms EXAMPLE.COM
102
 Krb5KeyTab /etc/http.keytab
103
 KrbLocalUserMapping On
104
 require valid-user
105
 ErrorDocument 401 '<html><meta http-equiv="refresh" content="0; URL=/users/login"><body>Kerberos authentication did not pass.</body></html>'
106
 </Location>
107
</pre>
108
109
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.
110
111
The patches support /users/extlogin not being configured properly, session expiration, and session logout.
112
113
The setting
114
115
<pre>
116
 :login_delegation_logout_url: /
117
</pre>
118
119
is not longer needed/used.