diff options
author | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2010-02-02 20:48:41 -0500 |
---|---|---|
committer | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2010-02-02 20:48:41 -0500 |
commit | 955f0853655cd499a12f69ca35768802ddbbac38 (patch) | |
tree | dee4116cbd68064d4d314f913daaaeba748ac90a /mediawiki/auth.py | |
parent | c269397bbc0f9716fa47ddb311cdd37d3954859d (diff) | |
download | askbot-955f0853655cd499a12f69ca35768802ddbbac38.tar.gz askbot-955f0853655cd499a12f69ca35768802ddbbac38.tar.bz2 askbot-955f0853655cd499a12f69ca35768802ddbbac38.zip |
remove experimental and unused files, small cleanups
Diffstat (limited to 'mediawiki/auth.py')
-rw-r--r-- | mediawiki/auth.py | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/mediawiki/auth.py b/mediawiki/auth.py deleted file mode 100644 index ee367dc1..00000000 --- a/mediawiki/auth.py +++ /dev/null @@ -1,59 +0,0 @@ -from mediawiki.models import User as MWUser -from django.contrib.auth.models import User -from django_authopenid.models import ExternalLoginData -from django.conf import settings -import logging -from PHPUnserialize import PHPUnserialize -import os - -class php(object): - @staticmethod - def get_session_data(session): - prefix = settings.MEDIAWIKI_PHP_SESSION_PREFIX - path = settings.MEDIAWIKI_PHP_SESSION_PATH - file = os.path.join(path,prefix + session) - #file may not exist - data = open(file).read() - u = PHPUnserialize() - return u.session_decode(data) - -class IncludeVirtualAuthenticationBackend(object): - def authenticate(self,token=None): - logging.debug('authenticating session %s' % token) - try: - php_session = php.get_session_data(token) - #todo: report technical errors to root - except: - #Fail condition 1. Session data cannot be retrieved - logging.debug('session %s cannot be retrieved' % str(token)) - return None - try: - name = php_session['wsUserName'] - id = php_session['wsUserID'] - except: - #Fail condition 2. Data misses keys - logging.debug('missing data in session table') - return None - try: - logging.debug('trying to find user %s id=%s in the MW database' % (name,id)) - wu = MWUser.objects.get(user_name=name,user_id=id) - except MWUser.DoesNotExist: - #Fail condition 3. User does not match session data - logging.debug('could not find wiki user who owns session') - return None - try: - logging.debug('trying to get external login data for mw user %s' % name) - eld = ExternalLoginData.objects.get(external_username=name) - #update session data and save? - return eld.user #may be none! - except ExternalLoginData.DoesNotExist: - #Fail condition 4. no external login data - user never logged in through django - #using the wiki login and password - logging.debug('no association found for MW user %s with django user' % name) - return None - - def get_user(self, user_id): - try: - return User.objects.get(pk=user_id) - except User.DoesNotExist: - return None |