From d9df9a36e1e0bb675ef6f70d6a2bec041e318b15 Mon Sep 17 00:00:00 2001 From: Jonas Wielicki Date: Tue, 14 Jan 2014 20:45:12 +0100 Subject: [PATCH] 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. --- radicale/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/radicale/__init__.py b/radicale/__init__.py index 9222e9c3..bec1683b 100644 --- a/radicale/__init__.py +++ b/radicale/__init__.py @@ -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)