Re: [evolution-patches] soup auth patch
- From: Joe Shaw <joe ximian com>
- To: Dan Winship <danw ximian com>
- Cc: evolution-patches ximian com
- Subject: Re: [evolution-patches] soup auth patch
- Date: 08 Aug 2003 16:16:37 -0400
On Thu, 2003-08-07 at 14:42, Dan Winship wrote:
> This fixes soup's auth handling, almost completely. I did it because I
> wanted to fix 43332, 46724, 46725 and one other bug not in bugzilla, but
> this patch actually fixes a lot more than that, because I already had a
> lot of the logic (and the regression test) on the soup-refactoring
> branch, and if I was going to fix a lot of things, I figured I might as
> well fix everything.
>
> Um... ok, so yes, it's a big patch. But it has a regression test! (And
> I'm running connector with it now.)
Looks good. Needs one change:
> Index: libsoup/soup-auth.c
> ===================================================================
> RCS file: /cvs/gnome/libsoup/libsoup/soup-auth.c,v
> retrieving revision 1.21
> diff -u -w -r1.21 soup-auth.c
> --- libsoup/soup-auth.c 29 Jul 2003 15:04:01 -0000 1.21
> +++ libsoup/soup-auth.c 7 Aug 2003 18:24:22 -0000
> @@ -62,6 +62,21 @@
> soup_header_param_destroy_hash (tokens);
> }
>
> +static GSList *
> +basic_pspace_func (SoupAuth *auth, const SoupUri *source_uri)
> +{
> + char *space, *p;
> +
> + space = g_strdup (source_uri->path);
> +
> + /* Strip query and filename component */
> + p = strrchr (space, '/');
> + if (p && p != space && p[1])
> + *p = '\0';
> +
> + return g_slist_prepend (NULL, space);
> +}
> +
> static void
> basic_init_func (SoupAuth *auth, const SoupUri *uri)
> {
> @@ -71,6 +86,20 @@
> user_pass = g_strdup_printf ("%s:%s", uri->user, uri->passwd);
> basic->token = soup_base64_encode (user_pass, strlen (user_pass));
> g_free (user_pass);
> +
> + auth->authenticated = TRUE;
> +}
> +
> +static gboolean
> +basic_invalidate_func (SoupAuth *auth)
> +{
> + SoupAuthBasic *basic = (SoupAuthBasic *) auth;
> +
> + g_free (basic->token);
> + basic->token = NULL;
> + auth->authenticated = FALSE;
> +
> + return TRUE;
> }
>
> static void
> @@ -91,9 +120,12 @@
> basic = g_new0 (SoupAuthBasic, 1);
> auth = (SoupAuth *) basic;
> auth->type = SOUP_AUTH_TYPE_BASIC;
> + auth->authenticated = FALSE;
>
> auth->parse_func = basic_parse_func;
> auth->init_func = basic_init_func;
> + auth->invalidate_func = basic_invalidate_func;
> + auth->pspace_func = basic_pspace_func;
> auth->auth_func = basic_auth_func;
> auth->free_func = basic_free;
>
> @@ -126,6 +158,7 @@
> char *nonce;
> QOPType qop_options;
> AlgorithmType algorithm;
> + char *domain;
>
> /* These are generated by the client */
> char *cnonce;
> @@ -331,6 +364,7 @@
> auth->realm = soup_header_param_copy_token (tokens, "realm");
>
> digest->nonce = soup_header_param_copy_token (tokens, "nonce");
> + digest->domain = soup_header_param_copy_token (tokens, "domain");
>
> tmp = soup_header_param_copy_token (tokens, "qop");
> ptr = tmp;
> @@ -356,6 +390,50 @@
> soup_header_param_destroy_hash (tokens);
> }
>
> +static GSList *
> +digest_pspace_func (SoupAuth *auth, const SoupUri *source_uri)
> +{
> + SoupAuthDigest *digest = (SoupAuthDigest *) auth;
> + GSList *space = NULL;
> + SoupUri *uri;
> + char *domain, *d, *lasts, *dir, *slash;
> +
> + if (!digest->domain) {
This needs to check if digest->domain is "", as the block below won't
pick it up:
if (!digest->domain || !*digest->domain) {
> + /* If no domain directive, the protection space is the
> + * whole server.
> + */
> + return g_slist_prepend (NULL, g_strdup (""));
> + }
> +
> + domain = g_strdup (digest->domain);
> + for (d = strtok_r (domain, " ", &lasts); d; d = strtok_r (NULL, " ", &lasts)) {
> + if (*d == '/')
> + dir = g_strdup (d);
> + else {
> + uri = soup_uri_new (d);
> + if (uri && uri->protocol == source_uri->protocol &&
> + uri->port == source_uri->port &&
> + !strcmp (uri->host, source_uri->host))
> + dir = g_strdup (uri->path);
> + else
> + dir = NULL;
> + if (uri)
> + soup_uri_free (uri);
> + }
> +
> + if (dir) {
> + slash = strrchr (dir, '/');
> + if (slash && !slash[1])
> + *slash = '\0';
> +
> + space = g_slist_prepend (space, dir);
> + }
> + }
> + g_free (domain);
> +
> + return space;
> +}
> +
Joe
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]