Example #1
0
def ask_for_http_auth(callback, url, auth_header, location):
    # call decode_auth_header, which will raise ValueError if auth_header is
    # invalid
    decode_auth_header(auth_header)
    id_ = requestIdGenerator.next()
    waitingHTTPAuthCallbacks[id_] = callback
    from miro.dl_daemon import daemon
    c = command.AskForHTTPAuthCommand(daemon.LAST_DAEMON, id_, url,
            auth_header, location)
    c.send()
Example #2
0
def ask_for_http_auth(callback, url, auth_header, location):
    # call decode_auth_header, which will raise ValueError or
    # AssertionError if auth_header is invalid
    decode_auth_header(auth_header)
    id_ = requestIdGenerator.next()
    waitingHTTPAuthCallbacks[id_] = callback
    from miro.dl_daemon import daemon
    c = command.AskForHTTPAuthCommand(daemon.LAST_DAEMON, id_, url,
                                      auth_header, location)
    c.send()
Example #3
0
    def test_valid_digest(self):
        ret = decode_auth_header(
            'Digest realm="atlanta.com",domain="sip:boxesbybob.com", '
            'qop="auth", nonce="f84f1cec41e6cbe5aea9c8e88d359", '
            'opaque="", stale=FALSE, algorithm=MD5')
        self.assertEquals(ret, ("digest", "atlanta.com", "sip:boxesbybob.com"))

        ret = decode_auth_header(
            'Digest realm="*****@*****.**", qop="auth,auth-int", '
            'nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093", '
            'opaque="5ccc069c403ebaf9f0171e9517f40e41"')
        self.assertEquals(ret, ("digest", "*****@*****.**", None))
    def test_valid_digest(self):
        ret = decode_auth_header(
            'Digest realm="atlanta.com",domain="sip:boxesbybob.com", '
            'qop="auth", nonce="f84f1cec41e6cbe5aea9c8e88d359", '
            'opaque="", stale=FALSE, algorithm=MD5')
        self.assertEquals(ret, ("digest", "atlanta.com", "sip:boxesbybob.com"))

        ret = decode_auth_header(
            'Digest realm="*****@*****.**", qop="auth,auth-int", '
            'nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093", '
            'opaque="5ccc069c403ebaf9f0171e9517f40e41"')
        self.assertEquals(ret, ("digest", "*****@*****.**", None))
Example #5
0
def find_http_auth(url, auth_header=None):
    global password_list
    if auth_header is not None:
        auth_scheme, realm, domain = decode_auth_header(auth_header)
    else:
        realm = None
    return password_list.find(url, realm)
Example #6
0
def find_http_auth(url, auth_header=None):
    global password_list
    try:
        if auth_header is not None:
            auth_scheme, realm, domain = decode_auth_header(auth_header)
        else:
            realm = None
    except (AssertionError, ValueError):
        # auth_header is malformed, so use a None realm
        realm = None

    return password_list.find(url, realm)
Example #7
0
def find_http_auth(url, auth_header=None):
    global password_list
    try:
        if auth_header is not None:
            auth_scheme, realm, domain = decode_auth_header(auth_header)
        else:
            realm = None
    except (AssertionError, ValueError):
        # auth_header is malformed, so use a None realm
        realm = None

    return password_list.find(url, realm)
Example #8
0
def find_http_auth(url, auth_header=None):
    """Find an HTTPAuthPassword object stored in the passwords database.

    This method searches the database for already entered passwords.  It
    will find a string to use for the Authorization header or None.

    :param url: request URL
    :param auth_header: optional www-authenticate header to use to search for.
        This allows us to better match basic auth passwords
    """
    global password_list
    if auth_header is not None:
        auth_scheme, realm, domain = decode_auth_header(auth_header)
    else:
        realm = None
    return password_list.find(url, realm)
Example #9
0
def find_http_auth(url, auth_header=None):
    """Find an HTTPAuthPassword object stored in the passwords database.

    This method searches the database for already entered passwords.  It
    will find a string to use for the Authorization header or None.

    :param url: request URL
    :param auth_header: optional www-authenticate header to use to search for.
        This allows us to better match basic auth passwords

    :returns: HTTPAuthPassword
    """
    global password_list
    try:
        if auth_header is not None:
            auth_scheme, realm, domain = decode_auth_header(auth_header)
        else:
            realm = None
    except (AssertionError, ValueError):
        # auth_header is malformed, so use a None realm.
        realm = None
    return password_list.find(url, realm)
Example #10
0
def ask_for_http_auth(callback, url, auth_header, location):
    """Ask the user for a username and password to login to a site.

    :param callback: will be called with a HTTPAuthPassword to use, or None
    :param url: URL for the request
    :param auth_header: www-authenticate header we got from the server
    :param location: human readable text of what's requesting authorization
    """
    global password_list

    auth_scheme, realm, domain = decode_auth_header(auth_header)

    def handle_login_response(dialog):
        if dialog.choice == dialogs.BUTTON_OK:
            callback_tracker.run_callbacks(url, realm, dialog.username,
                                           dialog.password, auth_header)
        else:
            callback_tracker.run_canceled_callbacks(url, realm)

    run_dialog = (not callback_tracker.has_callback(url, realm))
    callback_tracker.add_callback(callback, url, realm)
    if run_dialog:
        dialogs.HTTPAuthDialog(location, realm).run(handle_login_response)
Example #11
0
def ask_for_http_auth(callback, url, auth_header, location):
    """Ask the user for a username and password to login to a site.

    :param callback: will be called with a HTTPAuthPassword to use, or None
    :param url: URL for the request
    :param auth_header: www-authenticate header we got from the server
    :param location: human readable text of what's requesting authorization
    """
    global password_list

    auth_scheme, realm, domain = decode_auth_header(auth_header)

    def handle_login_response(dialog):
        if dialog.choice == dialogs.BUTTON_OK:
            callback_tracker.run_callbacks(url, realm, dialog.username,
                    dialog.password, auth_header)
        else:
            callback_tracker.run_canceled_callbacks(url, realm)

    run_dialog = (not callback_tracker.has_callback(url, realm))
    callback_tracker.add_callback(callback, url, realm)
    if run_dialog:
        dialogs.HTTPAuthDialog(location, realm).run(handle_login_response)
Example #12
0
 def test_valid_basic(self):
     for header, decoded in (
         ('Basic realm="secure"', ("basic", "secure", None)),
         ('Basic realm="r w s"', ("basic", "r w s", None)),
     ):
         self.assertEquals(decode_auth_header(header), decoded)
 def test_valid_basic(self):
     for header, decoded in (
         ('Basic realm="secure"', ("basic", "secure", None)),
         ('Basic realm="r w s"', ("basic", "r w s", None)),
         ):
         self.assertEquals(decode_auth_header(header), decoded)