Package pulp :: Package server :: Package webservices :: Package httpd :: Module repo_cert_handler
[hide private]
[frames] | no frames]

Source Code for Module pulp.server.webservices.httpd.repo_cert_handler

 1  #!/usr/bin/python 
 2  # 
 3  # Copyright (c) 2010 Red Hat, Inc. 
 4  # 
 5  # This software is licensed to you under the GNU General Public License, 
 6  # version 2 (GPLv2). There is NO WARRANTY for this software, express or 
 7  # implied, including the implied warranties of MERCHANTABILITY or FITNESS 
 8  # FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 
 9  # along with this software; if not, see 
10  # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 
11  # 
12  # Red Hat trademarks are not licensed under GPLv2. No permission is 
13  # granted to use or replicate Red Hat trademarks that are incorporated 
14  # in this software or its documentation. 
15   
16  import logging 
17   
18  from mod_python import apache 
19   
20  from pulp.server import config 
21  from pulp.server.webservices.httpd import repo_cert_validation as validation 
22   
23  # Logging 
24  format = logging.Formatter('%(asctime)s  %(message)s') 
25  file_handler = logging.FileHandler('/var/log/pulp/repo_entitlement.log') 
26  file_handler.setFormatter(format) 
27  logging.getLogger('pulp.webservices').addHandler(file_handler) 
28  logging.getLogger('pulp.webservices').setLevel(logging.DEBUG) 
29   
30  log = logging.getLogger(__name__) 
31   
32   
33 -def authenhandler(req):
34 # Needed to stuff the SSL variables into the request 35 req.add_common_vars() 36 37 # Only apply the entitlement certificate logic if pulp.webservices is configured to do so 38 if config.config.getboolean('repos', 'use_entitlement_certs'): 39 log.debug('Verifying client entitlement') 40 cert_pem = req.ssl_var_lookup('SSL_CLIENT_CERT') 41 42 if validation.is_valid(req.uri, cert_pem): 43 req.user = 'foo' 44 return apache.OK 45 else: 46 return apache.HTTP_UNAUTHORIZED 47 else: 48 req.user = 'foo' 49 return apache.OK
50