def handle_authz_response(environ, start_response): _cli = Consumer(SESSION_DB, CLIENT_CONFIG, SERVER_INFO, **CONSUMER_CONFIG) aresp = _cli.parse_authz(environ, start_response, DEVNULL()) print "ARESP: %s" % aresp kaka = http_util.cookie(CLIENT_CONFIG["client_id"], aresp.state, _cli.seed, expire=360, path="/") resp = http_util.Response("Your will is registered", headers=[kaka]) return resp(environ, start_response)
def handle_authz_response(environ, start_response): _cli = Consumer(SESSION_DB, CONSUMER_CONFIG, CLIENT_CONFIG, SERVER_INFO) aresp, atr, idt = _cli.parse_authz(environ, start_response, DEVNULL()) print "ARESP: %s" % aresp print "ATR: %s" % atr print "IDT: %s" % idt print "GSess: %s" % _cli.grant kaka = http_util.cookie(CONSUMER_CONFIG["name"], _cli.state, _cli.seed, expire=360, path="/") resp = http_util.Response("Your will is registered", headers=[kaka]) return resp(environ, start_response)
def test_factory(): _session_db = {} cons = Consumer(_session_db, client_config = CLIENT_CONFIG, server_info=SERVER_INFO, **CONSUMER_CONFIG) sid = stateID("https://example.org/", cons.seed) cons.state = sid cons._backup(sid) cons.sdb["seed:%s" % cons.seed] = sid kaka = http_util.cookie(CLIENT_CONFIG["client_id"], cons.state, cons.seed, expire=360, path="/") _oac = factory(kaka[1], _session_db, CLIENT_CONFIG["client_id"], client_config= CLIENT_CONFIG, server_info=SERVER_INFO, **CONSUMER_CONFIG) assert _oac assert _oac.state == cons.state assert _oac.seed == cons.seed
resp = http_util.Unauthorized("%s" % err) return resp(environ, start_response) except UnknownState, err: resp = http_util.BadRequest("Unsolicited Response") return resp(environ, start_response) if _conc["flow_type"] == "code": # Not done yet try: _cli.complete(logger) # get the access token from the token # endpoint except TokenError, err: resp = http_util.Unauthorized("%s" % err) return resp(environ, start_response) # Valid for 6 hours (=360 minutes) kaka = http_util.cookie(_cc["client_id"], _cli.state, _cli.seed, expire=360, path="/") _log_info("DUMP: %s" % (_cli.sdb[_cli.sdb["seed:%s" % _cli.seed]],)) resp = http_util.Response("Your will is registered", headers=[kaka]) _log_info("Cookie: %s" % (kaka,)) return resp(environ, start_response) # ---------------------------------------------------------------------------- URLS = [ (r'resource', resource), (r'register$', register), (r'authz', authz), ]
resp = http_util.Unauthorized("%s" % err) return resp(environ, start_response) except Exception, err: _log_info("Exception err: %s" % err) raise else: pass _log_info("AU: %s" % aresp) _log_info("AT: %s" % atr) _log_info("DUMP: %s" % (_cli.sdb[_cli.state],)) _log_info("[2] %s" % (_cli.__dict__,)) # Valid for 6 hours (=360 minutes) kaka = http_util.cookie(_conc["name"], _cli.state, _cli.seed, expire=360, path="/") resp = http_util.Response("Your will is registered", headers=[kaka]) _log_info("Cookie: %s" % (kaka,)) return resp(environ, start_response) #noinspection PyUnusedLocal def userinfo(environ, start_response, logger, kaka=None): _session_db = environ["oic.session_db"] _cc = environ["oic.client_config"] _conc = environ["oic.consumer.config"] _server_info = environ["oic.server.info"] _log_info = logger.info