diff options
author | martin.von.loewis <devnull@localhost> | 2011-06-19 14:17:58 +0000 |
---|---|---|
committer | martin.von.loewis <devnull@localhost> | 2011-06-19 14:17:58 +0000 |
commit | e2ad97a302f19026985f4f1614b1f18de6f3664e (patch) | |
tree | e2ce66ce74234570ad513352ff2f40abe3ba37d3 /openid2rp.py | |
parent | 63260a65e5a867c107af559ac7e694e194e68c3b (diff) | |
download | decorator-e2ad97a302f19026985f4f1614b1f18de6f3664e.tar.gz |
Explicitly try to resolve the signon services.
Diffstat (limited to 'openid2rp.py')
-rw-r--r-- | openid2rp.py | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/openid2rp.py b/openid2rp.py index ec8c2ac..b54db34 100644 --- a/openid2rp.py +++ b/openid2rp.py @@ -273,22 +273,29 @@ def resolve_xri(xri, proxy='xri.net'): Return canonical ID, services, op endpoint, op local; return None if an error occurred''' xri = urllib.quote(xri, safe='=@*!+()') - conn = httplib.HTTPConnection(proxy) - try: - conn.connect() - except: - # DNS or TCP error - return None - conn.putrequest("GET", '/'+xri+'?_xrd_r=application/xrds+xml') - conn.endheaders() - - res = conn.getresponse() - data = res.read() - conn.close() - - doc = ElementTree.fromstring(data) - res = _extract_services(doc) - if res is None: + # Ask explicitly for the specific service types, to + # avoid having to identify the correct XRD element in + # case the identifier is hierarchical + for stype in ('http://specs.openid.net/auth/2.0/signon', + 'http://openid.net/signon/1.0'): + conn = httplib.HTTPConnection(proxy) + try: + conn.connect() + except: + # DNS or TCP error + return None + conn.putrequest("GET", '/'+xri+'?_xrd_r=application/xrd+xml' + +'&_xrd_t='+stype) + conn.putheader('Connection', 'Keep-Alive') + conn.endheaders() + res = conn.getresponse() + data = res.read() + doc = ElementTree.fromstring(data) + res = _extract_services(doc) + conn.close() + if res is not None: + break + else: # No OpenID service found return None services, op_endpoint, op_local = res |