Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes | Static Public Attributes
MoinMoin.auth.mysql_group.MysqlGroupAuth Class Reference
Inheritance diagram for MoinMoin.auth.mysql_group.MysqlGroupAuth:
Inheritance graph
[legend]
Collaboration diagram for MoinMoin.auth.mysql_group.MysqlGroupAuth:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def login
def request
def logout
def login_hint

Public Attributes

 mysql_group_query
 host
 user
 passwd
 dbname

Static Public Attributes

 name = None
list login_inputs = []
 logout_possible = False

Detailed Description

Authorize via MySQL group DB.

We require an already-authenticated user_obj and
check that the user is part of an authorized group.

Definition at line 18 of file mysql_group.py.


Constructor & Destructor Documentation

def MoinMoin.auth.mysql_group.MysqlGroupAuth.__init__ (   self,
  host,
  user,
  passwd,
  dbname,
  query 
)

Definition at line 24 of file mysql_group.py.

00024 
00025     def __init__(self, host, user, passwd, dbname, query):
00026         BaseAuth.__init__(self)
00027         self.mysql_group_query = query
00028         self.host = host
00029         self.user = user
00030         self.passwd = passwd
00031         self.dbname = dbname


Member Function Documentation

def MoinMoin.auth.mysql_group.MysqlGroupAuth.login (   self,
  request,
  user_obj,
  kw 
)

Reimplemented from MoinMoin.auth.BaseAuth.

Definition at line 32 of file mysql_group.py.

00032 
00033     def login(self, request, user_obj, **kw):
00034         _ = request.getText
00035 
00036         logging.debug("got: user_obj=%r" % user_obj)
00037 
00038         if not (user_obj and user_obj.valid):
00039             # No other method succeeded, so we cannot authorize
00040             # but maybe some following auth methods can still "fix" that.
00041             logging.debug("did not get valid user from previous auth method")
00042             return ContinueLogin(user_obj)
00043 
00044         # Got a valid user object - we can do stuff!
00045         logging.debug("got valid user (name=%r) from previous auth method" % user_obj.auth_username)
00046 
00047         # XXX Check auth_username for dodgy chars (should be none as it is authenticated, but...)
00048         # shouldn't really be necessary since execute() quotes them all...
00049 
00050         # OK, now check mysql!
00051         try:
00052             m = MySQLdb.connect(host=self.host, user=self.user,
00053                                 passwd=self.passwd, db=self.dbname)
00054         except:
00055             logging.exception("authorization failed due to exception when connecting to DB, traceback follows...")
00056             return CancelLogin(_('Failed to connect to database.'))
00057 
00058         c = m.cursor()
00059         c.execute(self.mysql_group_query, user_obj.auth_username)
00060         results = c.fetchall()
00061         if results:
00062             # Checked out OK
00063             logging.debug("got %d results -- authorized!" % len(results))
00064             return ContinueLogin(user_obj)
00065         else:
00066             logging.debug("did not get match from DB -- not authorized")
00067             return CancelLogin(_("Invalid username or password."))

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 MoinMoin.auth.mysql_group.MysqlGroupAuth.request (   self,
  request,
  user_obj,
  kw 
)

Reimplemented from MoinMoin.auth.BaseAuth.

Definition at line 70 of file mysql_group.py.

00070 
00071     def request(self, request, user_obj, **kw):
00072         retval = self.login(request, user_obj, **kw)
00073         return retval.user_obj, retval.continue_flag
00074 

Here is the call graph for this function:


Member Data Documentation

Definition at line 30 of file mysql_group.py.

Definition at line 27 of file mysql_group.py.

list MoinMoin.auth.BaseAuth.login_inputs = [] [static, inherited]
MoinMoin.auth.BaseAuth.logout_possible = False [static, inherited]

Definition at line 26 of file mysql_group.py.

MoinMoin.auth.BaseAuth.name = None [static, inherited]

Definition at line 29 of file mysql_group.py.

Definition at line 28 of file mysql_group.py.


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