Fixed bug: Some exceptions were not caught.
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Tue, 8 Apr 2014 18:00:20 +0000 (20:00 +0200)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Tue, 8 Apr 2014 18:33:31 +0000 (20:33 +0200)
cgi-bin/dyndns.py

index d62ebfc..1d3e2d2 100755 (executable)
@@ -89,24 +89,23 @@ system   = fields.getvalue('system')
 url      = fields.getvalue('url')
 
 
-# Optional Auth Basic
-auth = os.environ.get('HTTP_AUTHORIZATION') # auth == 'Basic cGhpbGlwcDpka2ZhamRrZg=='
-if auth: # empty string if HTTP_AUTHORIZATION not present
-       auth_parts = auth.split(' ')
-       auth_method = 'Basic'
-       if len(auth_parts) != 2 or auth_parts[0] != auth_method:
-               raise AuthWrongMethod()
-       try:
-               auth_decoded = base64.b64decode(auth_parts[1]) # auth_decoded == 'philipp:dkfajdkf'
-       except TypeError:
-               raise AuthBasicError()
-       auth_decoded_parts = auth_decoded.split(':')
-       if len(auth_decoded_parts) != 2:
-               raise AuthBasicError()
-       username, password = auth_decoded_parts
-
-
 try:
+       # Optional Auth Basic
+       auth = os.environ.get('HTTP_AUTHORIZATION') # auth == 'Basic cGhpbGlwcDpka2ZhamRrZg=='
+       if auth: # empty string if HTTP_AUTHORIZATION not present
+               auth_parts = auth.split(' ')
+               auth_method = 'Basic'
+               if len(auth_parts) != 2 or auth_parts[0] != auth_method:
+                       raise AuthWrongMethod()
+               try:
+                       auth_decoded = base64.b64decode(auth_parts[1]) # auth_decoded == 'philipp:dkfajdkf'
+               except TypeError:
+                       raise AuthBasicError()
+               auth_decoded_parts = auth_decoded.split(':')
+               if len(auth_decoded_parts) != 2:
+                       raise AuthBasicError()
+               username, password = auth_decoded_parts
+
        # check username and password
        if username is None and password is None:
                raise CredentialsMissing()