Changeset 135040 in webkit


Ignore:
Timestamp:
Nov 17, 2012, 12:03:32 AM (13 years ago)
Author:
Martin Robinson
Message:

[Soup] CredentialStorage should only be used for HTTP-family requests
https://bugs.webkit.org/show_bug.cgi?id=102582

Reviewed by Gustavo Noronha Silva.

Do not use CredentialStorage when handling non-HTTP family requests. CredentialStorage
only expects to handle requests in the HTTP family.

No new tests. This is covered by existing tests.

  • platform/network/ResourceHandle.h:

(ResourceHandle): Add a shouldUseCredentialStorage helper to ResourceHandle. This
helper returns false when firstRequest() is a non-HTTP family request.

  • platform/network/soup/ResourceHandleSoup.cpp:

(WebCore::applyAuthenticationToRequest): Use the new helper.
(WebCore::createSoupRequestAndMessageForHandle): Ditto.
(WebCore::ResourceHandle::start): Ditto.
(WebCore::ResourceHandle::shouldUseCredentialStorage): Ditto.
(WebCore::ResourceHandle::didReceiveAuthenticationChallenge): Ditto.
(WebCore::ResourceHandle::receivedCredential): Ditto.

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r135039 r135040  
     12012-11-17  Martin Robinson  <mrobinson@igalia.com>
     2
     3        [Soup] CredentialStorage should only be used for HTTP-family requests
     4        https://bugs.webkit.org/show_bug.cgi?id=102582
     5
     6        Reviewed by Gustavo Noronha Silva.
     7
     8        Do not use CredentialStorage when handling non-HTTP family requests. CredentialStorage
     9        only expects to handle requests in the HTTP family.
     10
     11        No new tests. This is covered by existing tests.
     12
     13        * platform/network/ResourceHandle.h:
     14        (ResourceHandle): Add a shouldUseCredentialStorage helper to ResourceHandle. This
     15        helper returns false when firstRequest() is a non-HTTP family request.
     16        * platform/network/soup/ResourceHandleSoup.cpp:
     17        (WebCore::applyAuthenticationToRequest): Use the new helper.
     18        (WebCore::createSoupRequestAndMessageForHandle): Ditto.
     19        (WebCore::ResourceHandle::start): Ditto.
     20        (WebCore::ResourceHandle::shouldUseCredentialStorage): Ditto.
     21        (WebCore::ResourceHandle::didReceiveAuthenticationChallenge): Ditto.
     22        (WebCore::ResourceHandle::receivedCredential): Ditto.
     23
    1242012-11-16  Patrick Gansterer  <paroga@webkit.org>
    225
  • trunk/Source/WebCore/platform/network/ResourceHandle.h

    r134960 r135040  
    170170    void continueDidReceiveAuthenticationChallenge(const Credential& credentialFromPersistentStorage);
    171171    void sendPendingRequest();
     172    bool shouldUseCredentialStorage();
    172173    static SoupSession* defaultSession();
    173174    static uint64_t getSoupRequestInitiaingPageID(SoupRequest*);
  • trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp

    r134971 r135040  
    328328
    329329    ResourceRequest& request = d->m_firstRequest;
    330     if (!handle->client() || handle->client()->shouldUseCredentialStorage(handle)) {
     330    if (handle->shouldUseCredentialStorage()) {
    331331        if (d->m_user.isEmpty() && d->m_pass.isEmpty())
    332332            d->m_initialCredential = CredentialStorage::get(request.url());
     
    913913}
    914914
     915bool ResourceHandle::shouldUseCredentialStorage()
     916{
     917    return (!client() || client()->shouldUseCredentialStorage(this)) && firstRequest().url().protocolIsInHTTPFamily();
     918}
     919
    915920void ResourceHandle::setHostAllowsAnyHTTPSCertificate(const String& host)
    916921{
     
    960965    ASSERT(d->m_currentWebChallenge.isNull());
    961966
    962     bool shouldUseCredentialStorage = !client() || client()->shouldUseCredentialStorage(this);
     967    bool useCredentialStorage = shouldUseCredentialStorage();
    963968    if (!d->m_user.isNull() && !d->m_pass.isNull()) {
    964969        Credential credential = Credential(d->m_user, d->m_pass, CredentialPersistenceForSession);
    965         if (shouldUseCredentialStorage)
     970        if (useCredentialStorage)
    966971            CredentialStorage::set(credential, challenge.protectionSpace(), challenge.failureResponse().url());
    967972        soup_auth_authenticate(challenge.soupAuth(), credential.user().utf8().data(), credential.password().utf8().data());
     
    971976
    972977    // FIXME: Per the specification, the user shouldn't be asked for credentials if there were incorrect ones provided explicitly.
    973     if (shouldUseCredentialStorage) {
     978    if (useCredentialStorage) {
    974979        if (!d->m_initialCredential.isEmpty() || challenge.previousFailureCount()) {
    975980            // The stored credential wasn't accepted, stop using it. There is a race condition
     
    10021007    // use HTTP authentication. In the end, this doesn't matter much, because persistent credentials
    10031008    // will become session credentials after the first use.
    1004     if (shouldUseCredentialStorage) {
     1009    if (useCredentialStorage) {
    10051010        credentialBackingStore().credentialForChallenge(challenge, getCredentialFromPersistentStoreCallback, this);
    10061011        return;
     
    10331038    }
    10341039
    1035     // Eventually we will manage per-session credentials only internally or use some newly-exposed API from libsoup,
    1036     // because once we authenticate via libsoup, there is no way to ignore it for a particular request. Right now,
    1037     // we place the credentials in the store even though libsoup will never fire the authenticate signal again for
    1038     // this protection space.
    1039     if (credential.persistence() == CredentialPersistenceForSession || credential.persistence() == CredentialPersistencePermanent)
    1040         CredentialStorage::set(credential, challenge.protectionSpace(), challenge.failureResponse().url());
     1040    if (shouldUseCredentialStorage()) {
     1041        // Eventually we will manage per-session credentials only internally or use some newly-exposed API from libsoup,
     1042        // because once we authenticate via libsoup, there is no way to ignore it for a particular request. Right now,
     1043        // we place the credentials in the store even though libsoup will never fire the authenticate signal again for
     1044        // this protection space.
     1045        if (credential.persistence() == CredentialPersistenceForSession || credential.persistence() == CredentialPersistencePermanent)
     1046            CredentialStorage::set(credential, challenge.protectionSpace(), challenge.failureResponse().url());
    10411047
    10421048#if PLATFORM(GTK)
    1043     if (credential.persistence() == CredentialPersistencePermanent) {
    1044         d->m_credentialDataToSaveInPersistentStore.credential = credential;
    1045         d->m_credentialDataToSaveInPersistentStore.challenge = challenge;
    1046     }
    1047 #endif
     1049        if (credential.persistence() == CredentialPersistencePermanent) {
     1050            d->m_credentialDataToSaveInPersistentStore.credential = credential;
     1051            d->m_credentialDataToSaveInPersistentStore.challenge = challenge;
     1052        }
     1053#endif
     1054    }
    10481055
    10491056    ASSERT(challenge.soupSession());
Note: See TracChangeset for help on using the changeset viewer.