Fix issues if authentication is done by web server

This patch fixes `user` always being None if the authentication is
offloaded to the webserver, as it is suggested in the documentation.

For normal access, this is not a problem, but it becomes a problem if a
client wants to get the current-user-principal, for which the user name
is required.
This commit is contained in:
Jonas Wielicki 2014-01-14 20:45:12 +01:00
parent e2dbdd4d96
commit d9df9a36e1

View File

@ -278,7 +278,11 @@ class Application(object):
user, password = self.decode(base64.b64decode(
authorization.encode("ascii")), environ).split(":", 1)
else:
user = password = None
password = None
try:
user = environ["REMOTE_USER"]
except KeyError:
user = None
read_allowed_items, write_allowed_items = \
self.collect_allowed_items(items, user)