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


Python OpenIDSchema.to_json方法代码示例

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


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

示例1: claims_info_endpoint

# 需要导入模块: from oic.oic.message import OpenIDSchema [as 别名]
# 或者: from oic.oic.message.OpenIDSchema import to_json [as 别名]
    def claims_info_endpoint(self, environ, start_response, *args):
        _log_info = logger.info

        query = get_or_post(environ)
        _log_info("Claims_info_endpoint query: '%s'" % query)
        _log_info("environ: %s" % environ)

        #ucreq = self.srvmethod.parse_userinfo_claims_request(query)
        #_log_info("request: %s" % ucreq)

        # Supposed to be "Bearer <access_token>
        access_token = self._bearer_auth(environ)
        uiresp = OpenIDSchema(**self.info_store[access_token])

        resp = Response(uiresp.to_json(), content="application/json")
        return resp(environ, start_response)
开发者ID:imsoftware,项目名称:pyoidc,代码行数:18,代码来源:claims_provider.py

示例2: __call__

# 需要导入模块: from oic.oic.message import OpenIDSchema [as 别名]
# 或者: from oic.oic.message.OpenIDSchema import to_json [as 别名]
    def __call__(self, request):
        data = request.body

        self.provider.parse_user_info_request(data)

        _info = {
            'sub': 'test-sub',
            'name': 'Test User',
            'nickname': 'Tester',
            'email': '[email protected]',
            'verified': True,
        }

        resp = OpenIDSchema(**_info)

        userinfo = resp.to_json()

        return (200, {'Content-Type': 'application/json'}, userinfo)
开发者ID:crossgovernmentservices,项目名称:sue-my-brother,代码行数:20,代码来源:oidc_testbed.py

示例3: userinfo_endpoint

# 需要导入模块: from oic.oic.message import OpenIDSchema [as 别名]
# 或者: from oic.oic.message.OpenIDSchema import to_json [as 别名]
    def userinfo_endpoint(self, request="", **kwargs):
        """
        :param request: The request in a string format
        """
        try:
            _log_debug = kwargs["logger"].debug
            _log_info = kwargs["logger"].info
        except KeyError:
            _log_debug = logger.debug
            _log_info = logger.info

        _sdb = self.sdb

        if not request or "access_token" not in request:
            _token = kwargs["authn"]
            assert _token.startswith("Bearer ")
            _token = _token[len("Bearer "):]
            logger.debug("Bearer token: '%s'" % _token)
        else:
            uireq = self.server.parse_user_info_request(data=request)
            logger.debug("user_info_request: %s" % uireq)
            _token = uireq["access_token"]

        # should be an access token
        typ, key = _sdb.token.type_and_key(_token)
        _log_debug("access_token type: '%s'" % (typ,))

        try:
            assert typ == "T"
        except AssertionError:
            raise FailedAuthentication("Wrong type of token")

        #_log_info("keys: %s" % self.sdb.keys())
        if _sdb.is_revoked(key):
            return self._error(error="access_denied", descr="Token is revoked")
        session = _sdb[key]

        # Scope can translate to userinfo_claims

        info = OpenIDSchema(**self._collect_user_info(session))

        # Should I return a JSON or a JWT ?
        _cinfo = self.cdb[session["client_id"]]
        if "userinfo_signed_response_alg" in _cinfo:
            algo = _cinfo["userinfo_signed_response_alg"]
            # Use my key for signing
            key = self.keyjar.get_signing_key(alg2keytype(algo), "")
            jinfo = info.to_jwt(key, algo)
            content_type = "application/jwt"
            if "userinfo_encrypted_response_alg" in _cinfo:
                # encrypt with clients public key
                jinfo = self.encrypt(jinfo, _cinfo, session["client_id"],
                                     "userinfo")
        elif "userinfo_encrypted_response_alg" in _cinfo:
            jinfo = self.encrypt(info.to_json(), _cinfo, session["client_id"],
                                 "userinfo")
            content_type = "application/jwt"
        else:
            jinfo = info.to_json()
            content_type = "application/json"

        return Response(jinfo, content=content_type)
开发者ID:wayward710,项目名称:pyoidc,代码行数:64,代码来源:provider.py


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