Edgewall Software

Changes between Version 65 and Version 66 of TracModWSGI


Ignore:
Timestamp:
Mar 23, 2015, 4:58:36 AM (9 years ago)
Author:
Ryan J Ollos
Comment:

Improved markup.

Legend:

Unmodified
Added
Removed
Modified
  • TracModWSGI

    v65 v66  
    7575After preparing your .wsgi script, add the following to your Apache configuration file, typically `httpd.conf`:
    7676
    77 {{{
     77{{{#!apache
    7878WSGIScriptAlias /trac /usr/local/trac/mysite/apache/mysite.wsgi
    7979
     
    8989If you followed the directions [TracInstall#cgi-bin Generating the Trac cgi-bin directory], your Apache configuration file should look like following:
    9090
    91 {{{
     91{{{#!apache
    9292WSGIScriptAlias /trac /usr/share/trac/cgi-bin/trac.wsgi
    9393
     
    115115The following sections describe different methods for setting up authentication. See also [http://httpd.apache.org/docs/2.2/howto/auth.html Authentication, Authorization and Access Control] in the Apache guide.
    116116
    117 === Using Basic Authentication ===
     117=== Using Basic Authentication
    118118
    119119The simplest way to enable authentication with Apache is to create a password file. Use the `htpasswd` program as follows:
    120 {{{
     120{{{#!sh
    121121$ htpasswd -c /somewhere/trac.htpasswd admin
    122122New password: <type password>
     
    126126
    127127After the first user, you don't need the "-c" option anymore:
    128 {{{
     128{{{#!sh
    129129$ htpasswd /somewhere/trac.htpasswd john
    130130New password: <type password>
     
    138138
    139139Now, you need to enable authentication against the password file in the Apache configuration:
    140 {{{
     140{{{#!apache
    141141<Location "/trac/login">
    142142  AuthType Basic
     
    148148
    149149If you are hosting multiple projects, you can use the same password file for all of them:
    150 {{{
     150{{{#!apache
    151151<LocationMatch "/trac/[^/]+/login">
    152152  AuthType Basic
     
    159159See also the [http://httpd.apache.org/docs/2.2/mod/mod_auth_basic.html mod_auth_basic] documentation.
    160160
    161 === Using Digest Authentication ===
     161=== Using Digest Authentication
    162162
    163163For better security, it is recommended that you either enable SSL or at least use the “digest” authentication scheme instead of “Basic”.
    164164
    165165You have to create your `.htpasswd` file with the `htdigest` command instead of `htpasswd`, as follows:
    166 {{{
    167 # htdigest -c /somewhere/trac.htpasswd trac admin
     166{{{#!sh
     167$ htdigest -c /somewhere/trac.htpasswd trac admin
    168168}}}
    169169
    170170The "trac" parameter above is the "realm", and will have to be reused in the Apache configuration in the !AuthName directive:
    171171
    172 {{{
     172{{{#!apache
    173173<Location "/trac/login">
    174 
    175     AuthType Digest
    176     AuthName "trac"
    177     AuthDigestDomain /trac
    178     AuthUserFile /somewhere/trac.htpasswd
    179     Require valid-user
     174  AuthType Digest
     175  AuthName "trac"
     176  AuthDigestDomain /trac
     177  AuthUserFile /somewhere/trac.htpasswd
     178  Require valid-user
    180179</Location>
    181180}}}
     
    186185
    187186Don't forget to activate the mod_auth_digest. For example, on a Debian 4.0r1 (etch) system:
    188 {{{
    189     LoadModule auth_digest_module /usr/lib/apache2/modules/mod_auth_digest.so
     187{{{#!apache
     188  LoadModule auth_digest_module /usr/lib/apache2/modules/mod_auth_digest.so
    190189}}}
    191190
     
    197196
    1981971. You need to load the following modules in Apache httpd.conf:
    199 {{{
    200 LoadModule ldap_module modules/mod_ldap.so
    201 LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
    202 }}}
    203 
    204 2. Your httpd.conf also needs to look something like:
    205 
    206 {{{
     198{{{#!apache
     199  LoadModule ldap_module modules/mod_ldap.so
     200  LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
     201}}}
     2021. Your httpd.conf also needs to look something like:
     203{{{#!apache
    207204<Location /trac/>
    208205  # (if you're using it, mod_python specific settings go here)
     
    218215</Location>
    219216}}}
    220 
    221 3. You can use the LDAP interface as a way to authenticate to a Microsoft Active Directory:
    222 
    223 Use the following as your LDAP URL:
    224 {{{
    225     AuthLDAPURL "ldap://directory.example.com:3268/DC=example,DC=com?sAMAccountName?sub?(objectClass=user)"
    226 }}}
    227 
    228 You will also need to provide an account for Apache to use when checking credentials. As this password will be listed in plaintext in the config, you need to use an account specifically for this task:
    229 {{{
    230     AuthLDAPBindDN ldap-auth-user@example.com
    231     AuthLDAPBindPassword "password"
    232 }}}
    233 
    234 The whole section looks like:
    235 {{{
     2171. You can use the LDAP interface as a way to authenticate to a Microsoft Active Directory. Use the following as your LDAP URL:
     218{{{#!apache
     219  AuthLDAPURL "ldap://directory.example.com:3268/DC=example,DC=com?sAMAccountName?sub?(objectClass=user)"
     220}}}
     221 You will also need to provide an account for Apache to use when checking credentials. As this password will be listed in plaintext in the config, you need to use an account specifically for this task:
     222{{{#!apache
     223  AuthLDAPBindDN ldap-auth-user@example.com
     224  AuthLDAPBindPassword "password"
     225}}}
     226 The whole section looks like:
     227{{{#!apache
    236228<Location /trac/>
    237229  # (if you're using it, mod_python specific settings go here)
     
    247239  authzldapauthoritative Off
    248240  # require valid-user
    249   require ldap-group CN=Trac Users,CN=Users,DC=company,DC=com
     241  Require ldap-group CN=Trac Users,CN=Users,DC=company,DC=com
    250242</Location>
    251243}}}
     
    254246
    255247Note 2: You can also require the user be a member of a certain LDAP group, instead of just having a valid login:
    256 {{{
    257     Require ldap-group CN=Trac Users,CN=Users,DC=example,DC=com
     248{{{#!apache
     249  Require ldap-group CN=Trac Users,CN=Users,DC=example,DC=com
    258250}}}
    259251
     
    266258
    267259If you are using Apache on Windows, you can use mod_auth_sspi to provide single-sign-on. Download the module from the !SourceForge [http://sourceforge.net/projects/mod-auth-sspi/ mod-auth-sspi project] and then add the following to your !VirtualHost:
    268 {{{
    269     <Location /trac/login>
    270         AuthType SSPI
    271         AuthName "Trac Login"
    272         SSPIAuth On
    273         SSPIAuthoritative On
    274         SSPIDomain MyLocalDomain
    275         SSPIOfferBasic On
    276         SSPIOmitDomain Off
    277         SSPIBasicPreferred On
    278         Require valid-user
    279     </Location>
     260{{{#!apache
     261<Location /trac/login>
     262  AuthType SSPI
     263  AuthName "Trac Login"
     264  SSPIAuth On
     265  SSPIAuthoritative On
     266  SSPIDomain MyLocalDomain
     267  SSPIOfferBasic On
     268  SSPIOmitDomain Off
     269  SSPIBasicPreferred On
     270  Require valid-user
     271</Location>
    280272}}}
    281273
     
    293285
    294286Here is an example (from the !HttpAuthStore link) using acct_mgr-0.4 for hosting a single project:
    295 {{{
     287{{{#!ini
    296288[components]
    297289; be sure to enable the component
     
    304296}}}
    305297This will generally be matched with an Apache config like:
    306 {{{
     298{{{#!apache
    307299<Location /authFile>
    308300   …HTTP authentication configuration…
     
    321313
    322314Create the htpasswd file:
    323 {{{
     315{{{#!sh
    324316cd /home/trac-for-my-proj/the-env
    325317htpasswd -c htpasswd firstuser
     
    331323Create this file e.g. (ubuntu) `/etc/apache2/sites-enabled/trac.my-proj.my-site.org.conf` with the following content:
    332324
    333 {{{
     325{{{#!apache
    334326<Directory /home/trac-for-my-proj/the-deploy/cgi-bin/trac.wsgi>
    335327  WSGIApplicationGroup %{GLOBAL}
     
    364356If you plan to use `mod_wsgi` in embedded mode on Windows or with the MPM worker on Linux, then you will need version 0.3.4 or greater. See [trac:#10675] for details.
    365357
    366 === Getting Trac to work nicely with SSPI and 'Require Group' ===
     358=== Getting Trac to work nicely with SSPI and 'Require Group'
    367359
    368360If you have set Trac up on Apache, Win32 and configured SSPI, but added a 'Require group' option to your apache configuration, then the SSPIOmitDomain option is probably not working. If it is not working, your usernames in Trac probably look like 'DOMAIN\user' rather than 'user'.
     
    382374}}}
    383375
    384 === Trac with PostgreSQL ===
     376=== Trac with PostgreSQL
    385377
    386378When using the mod_wsgi adapter with multiple Trac instances and PostgreSQL (or MySQL?) as the database, the server ''may'' create a lot of open database connections and thus PostgreSQL processes.