diff options
| author | Carlos Garcia Campos <cgarcia@igalia.com> | 2020-10-27 12:20:42 +0100 |
|---|---|---|
| committer | Carlos Garcia Campos <cgarcia@igalia.com> | 2020-10-28 09:46:21 +0100 |
| commit | ca5c1c949236fda07aec953a4a9cac61b2e94efe (patch) | |
| tree | b432b770f59e8eb2ec9588e6ccc4ec54c8cae14a /libsoup/auth | |
| parent | 8a918ee3cd75def6f9c1a6bdcb1008e99684ec6b (diff) | |
| download | libsoup-ca5c1c949236fda07aec953a4a9cac61b2e94efe.tar.gz | |
auth: set the proxy host on SoupAuth instead of the requested one
In case of proxy auth, the host being authenticated is the proxy one.
Fixes #105
Diffstat (limited to 'libsoup/auth')
| -rw-r--r-- | libsoup/auth/soup-auth-manager.c | 18 | ||||
| -rw-r--r-- | libsoup/auth/soup-auth.c | 8 |
2 files changed, 16 insertions, 10 deletions
diff --git a/libsoup/auth/soup-auth-manager.c b/libsoup/auth/soup-auth-manager.c index 2af4a0b5..afe6be48 100644 --- a/libsoup/auth/soup-auth-manager.c +++ b/libsoup/auth/soup-auth-manager.c @@ -460,6 +460,7 @@ lookup_auth (SoupAuthManagerPrivate *priv, SoupMessage *msg) SoupAuthHost *host; const char *path, *realm; SoupAuth *auth; + SoupURI *uri; /* If the message already has a ready auth, use that instead */ auth = soup_message_get_auth (msg); @@ -469,7 +470,11 @@ lookup_auth (SoupAuthManagerPrivate *priv, SoupMessage *msg) if (soup_message_get_flags (msg) & SOUP_MESSAGE_DO_NOT_USE_AUTH_CACHE) return NULL; - host = get_auth_host_for_uri (priv, soup_message_get_uri (msg)); + uri = soup_message_get_uri_for_auth (msg); + if (!uri) + return NULL; + + host = get_auth_host_for_uri (priv, uri); if (!host->auth_realms && !make_auto_ntlm_auth (priv, host)) return NULL; @@ -481,7 +486,7 @@ lookup_auth (SoupAuthManagerPrivate *priv, SoupMessage *msg) if (!host->auth_realms) return NULL; - path = soup_message_get_uri (msg)->path; + path = uri->path; if (!path) path = "/"; realm = soup_path_map_lookup (host->auth_realms, path); @@ -533,12 +538,7 @@ authenticate_auth (SoupAuthManager *manager, SoupAuth *auth, if (!soup_auth_can_authenticate (auth)) return; - if (proxy) { - uri = soup_session_get_message_proxy_uri (priv->session, msg); - if (!uri) - return; - } else - uri = soup_message_get_uri (msg); + uri = soup_message_get_uri_for_auth (msg); /* If a password is specified explicitly in the URI, use it * even if the auth had previously already been authenticated. @@ -645,7 +645,7 @@ auth_got_headers (SoupMessage *msg, gpointer manager) if (!(soup_message_get_flags (msg) & SOUP_MESSAGE_DO_NOT_USE_AUTH_CACHE)) { SoupAuth *new_auth; - new_auth = record_auth_for_uri (priv, soup_message_get_uri (msg), + new_auth = record_auth_for_uri (priv, soup_message_get_uri_for_auth (msg), auth, prior_auth_failed); g_object_unref (auth); auth = g_object_ref (new_auth); diff --git a/libsoup/auth/soup-auth.c b/libsoup/auth/soup-auth.c index 62d0a677..9295400c 100644 --- a/libsoup/auth/soup-auth.c +++ b/libsoup/auth/soup-auth.c @@ -14,6 +14,7 @@ #include "soup-auth.h" #include "soup.h" #include "soup-connection-auth.h" +#include "soup-message-private.h" /** * SECTION:soup-auth @@ -262,14 +263,19 @@ soup_auth_new (GType type, SoupMessage *msg, const char *auth_header) SoupAuth *auth; GHashTable *params; const char *scheme; + SoupURI *uri; g_return_val_if_fail (g_type_is_a (type, SOUP_TYPE_AUTH), NULL); g_return_val_if_fail (SOUP_IS_MESSAGE (msg), NULL); g_return_val_if_fail (auth_header != NULL, NULL); + uri = soup_message_get_uri_for_auth (msg); + if (!uri) + return NULL; + auth = g_object_new (type, "is-for-proxy", (msg->status_code == SOUP_STATUS_PROXY_UNAUTHORIZED), - "host", soup_message_get_uri (msg)->host, + "host", uri->host, NULL); SoupAuthPrivate *priv = soup_auth_get_instance_private (auth); |
