當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。