Esempio n. 1
0
    def get(self, user_uuid):
        ListSchema = schemas.new_list_schema('type')
        list_params, errors = ListSchema().load(request.args)
        if errors:
            raise exceptions.InvalidListParamException(errors)

        items = self.external_auth_service.list_(user_uuid, **list_params)
        total = self.external_auth_service.count(user_uuid,
                                                 filtered=False,
                                                 **list_params)
        filtered = self.external_auth_service.count(user_uuid,
                                                    filtered=True,
                                                    **list_params)

        for item in items:
            plugin_info = current_app.config['external_auth_plugin_info'][
                item['type']]
            item['plugin_info'] = plugin_info

        response = {
            'filtered': filtered,
            'total': total,
            'items': items,
        }

        return response, 200
Esempio n. 2
0
    def get(self, group_uuid):
        tenant_uuids = get_tenant_uuids(recurse=True)

        self.group_service.assert_group_in_subtenant(tenant_uuids, group_uuid)

        try:
            list_params = schemas.GroupPolicyListSchema().load(request.args)
        except marshmallow.ValidationError as e:
            raise exceptions.InvalidListParamException(e.messages)

        policies = self.group_service.list_policies(
            group_uuid,
            tenant_uuids=tenant_uuids,
            **list_params,
        )
        total = self.group_service.count_policies(
            group_uuid,
            filtered=False,
            **list_params,
        )
        filtered = self.group_service.count_policies(
            group_uuid,
            filtered=True,
            **list_params,
        )
        return (
            {
                'items': policy_full_schema.dump(policies, many=True),
                'total': total,
                'filtered': filtered,
            },
            200,
        )
Esempio n. 3
0
    def get(self, user_uuid):
        scoping_tenant = Tenant.autodetect()

        self.user_service.assert_user_in_subtenant(scoping_tenant.uuid,
                                                   user_uuid)

        try:
            list_params = schemas.UserSessionListSchema().load(request.args)
        except marshmallow.ValidationError as e:
            raise exceptions.InvalidListParamException(e.messages)

        return (
            {
                'items':
                self.user_service.list_sessions(user_uuid, **list_params),
                'total':
                self.user_service.count_sessions(user_uuid,
                                                 filtered=False,
                                                 **list_params),
                'filtered':
                self.user_service.count_sessions(user_uuid,
                                                 filtered=True,
                                                 **list_params),
            },
            200,
        )
Esempio n. 4
0
    def get(self):
        scoping_tenant = Tenant.autodetect()
        ListSchema = schemas.new_list_schema('name')
        list_params, errors = ListSchema().load(request.args)
        if errors:
            raise exceptions.InvalidListParamException(errors)

        list_params['scoping_tenant_uuid'] = scoping_tenant.uuid

        policies = self.policy_service.list(**list_params)
        total = self.policy_service.count(**list_params)
        return {'items': policies, 'total': total}, 200
Esempio n. 5
0
    def get(self):
        try:
            list_params = schemas.PolicyListSchema().load(request.args)
        except marshmallow.ValidationError as e:
            raise exceptions.InvalidListParamException(e.messages)

        recurse = list_params.pop('recurse')
        tenant_uuids = get_tenant_uuids(recurse=recurse)
        policies = self.policy_service.list(tenant_uuids=tenant_uuids,
                                            **list_params)
        total = self.policy_service.count(tenant_uuids=tenant_uuids,
                                          **list_params)
        items = policy_full_schema.dump(policies, many=True)
        return {'items': items, 'total': total}, 200
Esempio n. 6
0
    def get(self, user_uuid):
        try:
            list_params = schemas.UserPolicyListSchema().load(request.args)
        except marshmallow.ValidationError as e:
            raise exceptions.InvalidListParamException(e.messages)

        policies = self.user_service.list_policies(user_uuid, **list_params)
        items = policy_full_schema.dump(policies, many=True)
        total = self.user_service.count_policies(user_uuid,
                                                 filtered=False,
                                                 **list_params)
        filtered = self.user_service.count_policies(user_uuid,
                                                    filtered=True,
                                                    **list_params)
        return {'items': items, 'total': total, 'filtered': filtered}, 200
Esempio n. 7
0
    def get(self, group_uuid):
        scoping_tenant = Tenant.autodetect()

        self.group_service.assert_group_in_subtenant(scoping_tenant.uuid, group_uuid)

        ListSchema = schemas.new_list_schema('name')
        list_params, errors = ListSchema().load(request.args)
        if errors:
            raise exceptions.InvalidListParamException(errors)

        return {
            'items': self.group_service.list_policies(group_uuid, **list_params),
            'total': self.group_service.count_policies(group_uuid, filtered=False, **list_params),
            'filtered': self.group_service.count_policies(group_uuid, filtered=True, **list_params),
        }, 200
Esempio n. 8
0
    def _build_search_params(
        self, user_uuid=None, scoping_tenant_uuid=None, recurse=None
    ):
        try:
            search_params = schemas.RefreshTokenListSchema().load(request.args)
        except marshmallow.ValidationError as e:
            raise exceptions.InvalidListParamException(e.messages)

        search_params['scoping_tenant_uuid'] = scoping_tenant_uuid
        if user_uuid is not None:
            search_params['user_uuid'] = user_uuid

        if recurse is not None:
            search_params['recurse'] = recurse

        return search_params
Esempio n. 9
0
    def get(self):
        scoping_tenant = Tenant.autodetect()
        try:
            list_params = schemas.SessionListSchema().load(request.args)
        except marshmallow.ValidationError as e:
            raise exceptions.InvalidListParamException(e.messages)

        list_params['scoping_tenant_uuid'] = scoping_tenant.uuid

        sessions = self.session_service.list_(**list_params)
        total = self.session_service.count(filtered=False, **list_params)
        filtered = self.session_service.count(filtered=True, **list_params)

        response = {'filtered': filtered, 'total': total, 'items': sessions}

        return response, 200
Esempio n. 10
0
    def get(self):
        scoping_tenant = TenantDetector.autodetect()
        try:
            list_params = schemas.TenantListSchema().load(request.args)
        except ValidationError as e:
            raise exceptions.InvalidListParamException(e.messages)

        tenants = self.tenant_service.list_(scoping_tenant.uuid, **list_params)
        total = self.tenant_service.count(scoping_tenant.uuid,
                                          filtered=False,
                                          **list_params)
        filtered = self.tenant_service.count(scoping_tenant.uuid,
                                             filtered=True,
                                             **list_params)

        response = {'filtered': filtered, 'total': total, 'items': tenants}

        return response, 200
Esempio n. 11
0
    def get(self, tenant_uuid):
        scoping_tenant = Tenant.autodetect()
        try:
            list_params = schemas.TenantPolicyListSchema().load(request.args)
        except marshmallow.ValidationError as e:
            raise exceptions.InvalidListParamException(e.messages)

        list_params['scoping_tenant_uuid'] = scoping_tenant.uuid
        total = self.tenant_service.count_policies(
            tenant_uuid, filtered=False, **list_params
        )
        filtered = self.tenant_service.count_policies(
            tenant_uuid, filtered=True, **list_params
        )

        policies = self.tenant_service.list_policies(tenant_uuid, **list_params)
        result = PolicySchema(only=POLICY_FIELDS).dump(policies, many=True)
        return {'items': result, 'total': total, 'filtered': filtered}
Esempio n. 12
0
    def get(self, user_uuid):
        logger.debug('listing user %s policies', user_uuid)
        ListSchema = schemas.new_list_schema('name')
        list_params, errors = ListSchema().load(request.args)
        if errors:
            raise exceptions.InvalidListParamException(errors)

        return {
            'items':
            self.user_service.list_policies(user_uuid, **list_params),
            'total':
            self.user_service.count_policies(user_uuid,
                                             filtered=False,
                                             **list_params),
            'filtered':
            self.user_service.count_policies(user_uuid,
                                             filtered=True,
                                             **list_params),
        }, 200
Esempio n. 13
0
    def get(self):
        scoping_tenant = Tenant.autodetect()
        ListSchema = schemas.new_list_schema('name')
        list_params, errors = ListSchema().load(request.args)
        if errors:
            raise exceptions.InvalidListParamException(errors)

        list_params['scoping_tenant_uuid'] = scoping_tenant.uuid

        groups = self.group_service.list_(**list_params)
        total = self.group_service.count(filtered=False, **list_params)
        filtered = self.group_service.count(filtered=True, **list_params)

        response = {
            'filtered': filtered,
            'total': total,
            'items': groups,
        }

        return response, 200
Esempio n. 14
0
    def get(self, group_uuid):
        try:
            list_params = schemas.GroupUserListSchema().load(request.args)
        except marshmallow.ValidationError as e:
            raise exceptions.InvalidListParamException(e.messages)

        return (
            {
                'items':
                self.group_service.list_users(group_uuid, **list_params),
                'total':
                self.group_service.count_users(group_uuid,
                                               filtered=False,
                                               **list_params),
                'filtered':
                self.group_service.count_users(group_uuid,
                                               filtered=True,
                                               **list_params),
            },
            200,
        )
Esempio n. 15
0
    def get(self, tenant_uuid):
        scoping_tenant = Tenant.autodetect()
        ListSchema = schemas.new_list_schema('name')
        list_params, errors = ListSchema().load(request.args)
        if errors:
            raise exceptions.InvalidListParamException(errors)

        list_params['scoping_tenant_uuid'] = scoping_tenant.uuid
        total = self.tenant_service.count_policies(tenant_uuid,
                                                   filtered=False,
                                                   **list_params)
        filtered = self.tenant_service.count_policies(tenant_uuid,
                                                      filtered=True,
                                                      **list_params)

        return {
            'items': self.tenant_service.list_policies(tenant_uuid,
                                                       **list_params),
            'total': total,
            'filtered': filtered,
        }, 200
Esempio n. 16
0
    def get(self, user_uuid):
        try:
            list_params = schemas.ExternalListSchema().load(request.args)
        except marshmallow.ValidationError as e:
            raise exceptions.InvalidListParamException(e.messages)

        items = self.external_auth_service.list_(user_uuid, **list_params)
        total = self.external_auth_service.count(user_uuid,
                                                 filtered=False,
                                                 **list_params)
        filtered = self.external_auth_service.count(user_uuid,
                                                    filtered=True,
                                                    **list_params)

        for item in items:
            plugin_info = current_app.config['external_auth_plugin_info'][
                item['type']]
            item['plugin_info'] = plugin_info

        response = {'filtered': filtered, 'total': total, 'items': items}

        return response, 200
Esempio n. 17
0
    def get(self, tenant_uuid):
        scoping_tenant = Tenant.autodetect()
        ListSchema = schemas.new_list_schema('username')
        list_params, errors = ListSchema().load(request.args)
        if errors:
            raise exceptions.InvalidListParamException(errors)

        self.tenant_service.assert_tenant_under(scoping_tenant.uuid,
                                                tenant_uuid)

        return {
            'items':
            self.tenant_service.list_users(tenant_uuid, **list_params),
            'total':
            self.tenant_service.count_users(tenant_uuid,
                                            filtered=False,
                                            **list_params),
            'filtered':
            self.tenant_service.count_users(tenant_uuid,
                                            filtered=True,
                                            **list_params),
        }, 200
Esempio n. 18
0
    def get(self):
        try:
            list_params = schemas.GroupListSchema().load(request.args)
        except marshmallow.ValidationError as e:
            raise exceptions.InvalidListParamException(e.messages)

        recurse = list_params.pop('recurse')
        tenant_uuids = get_tenant_uuids(recurse=recurse)
        groups = self.group_service.list_(tenant_uuids=tenant_uuids,
                                          **list_params)
        total = self.group_service.count(
            tenant_uuids=tenant_uuids,
            filtered=False,
            **list_params,
        )
        filtered = self.group_service.count(
            tenant_uuids=tenant_uuids,
            filtered=True,
            **list_params,
        )
        response = {'filtered': filtered, 'total': total, 'items': groups}
        return response, 200
Esempio n. 19
0
    def get(self, user_uuid):
        logger.debug('listing user %s policies', user_uuid)
        try:
            list_params = schemas.UserPolicyListSchema().load(request.args)
        except marshmallow.ValidationError as e:
            raise exceptions.InvalidListParamException(e.messages)

        return (
            {
                'items':
                self.user_service.list_policies(user_uuid, **list_params),
                'total':
                self.user_service.count_policies(user_uuid,
                                                 filtered=False,
                                                 **list_params),
                'filtered':
                self.user_service.count_policies(user_uuid,
                                                 filtered=True,
                                                 **list_params),
            },
            200,
        )