chiark / gitweb /
httpauth.py, cmd-cgi.py, list.fhtml: Implement explicit logout action.
[chopwood] / httpauth.py
index 4a41e4fcb16267b7242f79c6366bcef507bc6b20..13ba0d1155767a66de538942a6851f776d6ffdbb 100644 (file)
@@ -175,6 +175,7 @@ LOGIN_REASONS = {
   'EXPIRED': 'session timed out',
   'BADTAG': 'incorrect tag',
   'NOUSER': 'unknown user name',
+  'LOGOUT': 'explicitly logged out',
   None: None
 }
 
@@ -201,6 +202,9 @@ def check_auth(token, nonce = None):
 
   global NONCE
 
+  ## If the token has been explicitly clobbered, then we're logged out.
+  if token == 'logged-out': raise AuthenticationFailed, 'LOGOUT'
+
   ## Parse the token.
   bits = token.split('.', 3)
   if len(bits) != 4: raise AuthenticationFailed, 'BADTOKEN'