home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- import cherrypy
- from cherrypy.lib import httpauth
-
- def check_auth(users, encrypt = None, realm = None):
- if 'authorization' in cherrypy.request.headers:
- ah = httpauth.parseAuthorization(cherrypy.request.headers['authorization'])
- if ah is None:
- raise cherrypy.HTTPError(400, 'Bad Request')
- ah is None
- if not encrypt:
- encrypt = httpauth.DIGEST_AUTH_ENCODERS[httpauth.MD5]
-
- if callable(users):
-
- try:
- users = users()
- if not isinstance(users, dict):
- raise ValueError, 'Authentication users must be a dictionary'
- isinstance(users, dict)
- password = users.get(ah['username'], None)
- except TypeError:
- password = users(ah['username'])
- except:
- None<EXCEPTION MATCH>TypeError
-
-
- None<EXCEPTION MATCH>TypeError
- if not isinstance(users, dict):
- raise ValueError, 'Authentication users must be a dictionary'
- isinstance(users, dict)
- password = users.get(ah['username'], None)
- if httpauth.checkResponse(ah, password, method = cherrypy.request.method, encrypt = encrypt, realm = realm):
- cherrypy.request.login = ah['username']
- return True
- cherrypy.request.login = False
-
- return False
-
-
- def basic_auth(realm, users, encrypt = None):
- if check_auth(users, encrypt):
- return None
- cherrypy.response.headers['www-authenticate'] = httpauth.basicAuth(realm)
- raise cherrypy.HTTPError(401, 'You are not authorized to access that resource')
-
-
- def digest_auth(realm, users):
- if check_auth(users, realm = realm):
- return None
- cherrypy.response.headers['www-authenticate'] = httpauth.digestAuth(realm)
- raise cherrypy.HTTPError(401, 'You are not authorized to access that resource')
-
-