Back to index

moin  1.9.0~rc2
Namespaces | Classes | Functions | Variables
MoinMoin.auth Namespace Reference

Namespaces

namespace  _PHPsessionParser
namespace  botbouncer
namespace  cas
namespace  http
namespace  interwiki
namespace  log
namespace  mysql_group
namespace  openidrp
namespace  openidrp_ext
namespace  php_session
namespace  smb_mount
namespace  sslclientcert

Classes

class  LoginReturn
class  ContinueLogin
class  CancelLogin
class  MultistageFormLogin
class  MultistageRedirectLogin
class  BaseAuth
class  MoinAuth
class  GivenAuth

Functions

def get_multistage_continuation_url
def handle_login
def handle_logout
def handle_request
def setup_setuid
def setup_from_session

Variables

tuple logging = log.getLogger(__name__)

Function Documentation

def MoinMoin.auth.get_multistage_continuation_url (   request,
  auth_name,
  extra_fields = {} 
)
get_continuation_url - return a multistage continuation URL

   This function returns a URL that when loaded continues a multistage
   authentication at the auth method requesting it (parameter auth_name.)
   Additional fields are added to the URL from the extra_fields dict.

   @param request: the Moin request
   @param auth_name: name of the auth method requesting the continuation
   @param extra_fields: extra GET fields to add to the URL

Definition at line 143 of file __init__.py.

00143 
00144 def get_multistage_continuation_url(request, auth_name, extra_fields={}):
00145     """get_continuation_url - return a multistage continuation URL
00146 
00147        This function returns a URL that when loaded continues a multistage
00148        authentication at the auth method requesting it (parameter auth_name.)
00149        Additional fields are added to the URL from the extra_fields dict.
00150 
00151        @param request: the Moin request
00152        @param auth_name: name of the auth method requesting the continuation
00153        @param extra_fields: extra GET fields to add to the URL
00154     """
00155     # logically, this belongs to request, but semantically it should
00156     # live in auth so people do auth.get_multistage_continuation_url()
00157     fields = {'action': 'login',
00158               'login': '1',
00159               'stage': auth_name}
00160     fields.update(extra_fields)
00161     if request.page:
00162         logging.debug("request.page.url: " + request.page.url(request, querystr=fields))
00163         return request.page.url(request, querystr=fields)
00164     else:
00165         logging.debug("request.abs_href: " + request.abs_href(**fields))
00166         return request.abs_href(**fields)

Here is the caller graph for this function:

def MoinMoin.auth.handle_login (   request,
  userobj = None,
  username = None,
  password = None,
  attended = True,
  openid_identifier = None,
  stage = None 
)
Process a 'login' request by going through the configured authentication
methods in turn. The passable keyword arguments are explained in more
detail at the top of this file.

Definition at line 378 of file __init__.py.

00378 
00379                  attended=True, openid_identifier=None, stage=None):
00380     """
00381     Process a 'login' request by going through the configured authentication
00382     methods in turn. The passable keyword arguments are explained in more
00383     detail at the top of this file.
00384     """
00385     params = {
00386         'username': username,
00387         'password': password,
00388         'attended': attended,
00389         'openid_identifier': openid_identifier,
00390         'multistage': (stage and True) or None
00391     }
00392     for authmethod in request.cfg.auth:
00393         if stage and authmethod.name != stage:
00394             continue
00395         ret = authmethod.login(request, userobj, **params)
00396 
00397         userobj = ret.user_obj
00398         cont = ret.continue_flag
00399         if stage:
00400             stage = None
00401             del params['multistage']
00402 
00403         if ret.multistage:
00404             request._login_multistage = ret.multistage
00405             request._login_multistage_name = authmethod.name
00406             return userobj
00407 
00408         if ret.redirect_to:
00409             nextstage = auth.get_multistage_continuation_url(request, authmethod.name)
00410             url = ret.redirect_to
00411             url = url.replace('%return_form', quote_plus(nextstage))
00412             url = url.replace('%return', quote(nextstage))
00413             abort(redirect(url))
00414         msg = ret.message
00415         if msg and not msg in request._login_messages:
00416             request._login_messages.append(msg)
00417 
00418         if not cont:
00419             break
00420 
00421     return userobj

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin.auth.handle_logout (   request,
  userobj 
)
Logout the passed user from every configured authentication method. 

Definition at line 422 of file __init__.py.

00422 
00423 def handle_logout(request, userobj):
00424     """ Logout the passed user from every configured authentication method. """
00425     if userobj is None:
00426         # not logged in
00427         return userobj
00428 
00429     if userobj.auth_method == 'setuid':
00430         # we have no authmethod object for setuid
00431         userobj = request._setuid_real_user
00432         del request._setuid_real_user
00433         return userobj
00434 
00435     for authmethod in request.cfg.auth:
00436         userobj, cont = authmethod.logout(request, userobj, cookie=request.cookies)
00437         if not cont:
00438             break
00439     return userobj

def MoinMoin.auth.handle_request (   request,
  userobj 
)
Handle the per-request callbacks of the configured authentication methods. 

Definition at line 440 of file __init__.py.

00440 
00441 def handle_request(request, userobj):
00442     """ Handle the per-request callbacks of the configured authentication methods. """
00443     for authmethod in request.cfg.auth:
00444         userobj, cont = authmethod.request(request, userobj, cookie=request.cookies)
00445         if not cont:
00446             break
00447     return userobj

def MoinMoin.auth.setup_from_session (   request,
  session 
)

Definition at line 466 of file __init__.py.

00466 
00467 def setup_from_session(request, session):
00468     userobj = None
00469     if 'user.id' in session:
00470         auth_userid = session['user.id']
00471         auth_method = session['user.auth_method']
00472         auth_attrs = session['user.auth_attribs']
00473         logging.debug("got from session: %r %r" % (auth_userid, auth_method))
00474         logging.debug("current auth methods: %r" % request.cfg.auth_methods)
00475         if auth_method and auth_method in request.cfg.auth_methods:
00476             userobj = user.User(request, id=auth_userid,
00477                                 auth_method=auth_method,
00478                                 auth_attribs=auth_attrs)
00479     logging.debug("session started for user %r", userobj)
00480     return userobj
00481 
def MoinMoin.auth.setup_setuid (   request,
  userobj 
)
Check for setuid conditions in the session and setup an user
object accordingly. Returns a tuple of the new user objects.

@param request: a moin request object
@param userobj: a moin user object
@rtype: boolean
@return: (new_user, user) or (user, None)

Definition at line 448 of file __init__.py.

00448 
00449 def setup_setuid(request, userobj):
00450     """ Check for setuid conditions in the session and setup an user
00451     object accordingly. Returns a tuple of the new user objects.
00452 
00453     @param request: a moin request object
00454     @param userobj: a moin user object
00455     @rtype: boolean
00456     @return: (new_user, user) or (user, None)
00457     """
00458     old_user = None
00459     if 'setuid' in request.session and userobj and userobj.isSuperUser():
00460         old_user = userobj
00461         uid = request.session['setuid']
00462         userobj = user.User(request, uid, auth_method='setuid')
00463         userobj.valid = True
00464     logging.debug("setup_suid returns %r, %r" % (userobj, old_user))
00465     return (userobj, old_user)


Variable Documentation

Definition at line 138 of file __init__.py.