Robert Brewer avatar Robert Brewer committed 6a0d648

Added AUTH_TYPE, REMOTE_USER, and SERVER_SOFTWARE to wsgi environ. See #601.

Comments (0)

Files changed (1)

cherrypy/_cpwsgiserver.py

 """A high-speed, production ready, thread pooled, generic WSGI server."""
 
+import base64
 import mimetools # todo: use email
 import Queue
 import os
             return
         
         server = self.connection.server
+        self.environ["SERVER_SOFTWARE"] = "%s WSGI Server" % server.version
         
         method, path, req_protocol = request_line.strip().split(" ", 2)
         self.environ["REQUEST_METHOD"] = method
         headers = mimetools.Message(self.rfile)
         self.environ.update(self.parse_headers(headers))
         
+        creds = headers.getheader("Authorization", "").split(" ", 1)
+        self.environ["AUTH_TYPE"] = creds[0]
+        if creds[0].lower() == 'basic':
+            user, pw = base64.decodestring(creds[1]).split(":", 1)
+            self.environ["REMOTE_USER"] = user
+        
         # Persistent connection support
         if self.response_protocol == "HTTP/1.1":
             if headers.getheader("Connection", "") == "close":
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.