Ticket #59: authKitOpenId.patch

  • authkit/authenticate/cookie.py

    old new  
    372372            environ['REMOTE_USER'] = userid 
    373373            if environ.get('REMOTE_USER_TOKENS'): 
    374374                # We want to add tokens/roles to what's there: 
    375                 tokens = environ['REMOTE_USER_TOKENS'] + ',' + tokens 
     375                tokens = str(environ['REMOTE_USER_TOKENS']) + ',' + str(tokens) 
    376376            environ['REMOTE_USER_TOKENS'] = tokens 
    377377            environ['REMOTE_USER_DATA'] = user_data 
    378378            environ['AUTH_TYPE'] = 'cookie' 
  • authkit/authenticate/multi.py

    old new  
    4040                    log.debug("Multi: No binding was found for the check") 
    4141                    # XXX Shouldn't this be returning the writable to the application? 
    4242                    writable = start_response( 
    43                         status_[0],  
    44                         headers_ and headers_[0] or [], 
    45                         exc_info_[0
     43                        status_[-1],  
     44                        headers_ and headers_[-1] or [], 
     45                        exc_info_[-1
    4646                    ) 
    4747                    return writable 
    4848                else: 
     
    7373                if not len(headers_): 
    7474                    raise Exception('No headers were returned by the ' 
    7575                                    'application') 
    76                 if checker(environ, status_[0], headers_ and headers_[0] or []): 
     76                if checker(environ, status_[-1], headers_ and headers_[-1] or []): 
    7777                    log.debug( 
    7878                        "MultiMiddleware self.checker check() returning %r",  
    7979                        binding 
     
    8585        app_iter = app(environ, start_response) 
    8686        if not result_: 
    8787            raise Exception('Invalid WSGI response, did the application return an iterable?') 
    88         if result_[0] is None: 
     88        if result_[-1] is None: 
    8989            # The check failed and the initial app should be used. 
    9090            return app_iter 
    9191        else: 
    9292            # Close the unused app which we don't want 
    9393            if hasattr(app_iter, 'close'): 
    9494                app_iter.close() 
    95             return result_[0
     95            return result_[-1
    9696 
    9797def status_checker(environ, status, headers): 
    9898    """ 
  • authkit/authenticate/open_id.py

    old new  
    372372            username = info.identity_url 
    373373            if info.endpoint.canonicalID: 
    374374                username = cgi.escape(info.endpoint.canonicalID) 
    375             user_data = str(sreg.SRegResponse.fromSuccessResponse(info).getExtensionArgs()) 
     375            sreg_info = sreg.SRegResponse.fromSuccessResponse(info) 
     376            if sreg_info: 
     377              user_data = str(sreg.SRegResponse.fromSuccessResponse(info).getExtensionArgs()) 
     378            else: 
     379              user_data = "" 
    376380            # Set the cookie 
    377381            if self.urltouser: 
    378382                username = self.urltouser(environ, info.identity_url) 
     
    464468            sreg_required=options['sreg_required'], 
    465469            sreg_optional=options['sreg_optional'], 
    466470            sreg_policyurl=options['sreg_policyurl'], 
     471            session_middleware=options['session_middleware'] 
    467472        ) 
    468473        self.app = app 
    469474 
     
    502507        'sreg_required': auth_conf.get('sreg.required'), 
    503508        'sreg_optional': auth_conf.get('sreg.optional'), 
    504509        'sreg_policyurl': auth_conf.get('sreg.policyurl'), 
    505         'session_middleware': 'beaker.session'
     510        'session_middleware': auth_conf.get('session.middleware','beaker.session')
    506511    } 
    507512    auth_handler_params={ 
    508513        'template':user_setter_params['template'], 
     
    510515        'baseurl':user_setter_params['baseurl'], 
    511516        'charset':user_setter_params['charset'], 
    512517    } 
     518    authenticate_conf = strip_base(auth_conf, 'authenticate.') 
     519    app, authfunc, users = get_authenticate_function( 
     520        app,  
     521        authenticate_conf,  
     522        prefix=prefix+'authenticate.',  
     523        format='basic' 
     524    ) 
    513525    return app, auth_handler_params, user_setter_params 
    514526     
    515527def make_passurl_handler(