hooks.py 文件源码

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

项目:iotronic 作者: openstack 项目源码 文件源码
def before(self, state):
        headers = state.request.headers

        is_public_api = state.request.environ.get(
            'is_public_api', False)
        ctx = context.RequestContext.from_environ(
            state.request.environ,
            is_public_api=is_public_api,
            project_id=headers.get('X-Project-Id'),
            user_id=headers.get('X-User-Id'),
            )

        # Do not pass any token with context for noauth mode
        if cfg.CONF.auth_strategy == 'noauth':
            ctx.auth_token = None

        creds = ctx.to_policy_values()

        is_admin = policy.check('is_admin', creds, creds)
        ctx.is_admin = is_admin

        state.request.context = ctx
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号