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


Python Provider.create_providerinfo方法代码示例

本文整理汇总了Python中oic.oic.provider.Provider.create_providerinfo方法的典型用法代码示例。如果您正苦于以下问题:Python Provider.create_providerinfo方法的具体用法?Python Provider.create_providerinfo怎么用?Python Provider.create_providerinfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在oic.oic.provider.Provider的用法示例。


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

示例1: __init__

# 需要导入模块: from oic.oic.provider import Provider [as 别名]
# 或者: from oic.oic.provider.Provider import create_providerinfo [as 别名]

#.........这里部分代码省略.........
            "oauth_state": "authz",
            "authn_event": ae,
            "authzreq": authreq.to_json(),
            "client_id": CLIENT_ID,
            "code": access_grant,
            "code_used": False,
            "scope": ["openid"],
            "redirect_uri": self.redirect_urls[0],
        }
        _sdb.do_sub(sid, "client_salt")
        # Construct Access token request
        areq = AccessTokenRequest(code=access_grant, client_id=CLIENT_ID,
                                  redirect_uri=self.redirect_urls[0],
                                  client_secret="client_secret_1")
        txt = areq.to_urlencoded()
        resp = self.provider.token_endpoint(request=txt)
        responses.add(
            responses.POST,
            self.op_base + "token",
            body=resp.message,
            status=200,
            content_type='application/json')

    def setup_authentication_response(self, state=None):
        context = Context()
        context.path = 'openid/authz_cb'
        op_base = TestConfiguration.get_instance().rp_config.OP_URL
        if not state:
            state = rndstr()
        context.request = {
            'code': 'F+R4uWbN46U+Bq9moQPC4lEvRd2De4o=',
            'scope': 'openid profile email address phone',
            'state': state}
        context.state = self.generate_state(op_base)
        return context

    def generate_state(self, op_base):
        state = State()
        state_id = TestConfiguration.get_instance().rp_config.STATE_ID
        state_data = {
            StateKeys.OP: PROVIDER,
            StateKeys.NONCE: "9YraWpJAmVp4L3NJ",
            StateKeys.TOKEN_ENDPOINT: TestConfiguration.get_instance().rp_config.OP_URL + "token",
            StateKeys.CLIENT_ID: "client_1",
            StateKeys.CLIENT_SECRET: "2222222222",
            StateKeys.JWKS_URI:
                TestConfiguration.get_instance().rp_config.OP_URL + "static/jwks.json",
            StateKeys.USERINFO_ENDPOINT:
                TestConfiguration.get_instance().rp_config.OP_URL + "userinfo",
            StateKeys.STATE: FakeOP.STATE
        }
        state.add(state_id, state_data)
        return state

    def setup_client_registration_endpoint(self):
        client_info = TestConfiguration.get_instance().rp_config.CLIENTS[PROVIDER]["client_info"]
        request = RegistrationRequest().deserialize(json.dumps(client_info), "json")
        _cinfo = self.provider.do_client_registration(request, CLIENT_ID)
        args = dict([(k, v) for k, v in _cinfo.items()
                     if k in RegistrationResponse.c_param])
        args['client_id'] = CLIENT_ID
        self.provider.comb_uri(args)
        registration_response = RegistrationResponse(**args)
        responses.add(
            responses.POST,
            self.op_base + "registration",
            body=registration_response.to_json(),
            status=200,
            content_type='application/json')

    def setup_opienid_config_endpoint(self):
        self.provider.baseurl = self.op_base
        self.provider.jwks_uri = self.publish_jwks()
        provider_info = self.provider.create_providerinfo()
        responses.add(
            responses.GET,
            self.op_base + ".well-known/openid-configuration",
            body=provider_info.to_json(),
            status=200,
            content_type='application/json'
        )

    def setup_webfinger_endpoint(self):
        wf = WebFinger()
        resp = Response(wf.response(subject=self.op_base, base=self.op_base))
        responses.add(responses.GET,
                      self.op_base + ".well-known/webfinger",
                      body=resp.message,
                      status=200,
                      content_type='application/json')

    def publish_jwks(self):
        jwks_uri = self.op_base + "static/jwks.json"
        responses.add(
            responses.GET,
            jwks_uri,
            body=json.dumps(JWKS),
            status=200,
            content_type='application/json')
        return jwks_uri
开发者ID:borgand,项目名称:SATOSA,代码行数:104,代码来源:FakeOp.py


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