cpop.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:fedoidc 作者: OpenIDC 项目源码 文件源码
def registration(self, **kwargs):
        logger.debug('Request headers: {}'.format(cherrypy.request.headers))
        if cherrypy.request.method == "OPTIONS":
            cherrypy_cors.preflight(
                allowed_methods=["POST", "GET"], origins='*',
                allowed_headers=['Authorization', 'content-type'])
        elif cherrypy.request.method == "GET":
            _cinfo = self.op.cdb[kwargs['client_id']]
            for attr in ['redirect_uris', 'post_logout_redirect_uris']:
                try:
                    _cinfo[attr] = unpack_redirect_uri(_cinfo[attr])
                except KeyError:
                    pass
            rr = RegistrationResponse(**_cinfo)
            cherrypy.response.headers['Content-Type'] = 'application/json'
            return as_bytes(json.dumps(rr.to_dict()))
        else:
            logger.debug('ClientRegistration kwargs: {}'.format(kwargs))
            _request = None

            if cherrypy.request.process_request_body is True:
                _request = as_unicode(cherrypy.request.body.read())
                logger.debug('request_body: {}'.format(_request))

            try:
                if _request:
                    resp = self.op.registration_endpoint(_request)
                else:
                    resp = self.op.registration_endpoint(json.dumps(kwargs))
            except Exception as err:
                logger.error(err)
                raise cherrypy.HTTPError(message=str(err))

            return conv_response(resp)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号