1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
"""
mod_python gateway to all interesting cobbler web and web service
functions.
Copyright 2007, Red Hat, Inc
Michael DeHaan <mdehaan@redhat.com>
This software may be freely redistributed under the terms of the GNU
general public license.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
"""
# TO DO:
# connect backend authn via cobbler XMLRPC (non-RW) API
# connect backend authz via cobbler XMLRPC (RW) API
# serve up Web UI through this interface, via tokens in headers
# make REST interface for read/write commands (also?)
from mod_python import apache
def __get_user(req):
req.add_common_vars()
env_vars = req.subprocess_env.copy()
return env_vars["REMOTE_USER"]
def index(req):
user = __get_user(req)
path = req.uri
return "Hello, %s, %s" % (user, path)
def hello(req):
user = __get_user(req)
path = req.uri
return "We are in hello(%s)" % path
def authenhandler(req):
pw = req.get_basic_auth_pw()
user = req.user
# FIXME: poll cobbler_api (not rw) here to check
# check_authn(user,pass) -> T/F
apache.log_error("authenticate handler called")
if user == "admin" and pw == "cobbler":
return apache.OK
else:
return apache.HTTP_UNAUTHORIZED
def accesshandler(req):
uri = req.uri
apache.log_error("accesshandler uri: %s" % (uri))
# FIXME: poll cobbler_api (not rw) here to check
# check_access(user,uri) -> T/F
if uri.find("hello") != -1:
return apache.HTTP_FORBIDDEN
return apache.OK
def authenzhandler(req):
# we really don't need this because of the accesshandler.
# add in later if we find we /DO/ need it
return apache.OK
|