

def __call__(self, environ, start_response):
    env_identity = self._keystone_identity(environ)
    if (self.allow_overrides and environ.get('swift.authorize_override', False)):
        msg = 'Authorizing from an overriding middleware'
        self.logger.debug(msg)
        return self.app(environ, start_response)
    if env_identity:
        self.logger.debug('Using identity: %r', env_identity)
        environ['REMOTE_USER'] = env_identity.get('tenant')
        environ['keystone.identity'] = env_identity
        environ['swift.authorize'] = functools.partial(self.authorize, env_identity)
        user_roles = (r.lower() for r in env_identity.get('roles', []))
        if (self.reseller_admin_role in user_roles):
            environ['reseller_request'] = True
    else:
        self.logger.debug('Authorizing as anonymous')
        environ['swift.authorize'] = self.authorize_anonymous
    environ['swift.clean_acl'] = swift_acl.clean_acl

    def keystone_start_response(status, response_headers, exc_info=None):
        project_domain_id = None
        for (key, val) in response_headers:
            if (key.lower() == PROJECT_DOMAIN_ID_SYSMETA_HEADER):
                project_domain_id = val
                break
        if project_domain_id:
            response_headers.append((PROJECT_DOMAIN_ID_HEADER, project_domain_id))
        return start_response(status, response_headers, exc_info)
    return self.app(environ, keystone_start_response)

dataset/ETHPy150Open openstack/swift/swift/common/middleware/keystoneauth.py KeystoneAuth.__call__/original