Mercurial > openid
changeset 42:1068de1623a5
Announce when provider only supports old OpenID version
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Sun, 12 Jun 2011 18:12:47 -0400 |
parents | a77f4cd1336d |
children | 00c8f43be8b7 |
files | src/c/openid.c |
diffstat | 1 files changed, 11 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/c/openid.c Sun Jun 12 17:49:43 2011 -0400 +++ b/src/c/openid.c Sun Jun 12 18:12:47 2011 -0400 @@ -72,7 +72,7 @@ uw_context ctx; uw_OpenidFfi_discovery *d; xrds_mode mode; - int cur_priority, max_priority; + int cur_priority, max_priority, found_old_version; } endpoint; static void XMLCALL startElement(void *userData, const XML_Char *name, const XML_Char **atts) { @@ -89,6 +89,9 @@ if (!strcmp(attp[0], "rel") && !strcmp(attp[1], "openid2.provider")) { found = 1; break; + } else if (!strcmp(attp[0], "rel") && !strcmp(attp[1], "openid.server")) { + ep->found_old_version = 1; + return; } } @@ -182,7 +185,7 @@ CURL *c = curl(ctx); curl_discovery_data cd = {}; uw_OpenidFfi_discovery *dy = uw_malloc(ctx, sizeof(uw_OpenidFfi_discovery)); - endpoint ep = {ctx, dy, NONE, 0, INT_MAX}; + endpoint ep = {ctx, dy, NONE, 0, INT_MAX, 0}; CURLcode code; struct curl_slist *headers = NULL; @@ -222,8 +225,12 @@ uw_Basis_debug(ctx, "CURL error:"); uw_Basis_debug(ctx, (char*)curl_easy_strerror(code)); } - else if (!dy->endpoint) - uw_Basis_debug(ctx, "Couldn't parse endpoint from page"); + else if (!dy->endpoint) { + if (ep.found_old_version) + uw_Basis_debug(ctx, "Provider doesn't support OpenID version 2.0 but does support an older version"); + else + uw_Basis_debug(ctx, "Couldn't parse endpoint from page"); + } if (code || !dy->endpoint) return NULL;