@directus/api 20.1.0 → 21.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.js +5 -5
- package/dist/auth/drivers/ldap.js +5 -5
- package/dist/auth/drivers/local.js +4 -4
- package/dist/auth/drivers/oauth2.js +5 -5
- package/dist/auth/drivers/openid.js +3 -5
- package/dist/auth/drivers/saml.js +1 -1
- package/dist/auth.js +1 -1
- package/dist/cache.js +4 -1
- package/dist/cli/commands/bootstrap/index.js +9 -3
- package/dist/cli/commands/count/index.js +1 -1
- package/dist/cli/commands/database/install.js +1 -1
- package/dist/cli/commands/database/migrate.js +1 -1
- package/dist/cli/commands/init/index.js +9 -10
- package/dist/cli/commands/roles/create.js +1 -1
- package/dist/cli/commands/schema/apply.js +1 -1
- package/dist/cli/commands/schema/snapshot.js +1 -1
- package/dist/cli/commands/users/create.js +1 -1
- package/dist/cli/commands/users/passwd.js +1 -1
- package/dist/cli/load-extensions.js +1 -1
- package/dist/cli/utils/defaults.d.ts +4 -11
- package/dist/cli/utils/defaults.js +7 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +2 -2
- package/dist/controllers/access.d.ts +2 -0
- package/dist/controllers/access.js +148 -0
- package/dist/controllers/assets.js +1 -1
- package/dist/controllers/auth.js +6 -17
- package/dist/controllers/files.js +1 -1
- package/dist/controllers/permissions.js +14 -2
- package/dist/controllers/policies.d.ts +2 -0
- package/dist/controllers/policies.js +169 -0
- package/dist/controllers/roles.js +22 -1
- package/dist/controllers/schema.js +1 -1
- package/dist/controllers/tus.js +11 -23
- package/dist/controllers/users.js +0 -55
- package/dist/database/get-ast-from-query/get-ast-from-query.d.ts +16 -0
- package/dist/database/get-ast-from-query/get-ast-from-query.js +82 -0
- package/dist/database/get-ast-from-query/lib/convert-wildcards.d.ts +13 -0
- package/dist/database/get-ast-from-query/lib/convert-wildcards.js +69 -0
- package/dist/database/get-ast-from-query/lib/parse-fields.d.ts +15 -0
- package/dist/database/get-ast-from-query/lib/parse-fields.js +190 -0
- package/dist/database/get-ast-from-query/utils/get-deep-query.d.ts +14 -0
- package/dist/database/get-ast-from-query/utils/get-deep-query.js +17 -0
- package/dist/database/get-ast-from-query/utils/get-related-collection.d.ts +2 -0
- package/dist/database/get-ast-from-query/utils/get-related-collection.js +13 -0
- package/dist/database/get-ast-from-query/utils/get-relation.d.ts +2 -0
- package/dist/database/get-ast-from-query/utils/get-relation.js +7 -0
- package/dist/database/helpers/fn/types.d.ts +2 -1
- package/dist/database/helpers/fn/types.js +1 -1
- package/dist/database/helpers/geometry/dialects/mssql.d.ts +1 -1
- package/dist/database/helpers/geometry/dialects/mssql.js +4 -2
- package/dist/database/helpers/geometry/dialects/mysql.js +1 -1
- package/dist/database/helpers/geometry/dialects/oracle.d.ts +1 -1
- package/dist/database/helpers/geometry/dialects/oracle.js +5 -3
- package/dist/database/helpers/geometry/types.d.ts +1 -1
- package/dist/database/helpers/geometry/types.js +4 -2
- package/dist/database/index.js +3 -2
- package/dist/database/migrations/20210518A-add-foreign-key-constraints.js +1 -1
- package/dist/database/migrations/20210519A-add-system-fk-triggers.js +1 -1
- package/dist/database/migrations/20210802A-replace-groups.js +1 -1
- package/dist/database/migrations/20230721A-require-shares-fields.js +1 -1
- package/dist/database/migrations/20240710A-permissions-policies.d.ts +3 -0
- package/dist/database/migrations/20240710A-permissions-policies.js +169 -0
- package/dist/database/migrations/run.js +1 -1
- package/dist/database/run-ast/lib/get-db-query.d.ts +4 -0
- package/dist/database/run-ast/lib/get-db-query.js +208 -0
- package/dist/database/run-ast/lib/parse-current-level.d.ts +7 -0
- package/dist/database/run-ast/lib/parse-current-level.js +41 -0
- package/dist/database/run-ast/run-ast.d.ts +7 -0
- package/dist/database/run-ast/run-ast.js +107 -0
- package/dist/database/{run-ast.d.ts → run-ast/types.d.ts} +3 -9
- package/dist/database/run-ast/types.js +1 -0
- package/dist/database/run-ast/utils/apply-case-when.d.ts +16 -0
- package/dist/database/run-ast/utils/apply-case-when.js +26 -0
- package/dist/database/run-ast/utils/apply-parent-filters.d.ts +3 -0
- package/dist/database/run-ast/utils/apply-parent-filters.js +55 -0
- package/dist/database/run-ast/utils/get-column-pre-processor.d.ts +10 -0
- package/dist/database/run-ast/utils/get-column-pre-processor.js +57 -0
- package/dist/database/run-ast/utils/get-field-alias.d.ts +2 -0
- package/dist/database/run-ast/utils/get-field-alias.js +4 -0
- package/dist/database/run-ast/utils/get-inner-query-column-pre-processor.d.ts +5 -0
- package/dist/database/run-ast/utils/get-inner-query-column-pre-processor.js +23 -0
- package/dist/database/run-ast/utils/merge-with-parent-items.d.ts +3 -0
- package/dist/database/run-ast/utils/merge-with-parent-items.js +87 -0
- package/dist/database/run-ast/utils/remove-temporary-fields.d.ts +3 -0
- package/dist/database/run-ast/utils/remove-temporary-fields.js +73 -0
- package/dist/emitter.js +1 -1
- package/dist/extensions/lib/get-shared-deps-mapping.js +1 -1
- package/dist/extensions/lib/installation/manager.js +1 -1
- package/dist/extensions/lib/sandbox/register/call-reference.js +1 -1
- package/dist/extensions/lib/sandbox/sdk/generators/log.js +1 -1
- package/dist/extensions/lib/sync-extensions.js +1 -1
- package/dist/extensions/manager.js +1 -1
- package/dist/flows.js +4 -5
- package/dist/{logger.js → logger/index.js} +2 -8
- package/dist/logger/redact-query.d.ts +1 -0
- package/dist/logger/redact-query.js +13 -0
- package/dist/mailer.js +1 -1
- package/dist/middleware/authenticate.js +2 -7
- package/dist/middleware/cache.js +2 -2
- package/dist/middleware/error-handler.js +1 -1
- package/dist/middleware/rate-limiter-global.js +1 -1
- package/dist/middleware/respond.js +2 -2
- package/dist/operations/log/index.js +1 -1
- package/dist/operations/mail/index.js +1 -1
- package/dist/permissions/cache.d.ts +2 -0
- package/dist/permissions/cache.js +23 -0
- package/dist/permissions/lib/fetch-permissions.d.ts +10 -0
- package/dist/permissions/lib/fetch-permissions.js +55 -0
- package/dist/permissions/lib/fetch-policies.d.ts +7 -0
- package/dist/permissions/lib/fetch-policies.js +28 -0
- package/dist/permissions/lib/fetch-roles-tree.d.ts +3 -0
- package/dist/permissions/lib/fetch-roles-tree.js +28 -0
- package/dist/{services/permissions → permissions}/lib/with-app-minimal-permissions.d.ts +1 -1
- package/dist/permissions/lib/with-app-minimal-permissions.js +10 -0
- package/dist/permissions/modules/fetch-accountability-collection-access/fetch-accountability-collection-access.d.ts +7 -0
- package/dist/permissions/modules/fetch-accountability-collection-access/fetch-accountability-collection-access.js +56 -0
- package/dist/permissions/modules/fetch-accountability-policy-globals/fetch-accountability-policy-globals.d.ts +3 -0
- package/dist/permissions/modules/fetch-accountability-policy-globals/fetch-accountability-policy-globals.js +16 -0
- package/dist/permissions/modules/fetch-allowed-collections/fetch-allowed-collections.d.ts +8 -0
- package/dist/permissions/modules/fetch-allowed-collections/fetch-allowed-collections.js +24 -0
- package/dist/permissions/modules/fetch-allowed-field-map/fetch-allowed-field-map.d.ts +9 -0
- package/dist/permissions/modules/fetch-allowed-field-map/fetch-allowed-field-map.js +31 -0
- package/dist/permissions/modules/fetch-allowed-fields/fetch-allowed-fields.d.ts +16 -0
- package/dist/permissions/modules/fetch-allowed-fields/fetch-allowed-fields.js +27 -0
- package/dist/permissions/modules/fetch-global-access/fetch-global-access.d.ts +10 -0
- package/dist/permissions/modules/fetch-global-access/fetch-global-access.js +23 -0
- package/dist/permissions/modules/fetch-global-access/lib/fetch-global-access-for-roles.d.ts +5 -0
- package/dist/permissions/modules/fetch-global-access/lib/fetch-global-access-for-roles.js +7 -0
- package/dist/permissions/modules/fetch-global-access/lib/fetch-global-access-for-user.d.ts +5 -0
- package/dist/permissions/modules/fetch-global-access/lib/fetch-global-access-for-user.js +10 -0
- package/dist/permissions/modules/fetch-global-access/types.d.ts +4 -0
- package/dist/permissions/modules/fetch-global-access/types.js +1 -0
- package/dist/permissions/modules/fetch-global-access/utils/fetch-global-access-for-query.d.ts +4 -0
- package/dist/permissions/modules/fetch-global-access/utils/fetch-global-access-for-query.js +27 -0
- package/dist/permissions/modules/fetch-inconsistent-field-map/fetch-inconsistent-field-map.d.ts +12 -0
- package/dist/permissions/modules/fetch-inconsistent-field-map/fetch-inconsistent-field-map.js +32 -0
- package/dist/permissions/modules/fetch-policies-ip-access/fetch-policies-ip-access.d.ts +4 -0
- package/dist/permissions/modules/fetch-policies-ip-access/fetch-policies-ip-access.js +29 -0
- package/dist/permissions/modules/process-ast/lib/extract-fields-from-children.d.ts +4 -0
- package/dist/permissions/modules/process-ast/lib/extract-fields-from-children.js +49 -0
- package/dist/permissions/modules/process-ast/lib/extract-fields-from-query.d.ts +3 -0
- package/dist/permissions/modules/process-ast/lib/extract-fields-from-query.js +56 -0
- package/dist/permissions/modules/process-ast/lib/field-map-from-ast.d.ts +4 -0
- package/dist/permissions/modules/process-ast/lib/field-map-from-ast.js +8 -0
- package/dist/permissions/modules/process-ast/lib/inject-cases.d.ts +9 -0
- package/dist/permissions/modules/process-ast/lib/inject-cases.js +93 -0
- package/dist/permissions/modules/process-ast/process-ast.d.ts +9 -0
- package/dist/permissions/modules/process-ast/process-ast.js +39 -0
- package/dist/permissions/modules/process-ast/types.d.ts +24 -0
- package/dist/permissions/modules/process-ast/types.js +1 -0
- package/dist/permissions/modules/process-ast/utils/collections-in-field-map.d.ts +2 -0
- package/dist/permissions/modules/process-ast/utils/collections-in-field-map.js +7 -0
- package/dist/permissions/modules/process-ast/utils/dedupe-access.d.ts +12 -0
- package/dist/permissions/modules/process-ast/utils/dedupe-access.js +30 -0
- package/dist/permissions/modules/process-ast/utils/extract-paths-from-query.d.ts +15 -0
- package/dist/permissions/modules/process-ast/utils/extract-paths-from-query.js +50 -0
- package/dist/permissions/modules/process-ast/utils/find-related-collection.d.ts +3 -0
- package/dist/permissions/modules/process-ast/utils/find-related-collection.js +9 -0
- package/dist/permissions/modules/process-ast/utils/flatten-filter.d.ts +3 -0
- package/dist/permissions/modules/process-ast/utils/flatten-filter.js +34 -0
- package/dist/permissions/modules/process-ast/utils/format-a2o-key.d.ts +1 -0
- package/dist/permissions/modules/process-ast/utils/format-a2o-key.js +3 -0
- package/dist/permissions/modules/process-ast/utils/get-info-for-path.d.ts +5 -0
- package/dist/permissions/modules/process-ast/utils/get-info-for-path.js +7 -0
- package/dist/permissions/modules/process-ast/utils/has-item-permissions.d.ts +2 -0
- package/dist/permissions/modules/process-ast/utils/has-item-permissions.js +3 -0
- package/dist/permissions/modules/process-ast/utils/stringify-query-path.d.ts +2 -0
- package/dist/permissions/modules/process-ast/utils/stringify-query-path.js +3 -0
- package/dist/permissions/modules/process-ast/utils/validate-path/create-error.d.ts +3 -0
- package/dist/permissions/modules/process-ast/utils/validate-path/create-error.js +16 -0
- package/dist/permissions/modules/process-ast/utils/validate-path/validate-path-existence.d.ts +2 -0
- package/dist/permissions/modules/process-ast/utils/validate-path/validate-path-existence.js +12 -0
- package/dist/permissions/modules/process-ast/utils/validate-path/validate-path-permissions.d.ts +2 -0
- package/dist/permissions/modules/process-ast/utils/validate-path/validate-path-permissions.js +28 -0
- package/dist/permissions/modules/process-payload/lib/is-field-nullable.d.ts +5 -0
- package/dist/permissions/modules/process-payload/lib/is-field-nullable.js +12 -0
- package/dist/permissions/modules/process-payload/process-payload.d.ts +13 -0
- package/dist/permissions/modules/process-payload/process-payload.js +77 -0
- package/dist/permissions/modules/validate-access/lib/validate-collection-access.d.ts +12 -0
- package/dist/permissions/modules/validate-access/lib/validate-collection-access.js +11 -0
- package/dist/permissions/modules/validate-access/lib/validate-item-access.d.ts +9 -0
- package/dist/permissions/modules/validate-access/lib/validate-item-access.js +33 -0
- package/dist/permissions/modules/validate-access/validate-access.d.ts +14 -0
- package/dist/permissions/modules/validate-access/validate-access.js +28 -0
- package/dist/permissions/modules/validate-remaining-admin/validate-remaining-admin-count.d.ts +1 -0
- package/dist/permissions/modules/validate-remaining-admin/validate-remaining-admin-count.js +8 -0
- package/dist/permissions/modules/validate-remaining-admin/validate-remaining-admin-users.d.ts +5 -0
- package/dist/permissions/modules/validate-remaining-admin/validate-remaining-admin-users.js +10 -0
- package/dist/permissions/types.d.ts +6 -0
- package/dist/permissions/types.js +1 -0
- package/dist/permissions/utils/create-default-accountability.d.ts +2 -0
- package/dist/permissions/utils/create-default-accountability.js +11 -0
- package/dist/permissions/utils/extract-required-dynamic-variable-context.d.ts +8 -0
- package/dist/permissions/utils/extract-required-dynamic-variable-context.js +27 -0
- package/dist/permissions/utils/fetch-dynamic-variable-context.d.ts +9 -0
- package/dist/permissions/utils/fetch-dynamic-variable-context.js +43 -0
- package/dist/permissions/utils/filter-policies-by-ip.d.ts +2 -0
- package/dist/permissions/utils/filter-policies-by-ip.js +15 -0
- package/dist/permissions/utils/get-unaliased-field-key.d.ts +5 -0
- package/dist/permissions/utils/get-unaliased-field-key.js +17 -0
- package/dist/permissions/utils/process-permissions.d.ts +7 -0
- package/dist/permissions/utils/process-permissions.js +9 -0
- package/dist/permissions/utils/with-cache.d.ts +10 -0
- package/dist/permissions/utils/with-cache.js +25 -0
- package/dist/request/is-denied-ip.js +1 -1
- package/dist/server.js +1 -1
- package/dist/services/access.d.ts +10 -0
- package/dist/services/access.js +43 -0
- package/dist/services/activity.js +23 -11
- package/dist/services/assets.d.ts +2 -3
- package/dist/services/assets.js +11 -6
- package/dist/services/authentication.js +18 -18
- package/dist/services/collections.js +18 -17
- package/dist/services/fields.d.ts +0 -1
- package/dist/services/fields.js +53 -24
- package/dist/services/files/utils/get-metadata.js +1 -1
- package/dist/services/files.js +11 -4
- package/dist/services/graphql/index.d.ts +3 -3
- package/dist/services/graphql/index.js +126 -22
- package/dist/services/graphql/subscription.js +2 -4
- package/dist/services/graphql/utils/process-error.js +1 -1
- package/dist/services/graphql/utils/sanitize-gql-schema.js +1 -1
- package/dist/services/import-export.js +19 -5
- package/dist/services/index.d.ts +3 -2
- package/dist/services/index.js +3 -2
- package/dist/services/items.js +115 -44
- package/dist/services/mail/index.js +1 -1
- package/dist/services/meta.js +60 -23
- package/dist/services/notifications.js +15 -7
- package/dist/services/payload.d.ts +9 -10
- package/dist/services/payload.js +18 -3
- package/dist/services/{permissions/index.d.ts → permissions.d.ts} +5 -7
- package/dist/services/{permissions/index.js → permissions.js} +30 -54
- package/dist/services/policies.d.ts +12 -0
- package/dist/services/policies.js +87 -0
- package/dist/services/relations.d.ts +0 -6
- package/dist/services/relations.js +26 -29
- package/dist/services/roles.d.ts +4 -12
- package/dist/services/roles.js +57 -424
- package/dist/services/server.js +1 -1
- package/dist/services/shares.d.ts +0 -2
- package/dist/services/shares.js +13 -9
- package/dist/services/specifications.d.ts +2 -2
- package/dist/services/specifications.js +39 -27
- package/dist/services/tus/data-store.js +1 -1
- package/dist/services/users.d.ts +1 -5
- package/dist/services/users.js +79 -162
- package/dist/services/utils.js +11 -7
- package/dist/services/versions.d.ts +0 -2
- package/dist/services/versions.js +34 -10
- package/dist/services/webhooks.js +1 -1
- package/dist/telemetry/lib/get-report.js +2 -2
- package/dist/telemetry/lib/track.js +1 -1
- package/dist/telemetry/utils/check-user-limits.d.ts +5 -0
- package/dist/telemetry/utils/check-user-limits.js +19 -0
- package/dist/types/ast.d.ts +43 -1
- package/dist/types/items.d.ts +11 -0
- package/dist/utils/apply-diff.js +1 -1
- package/dist/utils/apply-query.d.ts +4 -3
- package/dist/utils/apply-query.js +37 -8
- package/dist/utils/delete-from-require-cache.js +1 -1
- package/dist/utils/fetch-user-count/fetch-access-lookup.d.ts +17 -0
- package/dist/utils/fetch-user-count/fetch-access-lookup.js +22 -0
- package/dist/utils/fetch-user-count/fetch-access-roles.d.ts +16 -0
- package/dist/utils/fetch-user-count/fetch-access-roles.js +37 -0
- package/dist/utils/fetch-user-count/fetch-active-users.d.ts +6 -0
- package/dist/utils/fetch-user-count/fetch-active-users.js +3 -0
- package/dist/utils/fetch-user-count/fetch-user-count.d.ts +12 -0
- package/dist/utils/fetch-user-count/fetch-user-count.js +57 -0
- package/dist/utils/fetch-user-count/get-user-count-query.d.ts +20 -0
- package/dist/utils/fetch-user-count/get-user-count-query.js +17 -0
- package/dist/utils/get-accountability-for-role.js +16 -25
- package/dist/utils/get-accountability-for-token.js +17 -16
- package/dist/utils/get-cache-key.d.ts +1 -1
- package/dist/utils/get-cache-key.js +12 -1
- package/dist/utils/get-column.d.ts +2 -1
- package/dist/utils/get-column.js +1 -0
- package/dist/utils/get-default-value.js +1 -1
- package/dist/utils/get-ip-from-req.js +1 -1
- package/dist/utils/get-schema.js +1 -1
- package/dist/utils/get-service.js +5 -1
- package/dist/utils/is-url-allowed.js +1 -1
- package/dist/utils/reduce-schema.d.ts +4 -6
- package/dist/utils/reduce-schema.js +16 -32
- package/dist/utils/sanitize-query.js +1 -1
- package/dist/utils/transaction.js +1 -1
- package/dist/utils/validate-env.js +1 -1
- package/dist/utils/validate-storage.js +1 -1
- package/dist/utils/validate-user-count-integrity.d.ts +13 -0
- package/dist/utils/validate-user-count-integrity.js +29 -0
- package/dist/websocket/authenticate.d.ts +0 -2
- package/dist/websocket/authenticate.js +0 -12
- package/dist/websocket/controllers/base.js +1 -1
- package/dist/websocket/controllers/graphql.js +2 -5
- package/dist/websocket/controllers/hooks.js +4 -0
- package/dist/websocket/controllers/rest.js +1 -3
- package/dist/websocket/errors.js +1 -1
- package/dist/websocket/handlers/subscribe.js +0 -2
- package/dist/websocket/utils/items.d.ts +1 -1
- package/package.json +24 -23
- package/dist/database/run-ast.js +0 -458
- package/dist/middleware/check-ip.d.ts +0 -2
- package/dist/middleware/check-ip.js +0 -37
- package/dist/middleware/get-permissions.d.ts +0 -3
- package/dist/middleware/get-permissions.js +0 -10
- package/dist/services/authorization.d.ts +0 -17
- package/dist/services/authorization.js +0 -456
- package/dist/services/permissions/lib/with-app-minimal-permissions.js +0 -13
- package/dist/telemetry/utils/check-increased-user-limits.d.ts +0 -7
- package/dist/telemetry/utils/check-increased-user-limits.js +0 -25
- package/dist/telemetry/utils/get-role-counts-by-roles.d.ts +0 -6
- package/dist/telemetry/utils/get-role-counts-by-roles.js +0 -27
- package/dist/telemetry/utils/get-role-counts-by-users.d.ts +0 -11
- package/dist/telemetry/utils/get-role-counts-by-users.js +0 -34
- package/dist/telemetry/utils/get-user-count.d.ts +0 -8
- package/dist/telemetry/utils/get-user-count.js +0 -33
- package/dist/telemetry/utils/get-user-counts-by-roles.d.ts +0 -7
- package/dist/telemetry/utils/get-user-counts-by-roles.js +0 -35
- package/dist/utils/get-ast-from-query.d.ts +0 -13
- package/dist/utils/get-ast-from-query.js +0 -297
- package/dist/utils/get-permissions.d.ts +0 -2
- package/dist/utils/get-permissions.js +0 -150
- package/dist/utils/merge-permissions-for-share.d.ts +0 -4
- package/dist/utils/merge-permissions-for-share.js +0 -109
- package/dist/utils/merge-permissions.d.ts +0 -3
- package/dist/utils/merge-permissions.js +0 -95
- /package/dist/{logger.d.ts → logger/index.d.ts} +0 -0
package/dist/services/fields.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DEFAULT_NUMERIC_PRECISION, DEFAULT_NUMERIC_SCALE, KNEX_TYPES, REGEX_BETWEEN_PARENS, } from '@directus/constants';
|
|
2
2
|
import { ForbiddenError, InvalidPayloadError } from '@directus/errors';
|
|
3
3
|
import { createInspector } from '@directus/schema';
|
|
4
4
|
import { addFieldFlag, toArray } from '@directus/utils';
|
|
@@ -9,6 +9,9 @@ import { translateDatabaseError } from '../database/errors/translate.js';
|
|
|
9
9
|
import { getHelpers } from '../database/helpers/index.js';
|
|
10
10
|
import getDatabase, { getSchemaInspector } from '../database/index.js';
|
|
11
11
|
import emitter from '../emitter.js';
|
|
12
|
+
import { fetchPermissions } from '../permissions/lib/fetch-permissions.js';
|
|
13
|
+
import { fetchPolicies } from '../permissions/lib/fetch-policies.js';
|
|
14
|
+
import { validateAccess } from '../permissions/modules/validate-access/validate-access.js';
|
|
12
15
|
import getDefaultValue from '../utils/get-default-value.js';
|
|
13
16
|
import { getSystemFieldRowsWithAuthProviders } from '../utils/get-field-system-rows.js';
|
|
14
17
|
import getLocalType from '../utils/get-local-type.js';
|
|
@@ -42,15 +45,17 @@ export class FieldsService {
|
|
|
42
45
|
this.cache = cache;
|
|
43
46
|
this.systemCache = systemCache;
|
|
44
47
|
}
|
|
45
|
-
get hasReadAccess() {
|
|
46
|
-
return !!this.accountability?.permissions?.find((permission) => {
|
|
47
|
-
return permission.collection === 'directus_fields' && permission.action === 'read';
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
48
|
async readAll(collection) {
|
|
51
49
|
let fields;
|
|
52
|
-
if (this.accountability
|
|
53
|
-
|
|
50
|
+
if (this.accountability) {
|
|
51
|
+
await validateAccess({
|
|
52
|
+
accountability: this.accountability,
|
|
53
|
+
action: 'read',
|
|
54
|
+
collection: 'directus_fields',
|
|
55
|
+
}, {
|
|
56
|
+
schema: this.schema,
|
|
57
|
+
knex: this.knex,
|
|
58
|
+
});
|
|
54
59
|
}
|
|
55
60
|
const nonAuthorizedItemsService = new ItemsService('directus_fields', {
|
|
56
61
|
knex: this.knex,
|
|
@@ -119,12 +124,27 @@ export class FieldsService {
|
|
|
119
124
|
const result = [...columnsWithSystem, ...aliasFieldsAsField].filter((field) => knownCollections.includes(field.collection));
|
|
120
125
|
// Filter the result so we only return the fields you have read access to
|
|
121
126
|
if (this.accountability && this.accountability.admin !== true) {
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
127
|
+
const policies = await fetchPolicies(this.accountability, { knex: this.knex, schema: this.schema });
|
|
128
|
+
const permissions = await fetchPermissions(collection
|
|
129
|
+
? {
|
|
130
|
+
action: 'read',
|
|
131
|
+
policies,
|
|
132
|
+
collections: [collection],
|
|
133
|
+
accountability: this.accountability,
|
|
134
|
+
}
|
|
135
|
+
: {
|
|
136
|
+
action: 'read',
|
|
137
|
+
policies,
|
|
138
|
+
accountability: this.accountability,
|
|
139
|
+
}, { knex: this.knex, schema: this.schema });
|
|
125
140
|
const allowedFieldsInCollection = {};
|
|
126
141
|
permissions.forEach((permission) => {
|
|
127
|
-
allowedFieldsInCollection[permission.collection]
|
|
142
|
+
if (!allowedFieldsInCollection[permission.collection]) {
|
|
143
|
+
allowedFieldsInCollection[permission.collection] = new Set();
|
|
144
|
+
}
|
|
145
|
+
for (const field of permission.fields ?? []) {
|
|
146
|
+
allowedFieldsInCollection[permission.collection].add(field);
|
|
147
|
+
}
|
|
128
148
|
});
|
|
129
149
|
if (collection && collection in allowedFieldsInCollection === false) {
|
|
130
150
|
throw new ForbiddenError();
|
|
@@ -133,9 +153,9 @@ export class FieldsService {
|
|
|
133
153
|
if (field.collection in allowedFieldsInCollection === false)
|
|
134
154
|
return false;
|
|
135
155
|
const allowedFields = allowedFieldsInCollection[field.collection];
|
|
136
|
-
if (allowedFields
|
|
156
|
+
if (allowedFields.has('*'))
|
|
137
157
|
return true;
|
|
138
|
-
return allowedFields.
|
|
158
|
+
return allowedFields.has(field.field);
|
|
139
159
|
});
|
|
140
160
|
}
|
|
141
161
|
// Update specific database type overrides
|
|
@@ -152,18 +172,27 @@ export class FieldsService {
|
|
|
152
172
|
}
|
|
153
173
|
async readOne(collection, field) {
|
|
154
174
|
if (this.accountability && this.accountability.admin !== true) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
175
|
+
await validateAccess({
|
|
176
|
+
accountability: this.accountability,
|
|
177
|
+
action: 'read',
|
|
178
|
+
collection,
|
|
179
|
+
}, {
|
|
180
|
+
schema: this.schema,
|
|
181
|
+
knex: this.knex,
|
|
160
182
|
});
|
|
161
|
-
|
|
183
|
+
const policies = await fetchPolicies(this.accountability, { knex: this.knex, schema: this.schema });
|
|
184
|
+
const permissions = await fetchPermissions({ action: 'read', policies, collections: [collection], accountability: this.accountability }, { knex: this.knex, schema: this.schema });
|
|
185
|
+
let hasAccess = false;
|
|
186
|
+
for (const permission of permissions) {
|
|
187
|
+
if (permission.fields) {
|
|
188
|
+
if (permission.fields.includes('*') || permission.fields.includes(field)) {
|
|
189
|
+
hasAccess = true;
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (!hasAccess) {
|
|
162
195
|
throw new ForbiddenError();
|
|
163
|
-
if (permissions.fields.includes('*') === false) {
|
|
164
|
-
const allowedFields = permissions.fields;
|
|
165
|
-
if (allowedFields.includes(field) === false)
|
|
166
|
-
throw new ForbiddenError();
|
|
167
196
|
}
|
|
168
197
|
}
|
|
169
198
|
let column = undefined;
|
|
@@ -4,7 +4,7 @@ import { pick } from 'lodash-es';
|
|
|
4
4
|
import { pipeline } from 'node:stream/promises';
|
|
5
5
|
import sharp from 'sharp';
|
|
6
6
|
import { useEnv } from '@directus/env';
|
|
7
|
-
import { useLogger } from '../../../logger.js';
|
|
7
|
+
import { useLogger } from '../../../logger/index.js';
|
|
8
8
|
import { parseIptc, parseXmp } from './parse-image-metadata.js';
|
|
9
9
|
const env = useEnv();
|
|
10
10
|
const logger = useLogger();
|
package/dist/services/files.js
CHANGED
|
@@ -11,7 +11,8 @@ import path from 'path';
|
|
|
11
11
|
import url from 'url';
|
|
12
12
|
import { RESUMABLE_UPLOADS } from '../constants.js';
|
|
13
13
|
import emitter from '../emitter.js';
|
|
14
|
-
import { useLogger } from '../logger.js';
|
|
14
|
+
import { useLogger } from '../logger/index.js';
|
|
15
|
+
import { validateAccess } from '../permissions/modules/validate-access/validate-access.js';
|
|
15
16
|
import { getAxios } from '../request/index.js';
|
|
16
17
|
import { getStorage } from '../storage/index.js';
|
|
17
18
|
import { extractMetadata } from './files/lib/extract-metadata.js';
|
|
@@ -152,9 +153,15 @@ export class FilesService extends ItemsService {
|
|
|
152
153
|
* Import a single file from an external URL
|
|
153
154
|
*/
|
|
154
155
|
async importOne(importURL, body) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
if (this.accountability) {
|
|
157
|
+
await validateAccess({
|
|
158
|
+
accountability: this.accountability,
|
|
159
|
+
action: 'create',
|
|
160
|
+
collection: 'directus_files',
|
|
161
|
+
}, {
|
|
162
|
+
knex: this.knex,
|
|
163
|
+
schema: this.schema,
|
|
164
|
+
});
|
|
158
165
|
}
|
|
159
166
|
let fileResponse;
|
|
160
167
|
try {
|
|
@@ -20,9 +20,9 @@ export declare class GraphQLService {
|
|
|
20
20
|
/**
|
|
21
21
|
* Generate the GraphQL schema. Pulls from the schema information generated by the get-schema util.
|
|
22
22
|
*/
|
|
23
|
-
getSchema(): GraphQLSchema
|
|
24
|
-
getSchema(type: 'schema'): GraphQLSchema
|
|
25
|
-
getSchema(type: 'sdl'): GraphQLSchema | string
|
|
23
|
+
getSchema(): Promise<GraphQLSchema>;
|
|
24
|
+
getSchema(type: 'schema'): Promise<GraphQLSchema>;
|
|
25
|
+
getSchema(type: 'sdl'): Promise<GraphQLSchema | string>;
|
|
26
26
|
/**
|
|
27
27
|
* Generic resolver that's used for every "regular" items/system query. Converts the incoming GraphQL AST / fragments into
|
|
28
28
|
* Directus' query structure which is then executed by the services.
|
|
@@ -11,6 +11,9 @@ import { clearSystemCache, getCache } from '../../cache.js';
|
|
|
11
11
|
import { DEFAULT_AUTH_PROVIDER, GENERATE_SPECIAL, REFRESH_COOKIE_OPTIONS, SESSION_COOKIE_OPTIONS, } from '../../constants.js';
|
|
12
12
|
import getDatabase from '../../database/index.js';
|
|
13
13
|
import { rateLimiter } from '../../middleware/rate-limiter-registration.js';
|
|
14
|
+
import { fetchAllowedFieldMap } from '../../permissions/modules/fetch-allowed-field-map/fetch-allowed-field-map.js';
|
|
15
|
+
import { fetchInconsistentFieldMap } from '../../permissions/modules/fetch-inconsistent-field-map/fetch-inconsistent-field-map.js';
|
|
16
|
+
import { createDefaultAccountability } from '../../permissions/utils/create-default-accountability.js';
|
|
14
17
|
import { generateHash } from '../../utils/generate-hash.js';
|
|
15
18
|
import { getGraphQLType } from '../../utils/get-graphql-type.js';
|
|
16
19
|
import { getIPFromReq } from '../../utils/get-ip-from-req.js';
|
|
@@ -48,6 +51,9 @@ import { GraphQLVoid } from './types/void.js';
|
|
|
48
51
|
import { addPathToValidationError } from './utils/add-path-to-validation-error.js';
|
|
49
52
|
import processError from './utils/process-error.js';
|
|
50
53
|
import { sanitizeGraphqlSchema } from './utils/sanitize-gql-schema.js';
|
|
54
|
+
import { fetchAccountabilityCollectionAccess } from '../../permissions/modules/fetch-accountability-collection-access/fetch-accountability-collection-access.js';
|
|
55
|
+
import { fetchAccountabilityPolicyGlobals } from '../../permissions/modules/fetch-accountability-policy-globals/fetch-accountability-policy-globals.js';
|
|
56
|
+
import { RolesService } from '../roles.js';
|
|
51
57
|
const env = useEnv();
|
|
52
58
|
const validationRules = Array.from(specifiedRules);
|
|
53
59
|
if (env['GRAPHQL_INTROSPECTION'] === false) {
|
|
@@ -80,7 +86,7 @@ export class GraphQLService {
|
|
|
80
86
|
* Execute a GraphQL structure
|
|
81
87
|
*/
|
|
82
88
|
async execute({ document, variables, operationName, contextValue, }) {
|
|
83
|
-
const schema = this.getSchema();
|
|
89
|
+
const schema = await this.getSchema();
|
|
84
90
|
const validationErrors = validate(schema, document, validationRules).map((validationError) => addPathToValidationError(validationError));
|
|
85
91
|
if (validationErrors.length > 0) {
|
|
86
92
|
throw new GraphQLValidationError({ errors: validationErrors });
|
|
@@ -108,7 +114,7 @@ export class GraphQLService {
|
|
|
108
114
|
formattedResult.extensions = result['extensions'];
|
|
109
115
|
return formattedResult;
|
|
110
116
|
}
|
|
111
|
-
getSchema(type = 'schema') {
|
|
117
|
+
async getSchema(type = 'schema') {
|
|
112
118
|
const key = `${this.scope}_${type}_${this.accountability?.role}_${this.accountability?.user}`;
|
|
113
119
|
const cachedSchema = cache.get(key);
|
|
114
120
|
if (cachedSchema)
|
|
@@ -116,20 +122,53 @@ export class GraphQLService {
|
|
|
116
122
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
117
123
|
const self = this;
|
|
118
124
|
const schemaComposer = new SchemaComposer();
|
|
125
|
+
let schema;
|
|
119
126
|
const sanitizedSchema = sanitizeGraphqlSchema(this.schema);
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
:
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
127
|
+
if (!this.accountability || this.accountability.admin) {
|
|
128
|
+
schema = {
|
|
129
|
+
read: sanitizedSchema,
|
|
130
|
+
create: sanitizedSchema,
|
|
131
|
+
update: sanitizedSchema,
|
|
132
|
+
delete: sanitizedSchema,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
schema = {
|
|
137
|
+
read: reduceSchema(sanitizedSchema, await fetchAllowedFieldMap({
|
|
138
|
+
accountability: this.accountability,
|
|
139
|
+
action: 'read',
|
|
140
|
+
}, { schema: this.schema, knex: this.knex })),
|
|
141
|
+
create: reduceSchema(sanitizedSchema, await fetchAllowedFieldMap({
|
|
142
|
+
accountability: this.accountability,
|
|
143
|
+
action: 'create',
|
|
144
|
+
}, { schema: this.schema, knex: this.knex })),
|
|
145
|
+
update: reduceSchema(sanitizedSchema, await fetchAllowedFieldMap({
|
|
146
|
+
accountability: this.accountability,
|
|
147
|
+
action: 'update',
|
|
148
|
+
}, { schema: this.schema, knex: this.knex })),
|
|
149
|
+
delete: reduceSchema(sanitizedSchema, await fetchAllowedFieldMap({
|
|
150
|
+
accountability: this.accountability,
|
|
151
|
+
action: 'delete',
|
|
152
|
+
}, { schema: this.schema, knex: this.knex })),
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
const inconsistentFields = {
|
|
156
|
+
read: await fetchInconsistentFieldMap({
|
|
157
|
+
accountability: this.accountability,
|
|
158
|
+
action: 'read',
|
|
159
|
+
}, { schema: this.schema, knex: this.knex }),
|
|
160
|
+
create: await fetchInconsistentFieldMap({
|
|
161
|
+
accountability: this.accountability,
|
|
162
|
+
action: 'create',
|
|
163
|
+
}, { schema: this.schema, knex: this.knex }),
|
|
164
|
+
update: await fetchInconsistentFieldMap({
|
|
165
|
+
accountability: this.accountability,
|
|
166
|
+
action: 'update',
|
|
167
|
+
}, { schema: this.schema, knex: this.knex }),
|
|
168
|
+
delete: await fetchInconsistentFieldMap({
|
|
169
|
+
accountability: this.accountability,
|
|
170
|
+
action: 'delete',
|
|
171
|
+
}, { schema: this.schema, knex: this.knex }),
|
|
133
172
|
};
|
|
134
173
|
const subscriptionEventType = schemaComposer.createEnumTC({
|
|
135
174
|
name: 'EventEnum',
|
|
@@ -300,16 +339,18 @@ export class GraphQLService {
|
|
|
300
339
|
name: action === 'read' ? collection.collection : `${action}_${collection.collection}`,
|
|
301
340
|
fields: Object.values(collection.fields).reduce((acc, field) => {
|
|
302
341
|
let type = getGraphQLType(field.type, field.special);
|
|
342
|
+
const fieldIsInconsistent = inconsistentFields[action][collection.collection]?.includes(field.field);
|
|
303
343
|
// GraphQL doesn't differentiate between not-null and has-to-be-submitted. We
|
|
304
344
|
// can't non-null in update, as that would require every not-nullable field to be
|
|
305
345
|
// submitted on updates
|
|
306
346
|
if (field.nullable === false &&
|
|
307
347
|
!field.defaultValue &&
|
|
308
348
|
!GENERATE_SPECIAL.some((flag) => field.special.includes(flag)) &&
|
|
349
|
+
fieldIsInconsistent === false &&
|
|
309
350
|
action !== 'update') {
|
|
310
351
|
type = new GraphQLNonNull(type);
|
|
311
352
|
}
|
|
312
|
-
if (collection.primary === field.field) {
|
|
353
|
+
if (collection.primary === field.field && fieldIsInconsistent === false) {
|
|
313
354
|
// permissions IDs need to be nullable https://github.com/directus/directus/issues/20509
|
|
314
355
|
if (collection.collection === 'directus_permissions') {
|
|
315
356
|
type = GraphQLID;
|
|
@@ -1762,7 +1803,7 @@ export class GraphQLService {
|
|
|
1762
1803
|
accountability: this.accountability,
|
|
1763
1804
|
scope: args['scope'] ?? 'items',
|
|
1764
1805
|
});
|
|
1765
|
-
return service.getSchema('sdl');
|
|
1806
|
+
return await service.getSchema('sdl');
|
|
1766
1807
|
},
|
|
1767
1808
|
},
|
|
1768
1809
|
server_ping: {
|
|
@@ -1815,7 +1856,7 @@ export class GraphQLService {
|
|
|
1815
1856
|
otp: GraphQLString,
|
|
1816
1857
|
},
|
|
1817
1858
|
resolve: async (_, args, { req, res }) => {
|
|
1818
|
-
const accountability =
|
|
1859
|
+
const accountability = createDefaultAccountability();
|
|
1819
1860
|
if (req?.ip)
|
|
1820
1861
|
accountability.ip = req.ip;
|
|
1821
1862
|
const userAgent = req?.get('user-agent');
|
|
@@ -1855,7 +1896,7 @@ export class GraphQLService {
|
|
|
1855
1896
|
mode: AuthMode,
|
|
1856
1897
|
},
|
|
1857
1898
|
resolve: async (_, args, { req, res }) => {
|
|
1858
|
-
const accountability =
|
|
1899
|
+
const accountability = createDefaultAccountability();
|
|
1859
1900
|
if (req?.ip)
|
|
1860
1901
|
accountability.ip = req.ip;
|
|
1861
1902
|
const userAgent = req?.get('user-agent');
|
|
@@ -1913,7 +1954,7 @@ export class GraphQLService {
|
|
|
1913
1954
|
mode: AuthMode,
|
|
1914
1955
|
},
|
|
1915
1956
|
resolve: async (_, args, { req, res }) => {
|
|
1916
|
-
const accountability =
|
|
1957
|
+
const accountability = createDefaultAccountability();
|
|
1917
1958
|
if (req?.ip)
|
|
1918
1959
|
accountability.ip = req.ip;
|
|
1919
1960
|
const userAgent = req?.get('user-agent');
|
|
@@ -1963,7 +2004,7 @@ export class GraphQLService {
|
|
|
1963
2004
|
reset_url: GraphQLString,
|
|
1964
2005
|
},
|
|
1965
2006
|
resolve: async (_, args, { req }) => {
|
|
1966
|
-
const accountability =
|
|
2007
|
+
const accountability = createDefaultAccountability();
|
|
1967
2008
|
if (req?.ip)
|
|
1968
2009
|
accountability.ip = req.ip;
|
|
1969
2010
|
const userAgent = req?.get('user-agent');
|
|
@@ -1991,7 +2032,7 @@ export class GraphQLService {
|
|
|
1991
2032
|
password: new GraphQLNonNull(GraphQLString),
|
|
1992
2033
|
},
|
|
1993
2034
|
resolve: async (_, args, { req }) => {
|
|
1994
|
-
const accountability =
|
|
2035
|
+
const accountability = createDefaultAccountability();
|
|
1995
2036
|
if (req?.ip)
|
|
1996
2037
|
accountability.ip = req.ip;
|
|
1997
2038
|
const userAgent = req?.get('user-agent');
|
|
@@ -2632,6 +2673,69 @@ export class GraphQLService {
|
|
|
2632
2673
|
},
|
|
2633
2674
|
});
|
|
2634
2675
|
}
|
|
2676
|
+
if ('directus_permissions' in schema.read.collections) {
|
|
2677
|
+
schemaComposer.Query.addFields({
|
|
2678
|
+
permissions_me: {
|
|
2679
|
+
type: schemaComposer.createScalarTC({
|
|
2680
|
+
name: 'permissions_me_type',
|
|
2681
|
+
parseValue: (value) => value,
|
|
2682
|
+
serialize: (value) => value,
|
|
2683
|
+
}),
|
|
2684
|
+
resolve: async (_, _args, __, _info) => {
|
|
2685
|
+
if (!this.accountability?.user && !this.accountability?.role)
|
|
2686
|
+
return null;
|
|
2687
|
+
const result = await fetchAccountabilityCollectionAccess(this.accountability, {
|
|
2688
|
+
schema: this.schema,
|
|
2689
|
+
knex: getDatabase(),
|
|
2690
|
+
});
|
|
2691
|
+
return result;
|
|
2692
|
+
},
|
|
2693
|
+
},
|
|
2694
|
+
});
|
|
2695
|
+
}
|
|
2696
|
+
if ('directus_roles' in schema.read.collections) {
|
|
2697
|
+
schemaComposer.Query.addFields({
|
|
2698
|
+
roles_me: {
|
|
2699
|
+
type: ReadCollectionTypes['directus_roles'].List,
|
|
2700
|
+
resolve: async (_, args, __, info) => {
|
|
2701
|
+
if (!this.accountability?.user && !this.accountability?.role)
|
|
2702
|
+
return null;
|
|
2703
|
+
const service = new RolesService({
|
|
2704
|
+
accountability: this.accountability,
|
|
2705
|
+
schema: this.schema,
|
|
2706
|
+
});
|
|
2707
|
+
const selections = this.replaceFragmentsInSelections(info.fieldNodes[0]?.selectionSet?.selections, info.fragments);
|
|
2708
|
+
const query = this.getQuery(args, selections || [], info.variableValues);
|
|
2709
|
+
query.limit = -1;
|
|
2710
|
+
const roles = await service.readMany(this.accountability.roles, query);
|
|
2711
|
+
return roles;
|
|
2712
|
+
},
|
|
2713
|
+
},
|
|
2714
|
+
});
|
|
2715
|
+
}
|
|
2716
|
+
if ('directus_policies' in schema.read.collections) {
|
|
2717
|
+
schemaComposer.Query.addFields({
|
|
2718
|
+
policies_me_globals: {
|
|
2719
|
+
type: schemaComposer.createObjectTC({
|
|
2720
|
+
name: 'policy_me_globals_type',
|
|
2721
|
+
fields: {
|
|
2722
|
+
enforce_tfa: 'Boolean',
|
|
2723
|
+
app_access: 'Boolean',
|
|
2724
|
+
admin_access: 'Boolean',
|
|
2725
|
+
},
|
|
2726
|
+
}),
|
|
2727
|
+
resolve: async (_, _args, __, _info) => {
|
|
2728
|
+
if (!this.accountability?.user && !this.accountability?.role)
|
|
2729
|
+
return null;
|
|
2730
|
+
const result = await fetchAccountabilityPolicyGlobals(this.accountability, {
|
|
2731
|
+
schema: this.schema,
|
|
2732
|
+
knex: getDatabase(),
|
|
2733
|
+
});
|
|
2734
|
+
return result;
|
|
2735
|
+
},
|
|
2736
|
+
},
|
|
2737
|
+
});
|
|
2738
|
+
}
|
|
2635
2739
|
if ('directus_users' in schema.update.collections && this.accountability?.user) {
|
|
2636
2740
|
schemaComposer.Mutation.addFields({
|
|
2637
2741
|
update_users_me: {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { EventEmitter, on } from 'events';
|
|
2
2
|
import { useBus } from '../../bus/index.js';
|
|
3
3
|
import { getSchema } from '../../utils/get-schema.js';
|
|
4
|
-
import { refreshAccountability } from '../../websocket/authenticate.js';
|
|
5
4
|
import { getPayload } from '../../websocket/utils/items.js';
|
|
6
5
|
const messages = createPubSub(new EventEmitter());
|
|
7
6
|
export function bindPubSub() {
|
|
@@ -19,7 +18,6 @@ export function createSubscriptionGenerator(self, event) {
|
|
|
19
18
|
if ('event' in args && eventData['action'] !== args['event']) {
|
|
20
19
|
continue; // skip filtered events
|
|
21
20
|
}
|
|
22
|
-
const accountability = await refreshAccountability(self.accountability);
|
|
23
21
|
const schema = await getSchema();
|
|
24
22
|
const subscription = {
|
|
25
23
|
collection: eventData['collection'],
|
|
@@ -35,7 +33,7 @@ export function createSubscriptionGenerator(self, event) {
|
|
|
35
33
|
if (eventData['action'] === 'create') {
|
|
36
34
|
try {
|
|
37
35
|
subscription.item = eventData['key'];
|
|
38
|
-
const result = await getPayload(subscription, accountability, schema, eventData);
|
|
36
|
+
const result = await getPayload(subscription, self.accountability, schema, eventData);
|
|
39
37
|
yield {
|
|
40
38
|
[event]: {
|
|
41
39
|
key: eventData['key'],
|
|
@@ -52,7 +50,7 @@ export function createSubscriptionGenerator(self, event) {
|
|
|
52
50
|
for (const key of eventData['keys']) {
|
|
53
51
|
try {
|
|
54
52
|
subscription.item = key;
|
|
55
|
-
const result = await getPayload(subscription, accountability, schema, eventData);
|
|
53
|
+
const result = await getPayload(subscription, self.accountability, schema, eventData);
|
|
56
54
|
yield {
|
|
57
55
|
[event]: {
|
|
58
56
|
key,
|
|
@@ -14,7 +14,8 @@ import Papa from 'papaparse';
|
|
|
14
14
|
import StreamArray from 'stream-json/streamers/StreamArray.js';
|
|
15
15
|
import getDatabase from '../database/index.js';
|
|
16
16
|
import emitter from '../emitter.js';
|
|
17
|
-
import { useLogger } from '../logger.js';
|
|
17
|
+
import { useLogger } from '../logger/index.js';
|
|
18
|
+
import { validateAccess } from '../permissions/modules/validate-access/validate-access.js';
|
|
18
19
|
import { getDateFormatted } from '../utils/get-date-formatted.js';
|
|
19
20
|
import { getService } from '../utils/get-service.js';
|
|
20
21
|
import { transaction } from '../utils/transaction.js';
|
|
@@ -37,10 +38,23 @@ export class ImportService {
|
|
|
37
38
|
async import(collection, mimetype, stream) {
|
|
38
39
|
if (this.accountability?.admin !== true && isSystemCollection(collection))
|
|
39
40
|
throw new ForbiddenError();
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
if (this.accountability) {
|
|
42
|
+
await validateAccess({
|
|
43
|
+
accountability: this.accountability,
|
|
44
|
+
action: 'create',
|
|
45
|
+
collection,
|
|
46
|
+
}, {
|
|
47
|
+
schema: this.schema,
|
|
48
|
+
knex: this.knex,
|
|
49
|
+
});
|
|
50
|
+
await validateAccess({
|
|
51
|
+
accountability: this.accountability,
|
|
52
|
+
action: 'update',
|
|
53
|
+
collection,
|
|
54
|
+
}, {
|
|
55
|
+
schema: this.schema,
|
|
56
|
+
knex: this.knex,
|
|
57
|
+
});
|
|
44
58
|
}
|
|
45
59
|
switch (mimetype) {
|
|
46
60
|
case 'application/json':
|
package/dist/services/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
export * from './access.js';
|
|
1
2
|
export * from './activity.js';
|
|
2
3
|
export * from './assets.js';
|
|
3
4
|
export * from './authentication.js';
|
|
4
|
-
export * from './authorization.js';
|
|
5
5
|
export * from './collections.js';
|
|
6
6
|
export * from './dashboards.js';
|
|
7
7
|
export * from './extensions.js';
|
|
@@ -18,7 +18,8 @@ export * from './notifications.js';
|
|
|
18
18
|
export * from './operations.js';
|
|
19
19
|
export * from './panels.js';
|
|
20
20
|
export * from './payload.js';
|
|
21
|
-
export * from './permissions
|
|
21
|
+
export * from './permissions.js';
|
|
22
|
+
export * from './policies.js';
|
|
22
23
|
export * from './presets.js';
|
|
23
24
|
export * from './relations.js';
|
|
24
25
|
export * from './revisions.js';
|
package/dist/services/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
export * from './access.js';
|
|
1
2
|
export * from './activity.js';
|
|
2
3
|
export * from './assets.js';
|
|
3
4
|
export * from './authentication.js';
|
|
4
|
-
export * from './authorization.js';
|
|
5
5
|
export * from './collections.js';
|
|
6
6
|
export * from './dashboards.js';
|
|
7
7
|
export * from './extensions.js';
|
|
@@ -18,7 +18,8 @@ export * from './notifications.js';
|
|
|
18
18
|
export * from './operations.js';
|
|
19
19
|
export * from './panels.js';
|
|
20
20
|
export * from './payload.js';
|
|
21
|
-
export * from './permissions
|
|
21
|
+
export * from './permissions.js';
|
|
22
|
+
export * from './policies.js';
|
|
22
23
|
export * from './presets.js';
|
|
23
24
|
export * from './relations.js';
|
|
24
25
|
export * from './revisions.js';
|