def decide(request, openid_request=None): from openid.yadis.discover import DiscoveryFailure from openid.fetchers import HTTPFetchingError from openid.server.trustroot import verifyReturnTo if not openid_request: openid_request = utils._load_request(request) trust_root = openid_request.trust_root return_to = openid_request.return_to try: # Stringify because template's ifequal can only compare to strings. trust_root_valid = verifyReturnTo(trust_root, return_to) \ and "Valid" or "Invalid" except DiscoveryFailure, err: trust_root_valid = "Discovery faild"
def endpoint(request): from openid.server.server import ProtocolError server = utils.get_server() data = dict(request.REQUEST.items()) try: openid_request = server.decodeRequest(data) except ProtocolError, why: return _render_error(request, force_unicode(why)) if openid_request is not None: utils._save_request(request, openid_request) else: openid_request = utils._load_request(request) if openid_request is None: return http.HttpResponseBadRequest('OpenID consumer request required') if openid_request.mode in ["checkid_immediate", "checkid_setup"]: if not openid_request.idSelect(): id_url = settings.TURBION_OPENID_IDENTITY_URL # Confirm that this server can actually vouch for that # identifier if id_url != openid_request.identity: # Return an error response why = ProtocolError( openid_request.message, "This server cannot verify the URL %r" % (openid_request.identity,)