13.07.2015 Views

How to Use NDS eDirectory to Secure Apache Web ... - CGISecurity

How to Use NDS eDirectory to Secure Apache Web ... - CGISecurity

How to Use NDS eDirectory to Secure Apache Web ... - CGISecurity

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

IntroductionThe <strong>Apache</strong> <strong>Web</strong> Server is the most widely used <strong>Web</strong> server on theInternet. According <strong>to</strong> the NetCraft Survey, over 60% of the <strong>Web</strong>servers driving the Internet <strong>to</strong>day are <strong>Apache</strong> <strong>Web</strong> Servers. Being anopen source project and freely available makes <strong>Apache</strong> an attractiveresource <strong>to</strong> small business as well as large corporations. <strong>Apache</strong> isstable, scalable, reliable, and free. In the past five years, <strong>Apache</strong> hasequaled—and in many cases, surpassed—the functionality andstability of commercially-available <strong>Web</strong> servers.The standard <strong>Apache</strong> <strong>Web</strong> Server installation includes modules thatprovide a certain level of authentication and authorizationfunctionality. This functionality is primarily file-based and must beapplied on a direc<strong>to</strong>ry or location basis. The problem with this levelof security is that it is independent of the security provided by theoperating system itself.This AppNote discusses how two additional modules, MOD_<strong>NDS</strong>and AUTH_LDAP, provide a much greater level of security byallowing <strong>Apache</strong> <strong>to</strong> rely on the operating system rather thanreinventing the security wheel. In addition <strong>to</strong> authentication andauthorization, this article also discusses how <strong>to</strong> use MOD_TLS <strong>to</strong> setup <strong>Secure</strong> Sockets Layer (SSL) connections between the client andthe server.Installing the <strong>Apache</strong> <strong>Web</strong> ServerInstalling the <strong>Apache</strong> <strong>Web</strong> Server on NetWare is a straightforwardprocess. <strong>Apache</strong> for NetWare does not currently include aninstallation or setup program. For the time being, the installation andsetup of <strong>Apache</strong> on NetWare is a manual process. The process forinstalling the <strong>Apache</strong> <strong>Web</strong> Server on NetWare is described below.(For a more detailed description of how <strong>to</strong> set up <strong>Apache</strong> forNetWare, refer <strong>to</strong> the installation instructions that are included withthe software.)The <strong>Apache</strong> <strong>Web</strong> Server binaries for NetWare are available athttp://www.apache.org/dist/binaries/netware/. Here are the steps <strong>to</strong>obtain and install the files from this <strong>Web</strong> site:1. Download the file <strong>Apache</strong>_1.3.x_Netware.zip. (A newer versionthat is required for use with <strong>NDS</strong> is available with this article; allversions later than 1.3.14a will contain the required patches.)This file decompresses in<strong>to</strong> the standard direc<strong>to</strong>ry structure for adefault installation of <strong>Apache</strong>.22www.novell.com/appnotes


<strong>Apache</strong> <strong>Web</strong> Server ModulesOne of the strong points of <strong>Apache</strong> is the ability <strong>to</strong> extend the <strong>Web</strong>server through modules. In fact, most of the functionality that existsin the <strong>Apache</strong> <strong>Web</strong> server is provided by the inclusion of modules.There are two types of <strong>Apache</strong> modules: external and internal (orbuilt-in). An external module is a set of functionality that is wrappedup in<strong>to</strong> a separate executable file. Having the module as a separatefile allows the administra<strong>to</strong>r <strong>to</strong> add, replace, or remove the module asneeded. If a newer version of the module becomes available, theadministra<strong>to</strong>r simply has <strong>to</strong> copy the new executable file in<strong>to</strong> the/APACHE/MODULES direc<strong>to</strong>ry and restart the server.The second type of module is an internal (or built-in) module. Theseare modules or sets of functionality that have been compiled in<strong>to</strong> the<strong>Apache</strong> executable itself when it was built from source. From asource code perspective, there is really no difference between anexternal or built-in module. The source code for the module looks thesame, and the framework for implementing it does not differ. In fact,an external module can be compiled directly in<strong>to</strong> the <strong>Apache</strong>executable by simply including the source as part of the core <strong>Apache</strong>code.When a request is received by the <strong>Apache</strong> <strong>Web</strong> Server, it must passthrough a series of stages in order for it <strong>to</strong> be completely handled. Thearchitecture of <strong>Apache</strong> allows a module <strong>to</strong> insert itself in<strong>to</strong> any one ormore of these stages (see Figure 1).24www.novell.com/appnotes


Request(wait)Post-read-requestURL translationHeader parsingCleanupAccess controlAuthenticationLoggingAuthorizationMIME type checkingFixupsResponseFigure 1: <strong>Apache</strong> <strong>Web</strong> Server stages.Three of these stages deal with web server security: Access Control,Authentication, and Authorization. There are currently various<strong>Apache</strong> modules available that supply handlers for one or more ofthese stages in order <strong>to</strong> give the <strong>Apache</strong> <strong>Web</strong> Server a certain level ofsecurity.The following sections briefly describe the default level of securitythat is provided by the standard modules that ship with the <strong>Apache</strong><strong>Web</strong> Server. They will also discuss three additional modules thatallow <strong>Apache</strong> <strong>to</strong> take advantage of the security provided by theoperating system.F e b r u a r y 2 0 0 125


AuthType BasicAuthName Restricted_AreaAuth<strong>Use</strong>rFile VOL1:/<strong>Use</strong>rAccessFiles/Restricted.pwdRequire valid-user<strong>Apache</strong> provides the ability <strong>to</strong> restrict access <strong>to</strong> the file system, butthe level of security is very basic. The functionality that is providedby the authentication and access control modules is cumbersome <strong>to</strong>use and does not respect the file rights that are built in<strong>to</strong> the operatingsystem. Also, once a user has access <strong>to</strong> a direc<strong>to</strong>ry or location, all betsare off. In the above example, there is nothing preventing anindividual user from viewing all of the files or web pages contained inthat location. What is worse, the authentication mechanism has <strong>to</strong> bemanually applied <strong>to</strong> each restricted area. If the set of valid usersdiffers from one location <strong>to</strong> another, a new password file has <strong>to</strong> bedefined for each.For a detailed description of how <strong>to</strong> install and use the standardauthentication modules or <strong>to</strong> define or blocks, refer <strong>to</strong> any one of a number of <strong>Apache</strong> <strong>Web</strong> Serveradministration guides that are available in books<strong>to</strong>res or visithttp://www.apache.org.Integrating Native Security Services with <strong>Apache</strong>The best way <strong>to</strong> secure a web server is by using the native securityinherent in the operating system. NetWare already provides the bestsecurity services on the net so why not take advantage of them.Although <strong>Apache</strong> ships with a set of modules that include a basic se<strong>to</strong>f security features, all the security <strong>Apache</strong> needs already exist inNetWare. The <strong>Apache</strong> modules MOD_<strong>NDS</strong>, MOD_TLS andAUTH_LDAP allow <strong>Apache</strong> <strong>to</strong> take advantage of the NetWaresecurity services.Mod_TLSOne of the advantages of <strong>Apache</strong> for NetWare is the fact that thesoftware ships with SSL support built in. All other platforms mustdownload, build and install an additional module <strong>to</strong> obtain SSLsupport. The reason why <strong>Apache</strong> for NetWare is able <strong>to</strong> ship withSSL is because the support for SSL actually exists in socket layer,which is part of the NetWare OS. Since <strong>Apache</strong> simply relies on theoperating system for socket support, both <strong>Apache</strong> for NetWare aswell as MOD_TLS do not contain any encryption code. MOD_TLS,which is the SSL support module, simply tells the socket layer <strong>to</strong>enable SSL on a given port. It is a very small module that has onlyone directive.F e b r u a r y 2 0 0 127


<strong>Secure</strong>ListenSyntaxContextDescription<strong>Secure</strong>Listen server configInstructs <strong>Apache</strong> <strong>to</strong> listen <strong>to</strong> the specified port on asecure connection.Mod_<strong>NDS</strong>MOD_<strong>NDS</strong> is an <strong>Apache</strong> module that was derived from animplementation for Linux that is based on the NCPFS API. Themodule was originally developed by Philip R. Wilson and is publiclyavailable under the GNU General Public License. The NetWareimplementation of MOD_<strong>NDS</strong> simply replaces the calls <strong>to</strong> NCPFSwith direct calls <strong>to</strong> the NetWare DSAPI. By doing so, MOD_<strong>NDS</strong> isalso able <strong>to</strong> force <strong>Apache</strong> <strong>to</strong> respect the file rights that aremanipulated through Novell <strong>NDS</strong> eDirec<strong>to</strong>ry and enforced by the filesystem. This level of file access could not be achieved by the Linuxversion of MOD_<strong>NDS</strong>. The following is a description of thedirectives that allow an administra<strong>to</strong>r <strong>to</strong> integrate the NetWareDirec<strong>to</strong>ry Services authentication and authorization with the <strong>Apache</strong><strong>Web</strong> Server. For a complete description of the directives, refer <strong>to</strong> thedocumentation that accompanies MOD_<strong>NDS</strong>.Auth<strong>NDS</strong><strong>Use</strong>rFileSyntaxContextDescriptionAuth<strong>NDS</strong><strong>Use</strong>rFile direc<strong>to</strong>ry, .htaccessSets the name of a text file containing a list of usernamesthat are allowed <strong>to</strong> authenticate (obsolete onNetWare).Auth<strong>NDS</strong>AuthoritativeSyntaxContextDescriptionAuth<strong>NDS</strong>Authoritative direc<strong>to</strong>ry, .htaccessDetermines whether the request is allowed <strong>to</strong> be passedon <strong>to</strong> lower level modules for further authentication.Auth<strong>NDS</strong>TreeSyntaxContextDescriptionAuth<strong>NDS</strong>Authoritative direc<strong>to</strong>ry, .htaccessSets the <strong>NDS</strong> tree that will be used for user authentication.This is a manda<strong>to</strong>ry directive.28www.novell.com/appnotes


Auth<strong>NDS</strong>RequirePWSyntaxContextDescriptionAuth<strong>NDS</strong>RequirePW direc<strong>to</strong>ry, .htaccessDetermines if a user name with an empty password willbe allowed <strong>to</strong> access the site.Auth<strong>NDS</strong>ExpiredURISyntaxContextDescriptionAuth<strong>NDS</strong>ExpiredURIdirec<strong>to</strong>ry, .htaccessProvides redirection <strong>to</strong> an alternate page if an expiredpassword is detected.Auth<strong>NDS</strong>CacheTimeoutSyntaxAuth<strong>NDS</strong>CacheTimeout Default Auth<strong>NDS</strong>CacheTimeout 300ContextDescriptionserver configSets the time-<strong>to</strong>-live value for entries in the cache (inseconds), or disables the cache entirely (by setting it <strong>to</strong>zero).Auth<strong>NDS</strong>UniqueCNsSyntax Auth<strong>NDS</strong>UniqueCNs ContextDescriptionserver configEnables the caching of name->FDN mappings, whichprevents the module from having <strong>to</strong> search for the user'sFDN on every request.Auth<strong>NDS</strong>ContextSyntaxContextDescriptionAuth<strong>NDS</strong>Context direc<strong>to</strong>ry, .htaccessSets a search list of contexts for contextless logins.Auth<strong>NDS</strong>ContextOverrideSyntaxContextDescriptionAuth<strong>NDS</strong>ContextOverride direc<strong>to</strong>ry, .htaccessThis directive only applies <strong>to</strong> Auth<strong>NDS</strong>Context. If set <strong>to</strong>'ON' for a given direc<strong>to</strong>ry, it causes all search contextsdefined in higher-level direc<strong>to</strong>ries <strong>to</strong> be ignored.F e b r u a r y 2 0 0 129


The following 'require' directives are supported:require user Defines a list of valid users.require valid-userAllows access for any valid user name and password.require context Allows access for any valid user name and password with a matching context.require context Allows access for any valid user name and password with a partial matching context.Auth_LDAPThe AUTH_LDAP module is an authentication module that can beused <strong>to</strong> authenticate users against any LDAP compliant direc<strong>to</strong>ryservice. This is an open source module and is freely distributed underthe <strong>Apache</strong> Public License. The NetWare version of this modulecontains no significant changes from any other platformimplementation. It supports SSL connections <strong>to</strong> the LDAP serverprovided that both the NetWare server and the LDAP server havebeen configured correctly for SSL. The following is a listing of thedirectives that are supported by AUTH_LDAP. For a completedescription, refer <strong>to</strong> the documentation that accompanies the module.AuthLDAPBindDNSyntaxContextDescriptionAuthLDAPBindDN direc<strong>to</strong>ry, .htaccessAn optional DN used <strong>to</strong> bind <strong>to</strong> the server when searchingfor entries. If not provided, AUTH_LDAP will use ananonymous bind.AuthLDAPBindPasswordSyntaxContextDescriptionAuthLDAPBindPassword direc<strong>to</strong>ry, .htaccessA bind password <strong>to</strong> use in conjunction with the bind DN.AuthLDAPAuthoritativeSyntaxContextDescriptionAuthLDAPAuthoritative direc<strong>to</strong>ry, .htaccessSet <strong>to</strong> 'OFF' if this module should let other authenticationmodules attempt <strong>to</strong> authenticate the user, shouldauthentication with this module fail.30www.novell.com/appnotes


AuthLDAPURLSyntaxContextDescriptionAuthLDAPURL direc<strong>to</strong>ry, .htaccessA URL which specifies the LDAP search parameters <strong>to</strong>use.AuthLDAPRemote<strong>Use</strong>rIsDNSyntaxContextDescriptionAuthLDAPRemote<strong>Use</strong>rIsDN < Off (Default) | On>direc<strong>to</strong>ry, .htaccessIf this directive is set <strong>to</strong> 'ON', the value of theREMOTE_USER environment variable will be set <strong>to</strong> thefull distinguished name of the authenticated user,rather than just the username that was passed by theclientAuthLDAPCertDBPathSyntaxContextDescriptionAuthLDAPCertDBPath server configSpecifies in which direc<strong>to</strong>ry AUTH_LDAP should look forthe certificate authorities database. There should be afile named cert7.db in that direc<strong>to</strong>ry.AuthLDAPCacheSizeSyntaxContextDescriptionAuthLDAPCacheSize server configSpecifies the maximum size of the LDAP search cache.AuthLDAPCacheTTLSyntaxContextDescriptionAuthLDAPCacheTTL server configSpecifies the time (in seconds) that an item in thesearch cache remains valid.AuthLDAPOpCacheSizeSyntaxContextDescriptionAuthLDAPOpCacheSize server configSpecifies the size of the cache AUTH_LDAP uses <strong>to</strong>cache LDAP operations.F e b r u a r y 2 0 0 131


At this point the modules will be loaded and all of the directives forMOD_TLS and MOD_<strong>NDS</strong> are available and ready <strong>to</strong> go. All that isleft <strong>to</strong> be done is <strong>to</strong> define the file restrictions in the HTTPD.CONFfile and determining when authentication is required. One simpleexample of requiring authentication and enforcing file access rightscould be as follows. Any request for a page that resides within thespecified direc<strong>to</strong>ry will prompt the user for authentication credentialsand enforce file access rights based on those credentials.<strong>Secure</strong>Listen 443 "SSL CertificateIP"AuthType BasicAuthName A_Protected_PlaceAuth<strong>NDS</strong>Tree my_company_treeAuth<strong>NDS</strong>Context .my_sales.staff .my_marketing.staffrequire valid-userWhen a request is issued for a page that resides in the privatedirec<strong>to</strong>ry, the above example will prompt the user for a valid username and password. If the user were a member of the one of the listedcontexts, only a valid user name rather than the fully qualifieddistinguished name would be required. Once the user name andpassword are supplied <strong>to</strong> the web server, the credentials are verifiedagainst <strong>NDS</strong> and the session is logged in as the specified user. Fromthen on all of the file rights that have been granted <strong>to</strong> the user areenforced by the operating system. If the user does not have file access<strong>to</strong> the requested page, a 403 Access Denied response will be returned.By using MOD_TLS and MOD_<strong>NDS</strong>, the web server is able <strong>to</strong>communicate with the browser over a secure connection and allowthe user access <strong>to</strong> only those files that the user has been granted rights<strong>to</strong> view. MOD_<strong>NDS</strong> integrates <strong>Apache</strong> with the world class securityservices that are provided by the NetWare operating system.Therefore there is no difference between managing web users and fileaccess as managing LAN users. In fact they are one and the same.F e b r u a r y 2 0 0 133


ConclusionSetting up and securing an <strong>Apache</strong> <strong>Web</strong> server is literally as easy asinstalling the <strong>Apache</strong> software and telling it <strong>to</strong> use the securityservices provide by NetWare. Granting or revoking rights <strong>to</strong> webpage is as simple has granting or revoking rights <strong>to</strong> a file or direc<strong>to</strong>ry.Since <strong>Apache</strong> is simply taking advantage of the security services thatare provided by the operating system, your web site has the samesecurity that you are used <strong>to</strong> with NetWare. Managing users, groupsand file access for the web is done in the same manner and using thesame <strong>to</strong>ols as have always been used <strong>to</strong> manage your NetWare server.There is nothing new <strong>to</strong> learn in order <strong>to</strong> secure your <strong>Apache</strong> <strong>Web</strong>Server. Best of all, the <strong>Apache</strong> <strong>Web</strong> Server, along with the securityaccess modules, are all free and available on the Internet.For more information about the <strong>Apache</strong> <strong>Web</strong> Server and other opensource projects, visit http://www.apache.org/.Copyright © 2001 by Novell, Inc. All rights reserved.No part of this document may be reproduced or transmittedin any form or by any means, electronic or mechanical,including pho<strong>to</strong>copying and recording, for any purposewithout the express written permission of Novell.All product names mentioned are trademarks oftheir respective companies or distribu<strong>to</strong>rs.34www.novell.com/appnotes

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!