def handle_basic(req, user, password):
    '''Handle a request authenticated using the Basic Access Authentication
    mechanism (RFC2617).
    '''
    req.log_error('Handling Basic Access Authentication for URI %s' % (req.unparsed_uri))

    domain = req.get_options().get('Domain', req.auth_name())
    client = NTLM_Client(user, domain, password)
    type1 = client.make_ntlm_negotiate()

    try:
        (proxy, type2) = connect_to_proxy(req, type1)
    except Exception, e:
        return apache.HTTP_INTERNAL_SERVER_ERROR
    
    client.parse_ntlm_challenge(type2)
    type3 = client.make_ntlm_authenticate()
    if not proxy.authenticate(type3):
        proxy.close()
        req.log_error('PYNTLM: User %s/%s failed Basic authentication for URI %s' % (
            user,domain,req.unparsed_uri))
        return handle_unauthorized(req)
    
    req.log_error('PYNTLM: User %s/%s has been authenticated (Basic) to access URI %s' % (user,domain,req.unparsed_uri), apache.APLOG_NOTICE)
    set_remote_user(req, user, domain)
    result = check_authorization(req, user, proxy)
    proxy.close()

    if not result:
        return apache.HTTP_FORBIDDEN

    req.connection.notes.add('BASIC_AUTHORIZED', user+password)
    return apache.OK
dataset/ETHPy150Open Legrandin/PyAuthenNTLM2/pyntlm.py/handle_basic/original