Back to index

moin  1.9.0~rc2
Public Member Functions | Static Public Attributes
wikiconfig.ExternalCookie Class Reference
Inheritance diagram for wikiconfig.ExternalCookie:
Inheritance graph
[legend]
Collaboration diagram for wikiconfig.ExternalCookie:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def request
def login
def logout
def login_hint

Static Public Attributes

string name = 'external_cookie'
list login_inputs = []
 logout_possible = False

Detailed Description

Definition at line 11 of file wikiconfig.py.


Member Function Documentation

def MoinMoin.auth.BaseAuth.login (   self,
  request,
  user_obj,
  kw 
) [inherited]
def MoinMoin.auth.BaseAuth.login_hint (   self,
  request 
) [inherited]

Reimplemented in MoinMoin.auth.openidrp.OpenIDAuth, and MoinMoin.auth.MoinAuth.

Definition at line 213 of file __init__.py.

00213 
00214     def login_hint(self, request):
00215         return None

def MoinMoin.auth.BaseAuth.logout (   self,
  request,
  user_obj,
  kw 
) [inherited]

Reimplemented in MoinMoin.auth.cas.CASAuth, MoinMoin.auth.smb_mount.SMBMount, and MoinMoin.auth.log.AuthLog.

Definition at line 208 of file __init__.py.

00208 
00209     def logout(self, request, user_obj, **kw):
00210         if self.name and user_obj and user_obj.auth_method == self.name:
00211             logging.debug("%s: logout - invalidating user %r" % (self.name, user_obj.name))
00212             user_obj.valid = False
        return user_obj, True
def wikiconfig.ExternalCookie.request (   self,
  request,
  user_obj,
  kw 
)
authenticate via external cookie 

Reimplemented from MoinMoin.auth.BaseAuth.

Definition at line 14 of file wikiconfig.py.

00014 
00015     def request(self, request, user_obj, **kw):
00016         """ authenticate via external cookie """
00017         import Cookie
00018         user = None
00019         try_next = True # if True, moin tries the next auth method
00020         cookiename = "whatever" # +++ external cookie name you want to use
00021 
00022         try:
00023             cookie = Cookie.SimpleCookie(request.saved_cookie)
00024         except Cookie.CookieError:
00025             # ignore invalid cookies
00026             cookie = None
00027         if cookie and cookiename in cookie:
00028             import urllib
00029             cookievalue = cookie[cookiename].value
00030             # +++ now we decode and parse the cookie value - edit this to fit your needs.
00031             # the minimum we need to get is auth_username. aliasname and email is optional.
00032             cookievalue = urllib.unquote(cookievalue) # cookie value is urlencoded, decode it
00033             cookievalue = cookievalue.decode('iso-8859-1') # decode cookie charset to unicode
00034             cookievalue = cookievalue.split('#') # cookie has format loginname#firstname#lastname#email
00035 
00036             auth_username = cookievalue[0] # having this cookie means user auth has already been done!
00037             aliasname = email = ''
00038             try:
00039                 aliasname = "%s %s" % (cookievalue[1], cookievalue[2]) # aliasname is for cosmetical stuff only
00040                 email = cookievalue[3]
00041             except IndexError: # +++ this is for debugging it, in case it does not work
00042                 if 0:
00043                     f = open("cookie.log", "w")
00044                     f.write(repr(cookie))
00045                     f.write(repr(cookievalue))
00046                     f.close()
00047                 pass
00048 
00049             from MoinMoin.user import User
00050             # giving auth_username to User constructor means that authentication has already been done.
00051             user = User(request, name=auth_username, auth_username=auth_username, auth_method=self.name)
00052 
00053             changed = False
00054             if aliasname != user.aliasname: # was the aliasname externally updated?
00055                 user.aliasname = aliasname
00056                 changed = True # yes -> update user profile
00057             if email != user.email: # was the email addr externally updated?
00058                 user.email = email
00059                 changed = True # yes -> update user profile
00060 
00061             if user:
00062                 user.create_or_update(changed)
00063             if user and user.valid: # did we succeed making up a valid user?
00064                 try_next = False # stop processing auth method list
00065         return user, try_next


Member Data Documentation

list MoinMoin.auth.BaseAuth.login_inputs = [] [static, inherited]
MoinMoin.auth.BaseAuth.logout_possible = False [static, inherited]
string wikiconfig.ExternalCookie.name = 'external_cookie' [static]

Reimplemented from MoinMoin.auth.BaseAuth.

Definition at line 12 of file wikiconfig.py.


The documentation for this class was generated from the following file: