Skip to content

Instantly share code, notes, and snippets.

@adieu
Created April 6, 2010 16:17
Show Gist options
  • Save adieu/357768 to your computer and use it in GitHub Desktop.
Save adieu/357768 to your computer and use it in GitHub Desktop.
Google Apps support patch for python-openid v2.1.1
diff --git a/consumer/consumer.py b/consumer/consumer.py
index e725da2..d57b9d3 100644
--- a/consumer/consumer.py
+++ b/consumer/consumer.py
@@ -724,7 +724,6 @@ class GenericConsumer(object):
"return_to does not match return URL. Expected %r, got %r"
% (return_to, message.getArg(OPENID_NS, 'return_to')))
-
# Verify discovery information:
endpoint = self._verifyDiscoveryResults(message, endpoint)
oidutil.log("Received id_res response from %s using association %s" %
@@ -1014,16 +1013,28 @@ class GenericConsumer(object):
# Fragments do not influence discovery, so we can't compare a
# claimed identifier with a fragment to discovered information.
- defragged_claimed_id, _ = urldefrag(to_match.claimed_id)
+ if to_match.server_url.startswith(u'https://www.google.com/a/'):
+ import urllib
+ claimed_id = u'https://www.google.com/accounts/o8/user-xrds?uri=%s' % urllib.quote_plus(to_match.claimed_id)
+ else:
+ claimed_id = to_match.claimed_id
+
+ defragged_claimed_id, _ = urldefrag(claimed_id)
if defragged_claimed_id != endpoint.claimed_id:
raise ProtocolError(
'Claimed ID does not match (different subjects!), '
'Expected %s, got %s' %
(defragged_claimed_id, endpoint.claimed_id))
+
+ if to_match.server_url.startswith(u'https://www.google.com/a/'):
+ import urllib
+ local_id = u'https://www.google.com/accounts/o8/user-xrds?uri=%s' % urllib.quote_plus(to_match.local_id)
+ else:
+ local_id = to_match.getLocalID()
- if to_match.getLocalID() != endpoint.getLocalID():
+ if local_id != endpoint.getLocalID():
raise ProtocolError('local_id mismatch. Expected %s, got %s' %
- (to_match.getLocalID(), endpoint.getLocalID()))
+ (local_id, endpoint.getLocalID()))
# If the server URL is None, this must be an OpenID 1
# response, because op_endpoint is a required parameter in
@@ -1056,8 +1067,14 @@ class GenericConsumer(object):
@raises DiscoveryFailure: when discovery fails.
"""
+ if to_match.server_url.startswith(u'https://www.google.com/a/'):
+ import urllib
+ claimed_id = u'https://www.google.com/accounts/o8/user-xrds?uri=%s' % urllib.quote_plus(to_match.claimed_id)
+ else:
+ claimed_id = to_match.claimed_id
+
oidutil.log('Performing discovery on %s' % (to_match.claimed_id,))
- _, services = self._discover(to_match.claimed_id)
+ _, services = self._discover(claimed_id)
if not services:
raise DiscoveryFailure('No OpenID information found at %s' %
(to_match.claimed_id,), None)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment