* Misc. fixes in bongo-standalone, Auth and PropfindView.

* Added Server.py for use in Apache.
 * Note: this currently doesn't work, so unless you have a way to send the
   Authorization header manually, Sundial through Apache will not work. This
   is pretty high up on my TODO list.
This commit is contained in:
jonnylamb
2007-09-14 13:18:33 +00:00
parent 6c8ffc91d8
commit e484cc4dd9
5 changed files with 57 additions and 3 deletions
+2 -1
View File
@@ -365,7 +365,8 @@ pkgpythonsundial_PYTHON := \
src/www/bongo/sundial/OptionsView.py \
src/www/bongo/sundial/ReportView.py \
src/www/bongo/sundial/DeleteView.py \
src/www/bongo/sundial/PutView.py
src/www/bongo/sundial/PutView.py \
src/www/bongo/sundial/Server.py
pkgpythoncommonwebdir = $(pkgpythondir)/commonweb
+1 -1
View File
@@ -219,7 +219,7 @@ class DragonflyHandler(SimpleHTTPRequestHandler):
handler = rp.GetHandler(req, rp)
if handler.NeedsAuth(rp):
if req.user == None:
if req.user is None:
self.req.headers_out["WWW-Authenticate"] = "Basic realm=\"Bongo\""
self.send_error(bongo.commonweb.HTTP_UNAUTHORIZED)
return bongo.commonweb.HTTP_UNAUTHORIZED
+1 -1
View File
@@ -35,7 +35,7 @@ def AcceptCredentials(req):
# Upon a success or failure, return the appropriate HTTP error code.
def authenhandler(req):
if AcceptCredentials(req):
req.log.debug("successful auth")
# req.log.debug("successful auth")
return bongo.commonweb.HTTP_OK
return bongo.commonweb.HTTP_UNAUTHORIZED
+1
View File
@@ -6,6 +6,7 @@
import bongo.commonweb
import bongo.commonweb.ElementTree
from bongo.commonweb.HttpError import HttpError
from SundialHandler import SundialHandler
from bongo.store.StoreClient import StoreClient
from bongo.store.StoreClient import DocTypes
+52
View File
@@ -0,0 +1,52 @@
from bongo.commonweb.ApacheLogHandler import ApacheLogHandler, RequestLogProxy
from SundialPath import SundialPath
from bongo.commonweb.HttpError import HttpError
import Auth
import bongo.commonweb
# Add a handler so messages from python's logging module go to apache.
# We don't use that module in the Bongo server proper, because we need
# to log to apache requests directly
import logging
logging.getLogger('').addHandler(ApacheLogHandler())
logging.root.setLevel(logging.DEBUG)
def handler(req):
req.log = RequestLogProxy(req)
req.log.debug("Request: %s", req)
try:
rp = SundialPath(req)
handler = rp.GetHandler(req, rp)
# if handler.NeedsAuth(rp):
# if req.user is None:
# self.req.headers_out["WWW-Authenticate"] = 'Basic realm="Bongo"'
# self.send_error(bongo.commonweb.HTTP_UNAUTHORIZED)
# return bongo.commonweb.HTTP_UNAUTHORIZED
# else:
# auth = bongo.sundial.Auth.authenhandler(req)
req.log.debug("request for %s (handled by %s)", req.path_info, handler)
mname = "do_" + req.method
if not hasattr(handler, mname):
req.log.debug("%s has no %s", handler, mname)
return bongo.commonweb.HTTP_NOT_FOUND
method = getattr(handler, mname)
ret = method(req, rp)
if ret is None:
req.log.error("Handler %s returned invalid value: None" % handler)
return bongo.commonweb.OK
return ret
except HttpError, e:
req.log.debug(str(e), exc_info=1)
return e.code