Configure Apache to use Kerberos authentication
ObjectiveTo configure Apache to use Kerberos authentication BackgroundKerberos is an authentication protocol that supports the concept of Single Sign-On (SSO). Having authenticated once at the start of a session, users can access network services throughout a Kerberos realm without authenticating again. For this to work it is necessary to use network protocols that are Kerberos-aware. In the case of HTTP, support for Kerberos is usually provided using the SPNEGO authentication mechanism (Simple and Protected GSS-API Negotiation). This is also known as ‘integrated authentication’ or ‘negotiate authentication’. Apache does not itself support SPNEGO, but support can be added by means of the ScenarioSuppose you wish to restrict access to the web site The users to be given access are members of the Kerberos realm PrerequisitesThe description below assumes that you have already installed both Apache and Kerberos on the web server. Apache should be in a state where you can request at least one page from the relevant web site for testing purposes. It need not contain any real content (and if it does then you will probably want to take steps to isolate the server from unauthorised users until it has been properly secured). Kerberos should be in a state where MethodOverviewThe method described here has six steps:
Note that in addition to enabling SPNEGO on the web server, it may also be necessary to explicitly enable it within the web browser. This is known to be the case for Mozilla Firefox. See: Install the mod_auth_kerb authentication moduleAs noted above, Apache does not itself provide support for SPNEGO but it can be added using the module apt-get install libapache2-mod-auth-kerb and on Red Hat-based systems by the package yum install mod_auth_kerb Apache modules must be loaded before they can be used, but both of the above packages arrange for this to happen automatically. If for any reason you need to do this manually then the appropriate configuration directive is: LoadModule auth_kerb_module /usr/lib/apache2/modules/mod_auth_kerb.so (where the pathname of the module should be replaced with whatever is appropriate for your system). Create a service principal for the web serverSPNEGO requires that a Kerberos service principal be created for the web server. The service name is defined to be If you are using MIT Kerberos then the service principal can be created using the kadmin -p bofh/admin -q "addprinc -randkey HTTP/www." See the microHOWTO Create a service principal using MIT Kerberos for further information about how a service principal can be created and why one is needed. Create a keytab for the service principalA keytab is a file for storing the encryption keys corresponding to one or more Kerberos principals. On Debian-based systems a suitable location for the keytab would be kadmin -p bofh/admin -q "ktadd -k /etc/apache2/http.keytab HTTP/www." chown www-data /etc/apache2/http.keytab On Red Hat-based systems a suitable location would be kadmin -p bofh/admin -q "ktadd -k /etc/httpd/http.keytab HTTP/www." chown apache /etc/httpd/http.keytab The See the microHOWTO Add a host or service principal to a keytab using MIT Kerberos for further information about the creation of keytabs, their purpose, and why the default keytab (typically If you wish to check that the key has been correctly added to the keytab then you can attempt to use it to authenticate as the service principal, then view the resulting ticket-granting ticket using kinit -k -t /etc/apache2/http.keytab HTTP/www. klist Specify the authentication method to be usedApache must be told which parts of which web sites are to use authentication provided by If the intent is to apply these directive to the whole of a given web site then they can be placed in a <Location /> AuthType Kerberos AuthName "Acme Corporation" KrbMethodNegotiate on KrbMethodK5Passwd off Krb5Keytab /etc/apache2/http.keytab </Location> The In addition to the SPNEGO protocol, The Although a Specify a list of authorised usersSetting the authentication method does not by itself restrict access to the server. This is because Apache defaults to allowing access by anonymous users, and unless that behaviour is overridden then the authentication method (whatever it might be) will not be invoked. In this example there are only four users who need access, and the simplest way to arrange that is by means of a <Location /> # ... Require user dougal@EXAMPLE.COM brian@EXAMPLE.COM ermintrude@EXAMPLE.COM dylan@EXAMPLE.COM </Location> Note that each name is qualified by the Kerberos realm of which it is a member. For servers with larger numbers of users this is obviously not a scalable solution, however Apache has other authorisation methods that can efficiently handle large numbers of users including Reload the Apache configurationSee Cause a system service to reload its configuration. On recent Debian-based systems the required command is: service apache2 force-reload Security considerationsPassword authenticationAs noted above,
The first of these points can be addressed by enabling access via TLS (SSL) and disabling plain HTTP. The second and third points are less tractable, and undermine many of the security benefits provided by the Single Sign-on model generally and by Kerberos in particular. In practice it is sometimes necessary to allow access from hosts that are not part of the Kerberos realm or from user agents that do not support SPNEGO. For this reason it is unrealistic to recommend that password authentication should never be used as a fallback, however it is best avoided if you can and should not be permitted merely because it is enabled by default. SPNEGOAuthentication using SPNEGO addresses the concerns listed above but the manner in which it is integrated with HTTP is far from ideal. When a client authenticates to a Kerberos network service one of the products of the authentication process is an encryption key that the client and server can use to secure any further communication between them. This is not used when an HTTP connection is authenticated using SPNEGO, which means that if a connection is hijacked after authentication has completed then there is nothing to prevent an attacker from issuing unauthorised HTTP commands. This risk can be greatly reduced by using TLS (SSL) to secure the connection. This prevents a connection from being hijacked once it has been established, and prevents a server from accepting connections to a web site for which it does not have a valid certificate. It is not a perfect solution because of the large number of organisations that can issue certificates. There is a solution which uses channel binding to link the TLS key to Kerberos, however at the time of writing it had not been widely implemented (and is not supported by See also
Further reading
|
|
来自: sven_ > 《Kerberos单点登录》