Changes between Initial Version and Version 1 of SslAuthenticationPlugin


Ignore:
Timestamp:
Apr 26, 2008, 8:30:53 PM (16 years ago)
Author:
Giel van Schijndel
Comment:

New hack SslAuthenticationPlugin, created by giel

Legend:

Unmodified
Added
Removed
Modified
  • SslAuthenticationPlugin

    v1 v1  
     1= SSL Authentication =
     2
     3== Description ==
     4
     5This plugin allows authentication of users by making use of SSL client certificates.
     6
     7== Bugs/Feature Requests ==
     8
     9Existing bugs and feature requests for SslAuthenticationPlugin are
     10[report:9?COMPONENT=SslAuthenticationPlugin here].
     11
     12If you have any issues, create a
     13[http://trac-hacks.org/newticket?component=SslAuthenticationPlugin&owner=giel new ticket].
     14
     15== Download ==
     16
     17Download the zipped source from [download:sslauthenticationplugin here].
     18
     19== Source ==
     20
     21You can check out SslAuthenticationPlugin from [http://trac-hacks.org/svn/sslauthenticationplugin here] using Subversion, or [source:sslauthenticationplugin browse the source] with Trac.
     22
     23== Example ==
     24
     25Currently a small patch is required to be applied against Trac in order to get this working (this patch is against 10.4-2, the -2 represents a Debian package revision):
     26{{{
     27#!diff
     28diff -Nur /usr/share/python-support/trac/trac/web/main.py /var/lib/python-support/python2.4/trac/web/main.py
     29--- /usr/share/python-support/trac/trac/web/main.py     2007-05-30 03:23:40.000000000 +0200
     30+++ /var/lib/python-support/python2.4/trac/web/main.py  2008-04-26 21:55:45.000000000 +0200
     31@@ -180,7 +180,13 @@
     32             if not getattr(chosen_handler, 'anonymous_request', False):
     33                 try:
     34                     req.authname = self.authenticate(req)
     35-                    req.perm = PermissionCache(self.env, req.authname)
     36+                    try:
     37+                        if req.perm_user:
     38+                            req.perm = PermissionCache(self.env, req.perm_user)
     39+                        else:
     40+                            req.perm = PermissionCache(self.env, req.authname)
     41+                    except:
     42+                        req.perm = PermissionCache(self.env, req.authname)
     43                     req.session = Session(self.env, req)
     44                     req.form_token = self._get_form_token(req)
     45                 except:
     46}}}
     47
     48When this patch is applied you can use a virtual host config section similar to this (assuming you're using Apache):
     49{{{
     50#!apache
     51<VirtualHost *:443>
     52    ServerName trac.example.org
     53
     54    Alias /chrome/common /usr/share/trac/htdocs
     55
     56    SSLEngine on
     57    SSLCertificateFile /etc/apache2/ssl/trac.example.org_publickey.pem
     58    SSLCertificateKeyFile /etc/apache2/ssl/trac.example.org_privatekey.pem
     59    # I use CACert's root certificate, you can get it from here: http://www.cacert.org/index.php?id=3
     60    SSLCACertificateFile /etc/apache2/ssl/CACert_class_1_and_3.pem
     61
     62    SSLVerifyClient none
     63    SSLOptions -StrictRequire
     64
     65    <Directory "/usr/share/trac/htdocs">
     66        Options Indexes MultiViews
     67        AllowOverride None
     68        Order allow,deny
     69        Allow from all
     70    </Directory>
     71
     72    <Location "/test">
     73        SetHandler mod_python
     74        PythonHandler trac.web.modpython_frontend
     75        PythonOption TracEnv /var/trac/test
     76        PythonOption TracUriRoot /personal/
     77
     78        # Authentication
     79        # Require SSL connection to access this location
     80        SSLRequireSSL
     81
     82        # Requires client verification, and verifies up to 2 intermediary CAs
     83        SSLVerifyClient optional
     84        SSLVerifyDepth 2
     85
     86        # Creates additional environment variables including client certificate data
     87        SSLOptions +StdEnvVars
     88        # Requires the above SSLRequireSSL directive to be succesfull as well as
     89        # the SSLRequire directive below, if it isn't succesfull Apache will
     90        # refuse access to this page.
     91        SSLOptions +StrictRequire
     92
     93        # Requires, that the client's CN and e-mail in the certificates equals one of the below
     94        SSLRequire %{SSL_CIPHER_USEKEYSIZE} >= 128
     95    </Location>
     96
     97    # Lets still allow basic HTTP authentication
     98    <Location "/test/login">
     99        AuthType Basic
     100        AuthName "Test Trac"
     101        AuthUserFile /etc/apache2/passwd/trac.example.org/test.passwd
     102        Require valid-user
     103    </Location>
     104
     105    CustomLog /var/log/apache2/trac.example.org/access.log combined
     106    ErrorLog /var/log/apache2/trac.example.org/error.log
     107</VirtualHost>
     108}}}
     109
     110If the plugin is installed and enabled, and the patch is applied, you will be able to automatically log in with the email address in your browser's client certificate.
     111
     112You can create yourself a client certificate at [http://cacert.org/ CACert].
     113
     114== Recent Changes ==
     115
     116[[ChangeLog(sslauthenticationplugin, 3)]]
     117
     118== Author/Contributors ==
     119
     120'''Author:''' [wiki:giel] [[BR]]
     121'''Contributors:'''