当前位置: 首页>>代码示例>>Python>>正文


Python consumer.Consumer类代码示例

本文整理汇总了Python中oic.oic.consumer.Consumer的典型用法代码示例。如果您正苦于以下问题:Python Consumer类的具体用法?Python Consumer怎么用?Python Consumer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Consumer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_server_authenticated_none

def test_server_authenticated_none():
    server = provider_init
    _session_db = {}
    cons = Consumer(_session_db, CONSUMER_CONFIG, CLIENT_CONFIG,
                    server_info=SERVER_INFO, )
    cons.debug = True
    cons.keyjar[""] = KC_RSA
    cons.response_type = "none"
    environ = BASE_ENVIRON

    location = cons.begin(environ, start_response)

    environ = BASE_ENVIRON.copy()
    environ["QUERY_STRING"] = location.split("?")[1]

    resp = server.authorization_endpoint(environ, start_response)

    sid = resp[0][len("<form>"):-len("</form>")]
    environ2 = create_return_form_env("user", "password", sid)

    resp2 = server.authenticated(environ2, start_response)

    assert len(resp2) == 1
    txt = resp2[0]
    pos0 = txt.index("<title>") + len("<title>Redirecting to ")
    pos1 = txt.index("</title>")
    location = txt[pos0:pos1]
    print location

    assert location.startswith("http://localhost:8087/authz")
    query = location.split("?")[1]
    print query
    assert "token_type=Bearer" in query
开发者ID:asheidan,项目名称:pyoidc,代码行数:33,代码来源:test_oic_provider.py

示例2: setup_userinfo_endpoint

    def setup_userinfo_endpoint(self):
        cons = Consumer({}, CONSUMER_CONFIG, {"client_id": CLIENT_ID},
                        server_info=SERVER_INFO, )
        cons.behaviour = {
            "request_object_signing_alg": DEF_SIGN_ALG["openid_request_object"]}
        cons.keyjar[""] = KC_RSA

        cons.client_secret = "drickyoughurt"
        state, location = cons.begin("openid", "token",
                                     path=TestConfiguration.get_instance().rp_base)

        resp = self.provider.authorization_endpoint(
            request=urlparse(location).query)

        # redirect
        atr = AuthorizationResponse().deserialize(
            urlparse(resp.message).fragment, "urlencoded")

        uir = UserInfoRequest(access_token=atr["access_token"], schema="openid")
        resp = self.provider.userinfo_endpoint(request=uir.to_urlencoded())
        responses.add(
            responses.POST,
            self.op_base + "userinfo",
            body=resp.message,
            status=200,
            content_type='application/json')
开发者ID:borgand,项目名称:SATOSA,代码行数:26,代码来源:FakeOp.py

示例3: test_server_authenticated_token

def test_server_authenticated_token():
    server = provider_init

    _session_db = {}
    cons = Consumer(_session_db, CONSUMER_CONFIG, CLIENT_CONFIG,
                    server_info=SERVER_INFO, )
    cons.debug = True
    cons.keyjar[""] = KC_RSA

    cons.config["response_type"] = ["token"]
    environ = BASE_ENVIRON

    location = cons.begin(environ, start_response)

    environ = BASE_ENVIRON.copy()
    environ["QUERY_STRING"] = location.split("?")[1]

    resp = server.authorization_endpoint(environ, start_response)

    sid = resp[0][len("<form>"):-len("</form>")]
    environ2 = create_return_form_env("user", "password", sid)

    resp2 = server.authenticated(environ2, start_response)

    assert len(resp2) == 1
    txt = resp2[0]
    assert "access_token=" in txt
    assert "token_type=Bearer" in txt
开发者ID:asheidan,项目名称:pyoidc,代码行数:28,代码来源:test_oic_provider.py

示例4: test_provider_config

    def test_provider_config(self):
        c = Consumer(None, None)
        mfos = MyFakeOICServer("http://example.com")
        mfos.keyjar = SRVKEYS
        c.http_request = mfos.http_request

        principal = "[email protected]"

        res = c.discover(principal)
        info = c.provider_config(res)
        assert isinstance(info, ProviderConfigurationResponse)
        assert _eq(info.keys(), ['registration_endpoint', 'jwks_uri',
                                 'check_session_endpoint',
                                 'refresh_session_endpoint',
                                 'register_endpoint',
                                 'subject_types_supported',
                                 'token_endpoint_auth_methods_supported',
                                 'id_token_signing_alg_values_supported',
                                 'grant_types_supported', 'user_info_endpoint',
                                 'claims_parameter_supported',
                                 'request_parameter_supported',
                                 'discovery_endpoint', 'issuer',
                                 'authorization_endpoint', 'scopes_supported',
                                 'require_request_uri_registration',
                                 'identifiers_supported', 'token_endpoint',
                                 'request_uri_parameter_supported', 'version',
                                 'response_types_supported',
                                 'end_session_endpoint', 'flows_supported'])

        assert info["end_session_endpoint"] == "http://example.com/end_session"
开发者ID:Omosofe,项目名称:pyoidc,代码行数:30,代码来源:test_oic_consumer.py

示例5: test_discover_redirect

def test_discover_redirect():
    c = Consumer(None, None)
    mfos = MyFakeOICServer(name="http://example.com/")
    c.http_request = mfos.http_request

    principal = "[email protected]"

    res = c.discover(principal)
    assert res == "http://example.net/providerconf"
开发者ID:imsoftware,项目名称:pyoidc,代码行数:9,代码来源:test_oic_consumer.py

示例6: test_discover

    def test_discover(self):
        c = Consumer(None, None)
        mfos = MyFakeOICServer("http://localhost:8088")
        mfos.keyjar = SRVKEYS
        c.http_request = mfos.http_request

        principal = "[email protected]"
        res = c.discover(principal)
        assert res == "http://localhost:8088/"
开发者ID:Omosofe,项目名称:pyoidc,代码行数:9,代码来源:test_oic_consumer.py

示例7: test_discover

def test_discover():
    c = Consumer(None, None)
    mfos = MyFakeOICServer(SRVKEYS, "http://example.com/")
    c.http_request = mfos.http_request

    principal = "[email protected]"

    res = c.discover(principal)
    assert res == "http://example.com/"
开发者ID:imsoftware,项目名称:pyoidc,代码行数:9,代码来源:test_oic_consumer.py

示例8: handle_authz_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)
开发者ID:asheidan,项目名称:pyoidc,代码行数:11,代码来源:test_server_1.py

示例9: test_faulty_id_token_in_access_token_response

    def test_faulty_id_token_in_access_token_response(self):
        c = Consumer(None, None)
        c.keyjar.add_symmetric("", "TestPassword", ["sig"])

        _info = {"access_token": "accessTok",
                 "id_token": self._faulty_id_token(),
                 "token_type": "Bearer"}

        _json = json.dumps(_info)
        with pytest.raises(BadSignature):
            c.parse_response(AccessTokenResponse, _json, sformat="json")
开发者ID:Omosofe,项目名称:pyoidc,代码行数:11,代码来源:test_oic_consumer.py

示例10: test_server_authenticated

def test_server_authenticated():
    server = provider_init
    _session_db = {}
    cons = Consumer(_session_db, CONSUMER_CONFIG, CLIENT_CONFIG,
                    server_info=SERVER_INFO, )
    cons.debug = True
    cons.keyjar[""] = KC_RSA

    environ = BASE_ENVIRON

    location = cons.begin(environ, start_response)

    environ = BASE_ENVIRON.copy()
    environ["QUERY_STRING"] = location.split("?")[1]

    resp = server.authorization_endpoint(environ, start_response)

    sid = resp[0][len("<form>"):-len("</form>")]
    environ2 = create_return_form_env("user", "password", sid)

    resp2 = server.authenticated(environ2, start_response)

    print resp2[0]
    assert len(resp2) == 1
    txt = resp2[0]
    pos0 = txt.index("<title>") + len("<title>Redirecting to ")
    pos1 = txt.index("</title>")
    location = txt[pos0:pos1]
    print location

    assert location.startswith("http://localhost:8087/authz")

    environ = BASE_ENVIRON.copy()
    environ["QUERY_STRING"] = location

    part = cons.parse_authz(environ, start_response)
    
    aresp = part[0]
    assert part[1] is None
    assert part[2] is None

    #aresp = client.parse_response(AuthorizationResponse, location,
    #                              format="urlencoded",
    #                              state="id-6da9ca0cc23959f5f33e8becd9b08cae")

    print aresp.keys()
    assert aresp.type() == "AuthorizationResponse"
    assert _eq(aresp.keys(), ['code', 'state', 'scope'])

    print cons.grant[cons.state].keys()
    assert _eq(cons.grant[cons.state].keys(), ['code', 'id_token', 'tokens',
                                               'exp_in',
                                               'grant_expiration_time', 'seed'])
开发者ID:asheidan,项目名称:pyoidc,代码行数:53,代码来源:test_oic_provider.py

示例11: test_faulty_id_token_in_access_token_response

def test_faulty_id_token_in_access_token_response():
    c = Consumer(None, None)
    c.keyjar.add_symmetric("", "TestPassword", ["sig"])

    _info = {"access_token": "accessTok", "id_token": _faulty_id_token(),
             "token_type": "Bearer", "expires_in": 3600}

    _json = json.dumps(_info)
    try:
        resp = c.parse_response(AccessTokenResponse, _json, sformat="json")
    except BadSignature:
        pass
    else:
        assert False
开发者ID:dallerbarn,项目名称:pyoidc,代码行数:14,代码来源:test_oic_consumer.py

示例12: real_test_discover

 def real_test_discover(self):
     c = Consumer(None, None)
     principal = "[email protected]"
     res = c.discover(principal)
     assert isinstance(res, ProviderConfigurationResponse)
     assert _eq(res.keys(), ['registration_endpoint', 'scopes_supported',
                             'identifiers_supported', 'token_endpoint',
                             'flows_supported', 'version',
                             'userinfo_endpoint',
                             'authorization_endpoint', 'x509_url', 'issuer'])
     assert res.version == "3.0"
     assert _eq(res.flows_supported, ['code', 'token', 'id_token',
                                      'code token', 'code id_token',
                                      'id_token token'])
开发者ID:Omosofe,项目名称:pyoidc,代码行数:14,代码来源:test_oic_consumer.py

示例13: setup_consumer

    def setup_consumer(self, fake_oic_server, session_db_factory):
        client_id = "client_1"
        client_config = {
            "client_id": client_id,
            "client_authn_method": CLIENT_AUTHN_METHOD,
            # 'config': {}
        }

        self.consumer = Consumer(session_db_factory(SERVER_INFO["issuer"]),
                                 CONFIG, client_config, SERVER_INFO)
        self.consumer.behaviour = {
            "request_object_signing_alg": DEF_SIGN_ALG["openid_request_object"]}
        self.consumer.client_secret = "abcdefghijklmnop"
        self.consumer.keyjar = CLIKEYS
        self.consumer.redirect_uris = ["https://example.com/cb"]
        self.consumer.authorization_endpoint = \
            "http://example.com/authorization"
        self.consumer.token_endpoint = "http://example.com/token"
        self.consumer.userinfo_endpoint = "http://example.com/userinfo"
        self.consumer.client_secret = "hemlig"
        self.consumer.secret_type = "basic"

        mfos = fake_oic_server("http://localhost:8088")
        mfos.keyjar = SRVKEYS
        self.consumer.http_request = mfos.http_request
开发者ID:,项目名称:,代码行数:25,代码来源:

示例14: register

def register(environ, start_response, logger, kaka=None):
    """
    Initialize the OAuth2 flow
    """
    _session_db = environ["oic.session_db"]
    _cc = environ["oic.client_config"]
    _conc = environ["oic.consumer.config"]
    _server_info = environ["oic.server.info"]

    # get the redirect to the authorization server endpoint
    _oac = Consumer(_session_db, _conc, _cc, _server_info)
    location = _oac.begin(environ, start_response, logger)

    logger.info("[1] %s" % (_oac.__dict__,))
    resp = http_util.Redirect(location)
    return resp(environ, start_response)
开发者ID:asheidan,项目名称:pyoidc,代码行数:16,代码来源:oic_consumer.py

示例15: test_server_authenticated_token

def test_server_authenticated_token():
    server = provider_init

    _session_db = {}
    cons = Consumer(_session_db, CONSUMER_CONFIG, CLIENT_CONFIG,
                    server_info=SERVER_INFO, )
    cons.debug = True
    cons.keyjar[""] = KC_RSA

    location = cons.begin("openid", response_type="token",
                          path="http://localhost:8087")

    resp = server.authorization_endpoint(request=location.split("?")[1])

    txt = resp.message
    assert "access_token=" in txt
    assert "token_type=Bearer" in txt
开发者ID:biancini,项目名称:pyoidc,代码行数:17,代码来源:test_oic_provider.py


注:本文中的oic.oic.consumer.Consumer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。