@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
|
@@ -1,41 +1,40 @@
|
|
|
1
1
|
import { InvalidCredentialsError } from '@directus/errors';
|
|
2
2
|
import getDatabase from '../database/index.js';
|
|
3
|
+
import { fetchRolesTree } from '../permissions/lib/fetch-roles-tree.js';
|
|
4
|
+
import { fetchGlobalAccess } from '../permissions/modules/fetch-global-access/fetch-global-access.js';
|
|
5
|
+
import { createDefaultAccountability } from '../permissions/utils/create-default-accountability.js';
|
|
3
6
|
import { getSecret } from './get-secret.js';
|
|
4
7
|
import isDirectusJWT from './is-directus-jwt.js';
|
|
5
|
-
import { verifySessionJWT } from './verify-session-jwt.js';
|
|
6
8
|
import { verifyAccessJWT } from './jwt.js';
|
|
9
|
+
import { verifySessionJWT } from './verify-session-jwt.js';
|
|
7
10
|
export async function getAccountabilityForToken(token, accountability) {
|
|
8
11
|
if (!accountability) {
|
|
9
|
-
accountability =
|
|
10
|
-
user: null,
|
|
11
|
-
role: null,
|
|
12
|
-
admin: false,
|
|
13
|
-
app: false,
|
|
14
|
-
};
|
|
12
|
+
accountability = createDefaultAccountability();
|
|
15
13
|
}
|
|
14
|
+
// Try finding the user with the provided token
|
|
15
|
+
const database = getDatabase();
|
|
16
16
|
if (token) {
|
|
17
17
|
if (isDirectusJWT(token)) {
|
|
18
18
|
const payload = verifyAccessJWT(token, getSecret());
|
|
19
19
|
if ('session' in payload) {
|
|
20
20
|
await verifySessionJWT(payload);
|
|
21
21
|
}
|
|
22
|
-
accountability.role = payload.role;
|
|
23
|
-
accountability.admin = payload.admin_access === true || payload.admin_access == 1;
|
|
24
|
-
accountability.app = payload.app_access === true || payload.app_access == 1;
|
|
25
22
|
if (payload.share)
|
|
26
23
|
accountability.share = payload.share;
|
|
27
24
|
if (payload.share_scope)
|
|
28
25
|
accountability.share_scope = payload.share_scope;
|
|
29
26
|
if (payload.id)
|
|
30
27
|
accountability.user = payload.id;
|
|
28
|
+
accountability.role = payload.role;
|
|
29
|
+
accountability.roles = await fetchRolesTree(payload.role, database);
|
|
30
|
+
const { admin, app } = await fetchGlobalAccess(accountability, database);
|
|
31
|
+
accountability.admin = admin;
|
|
32
|
+
accountability.app = app;
|
|
31
33
|
}
|
|
32
34
|
else {
|
|
33
|
-
// Try finding the user with the provided token
|
|
34
|
-
const database = getDatabase();
|
|
35
35
|
const user = await database
|
|
36
|
-
.select('directus_users.id', 'directus_users.role'
|
|
36
|
+
.select('directus_users.id', 'directus_users.role')
|
|
37
37
|
.from('directus_users')
|
|
38
|
-
.leftJoin('directus_roles', 'directus_users.role', 'directus_roles.id')
|
|
39
38
|
.where({
|
|
40
39
|
'directus_users.token': token,
|
|
41
40
|
status: 'active',
|
|
@@ -46,8 +45,10 @@ export async function getAccountabilityForToken(token, accountability) {
|
|
|
46
45
|
}
|
|
47
46
|
accountability.user = user.id;
|
|
48
47
|
accountability.role = user.role;
|
|
49
|
-
accountability.
|
|
50
|
-
|
|
48
|
+
accountability.roles = await fetchRolesTree(user.role, database);
|
|
49
|
+
const { admin, app } = await fetchGlobalAccess(accountability, database);
|
|
50
|
+
accountability.admin = admin;
|
|
51
|
+
accountability.app = app;
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
54
|
return accountability;
|
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
import hash from 'object-hash';
|
|
2
2
|
import url from 'url';
|
|
3
|
+
import getDatabase from '../database/index.js';
|
|
4
|
+
import { fetchPoliciesIpAccess } from '../permissions/modules/fetch-policies-ip-access/fetch-policies-ip-access.js';
|
|
3
5
|
import { getGraphqlQueryAndVariables } from './get-graphql-query-and-variables.js';
|
|
4
6
|
import { version } from 'directus/version';
|
|
5
|
-
|
|
7
|
+
import { ipInNetworks } from './ip-in-networks.js';
|
|
8
|
+
export async function getCacheKey(req) {
|
|
6
9
|
const path = url.parse(req.originalUrl).pathname;
|
|
7
10
|
const isGraphQl = path?.startsWith('/graphql');
|
|
11
|
+
let includeIp = false;
|
|
12
|
+
if (req.accountability && req.accountability.ip) {
|
|
13
|
+
// Check if the IP influences the result of the request, that can be the case if some policies have an ip_access
|
|
14
|
+
// filter and the request IP matches any of those filters
|
|
15
|
+
const ipFilters = await fetchPoliciesIpAccess(req.accountability, getDatabase());
|
|
16
|
+
includeIp = ipFilters.length > 0 && ipFilters.some((networks) => ipInNetworks(req.accountability.ip, networks));
|
|
17
|
+
}
|
|
8
18
|
const info = {
|
|
9
19
|
version,
|
|
10
20
|
user: req.accountability?.user || null,
|
|
11
21
|
path,
|
|
12
22
|
query: isGraphQl ? getGraphqlQueryAndVariables(req) : req.sanitizedQuery,
|
|
23
|
+
...(includeIp && { ip: req.accountability.ip }),
|
|
13
24
|
};
|
|
14
25
|
const key = hash(info);
|
|
15
26
|
return key;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { Query, SchemaOverview } from '@directus/types';
|
|
1
|
+
import type { Filter, Query, SchemaOverview } from '@directus/types';
|
|
2
2
|
import type { Knex } from 'knex';
|
|
3
3
|
type GetColumnOptions = {
|
|
4
4
|
query?: Query | undefined;
|
|
5
|
+
cases?: Filter[];
|
|
5
6
|
originalCollectionName?: string | undefined;
|
|
6
7
|
};
|
|
7
8
|
/**
|
package/dist/utils/get-column.js
CHANGED
|
@@ -30,6 +30,7 @@ export function getColumn(knex, table, column, alias = applyFunctionToColumnName
|
|
|
30
30
|
const result = fn[functionName](table, columnName, {
|
|
31
31
|
type,
|
|
32
32
|
query: options?.query,
|
|
33
|
+
cases: options?.cases,
|
|
33
34
|
originalCollectionName: options?.originalCollectionName,
|
|
34
35
|
});
|
|
35
36
|
if (alias) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { parseJSON } from '@directus/utils';
|
|
2
2
|
import { getNodeEnv } from '@directus/utils/node';
|
|
3
|
-
import { useLogger } from '../logger.js';
|
|
3
|
+
import { useLogger } from '../logger/index.js';
|
|
4
4
|
import getLocalType from './get-local-type.js';
|
|
5
5
|
export default function getDefaultValue(column, field) {
|
|
6
6
|
const type = getLocalType(column, field);
|
package/dist/utils/get-schema.js
CHANGED
|
@@ -8,7 +8,7 @@ import { getSchemaCache, setSchemaCache } from '../cache.js';
|
|
|
8
8
|
import { ALIAS_TYPES } from '../constants.js';
|
|
9
9
|
import getDatabase from '../database/index.js';
|
|
10
10
|
import { useLock } from '../lock/index.js';
|
|
11
|
-
import { useLogger } from '../logger.js';
|
|
11
|
+
import { useLogger } from '../logger/index.js';
|
|
12
12
|
import { RelationsService } from '../services/relations.js';
|
|
13
13
|
import getDefaultValue from './get-default-value.js';
|
|
14
14
|
import { getSystemFieldRowsWithAuthProviders } from './get-field-system-rows.js';
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { ForbiddenError } from '@directus/errors';
|
|
2
|
-
import { ActivityService, DashboardsService, FilesService, FlowsService, FoldersService, ItemsService, NotificationsService, OperationsService, PanelsService, PermissionsService, PresetsService, RevisionsService, RolesService, SettingsService, SharesService, TranslationsService, UsersService, VersionsService, WebhooksService, } from '../services/index.js';
|
|
2
|
+
import { AccessService, ActivityService, DashboardsService, FilesService, FlowsService, FoldersService, ItemsService, NotificationsService, OperationsService, PanelsService, PermissionsService, PoliciesService, PresetsService, RevisionsService, RolesService, SettingsService, SharesService, TranslationsService, UsersService, VersionsService, WebhooksService, } from '../services/index.js';
|
|
3
3
|
/**
|
|
4
4
|
* Select the correct service for the given collection. This allows the individual services to run
|
|
5
5
|
* their custom checks (f.e. it allows `UsersService` to prevent updating TFA secret from outside).
|
|
6
6
|
*/
|
|
7
7
|
export function getService(collection, opts) {
|
|
8
8
|
switch (collection) {
|
|
9
|
+
case 'directus_access':
|
|
10
|
+
return new AccessService(opts);
|
|
9
11
|
case 'directus_activity':
|
|
10
12
|
return new ActivityService(opts);
|
|
11
13
|
case 'directus_dashboards':
|
|
@@ -26,6 +28,8 @@ export function getService(collection, opts) {
|
|
|
26
28
|
return new PermissionsService(opts);
|
|
27
29
|
case 'directus_presets':
|
|
28
30
|
return new PresetsService(opts);
|
|
31
|
+
case 'directus_policies':
|
|
32
|
+
return new PoliciesService(opts);
|
|
29
33
|
case 'directus_revisions':
|
|
30
34
|
return new RevisionsService(opts);
|
|
31
35
|
case 'directus_roles':
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { toArray } from '@directus/utils';
|
|
2
2
|
import { URL } from 'url';
|
|
3
|
-
import { useLogger } from '../logger.js';
|
|
3
|
+
import { useLogger } from '../logger/index.js';
|
|
4
4
|
/**
|
|
5
5
|
* Check if URL matches allow list either exactly or by origin (protocol+domain+port) + pathname
|
|
6
6
|
*/
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SchemaOverview } from '@directus/types';
|
|
2
|
+
import type { FieldMap } from '../permissions/modules/fetch-allowed-field-map/fetch-allowed-field-map.js';
|
|
2
3
|
/**
|
|
3
4
|
* Reduces the schema based on the included permissions. The resulting object is the schema structure, but with only
|
|
4
|
-
* the allowed collections/fields/relations included based on the
|
|
5
|
-
* @param schema The full project schema
|
|
6
|
-
* @param actions Array of permissions actions (crud)
|
|
7
|
-
* @returns Reduced schema
|
|
5
|
+
* the allowed collections/fields/relations included based on the passed field map.
|
|
8
6
|
*/
|
|
9
|
-
export declare function reduceSchema(schema: SchemaOverview,
|
|
7
|
+
export declare function reduceSchema(schema: SchemaOverview, fieldMap: FieldMap): SchemaOverview;
|
|
@@ -1,40 +1,24 @@
|
|
|
1
|
-
import { uniq } from 'lodash-es';
|
|
2
1
|
/**
|
|
3
2
|
* Reduces the schema based on the included permissions. The resulting object is the schema structure, but with only
|
|
4
|
-
* the allowed collections/fields/relations included based on the
|
|
5
|
-
* @param schema The full project schema
|
|
6
|
-
* @param actions Array of permissions actions (crud)
|
|
7
|
-
* @returns Reduced schema
|
|
3
|
+
* the allowed collections/fields/relations included based on the passed field map.
|
|
8
4
|
*/
|
|
9
|
-
export function reduceSchema(schema,
|
|
5
|
+
export function reduceSchema(schema, fieldMap) {
|
|
10
6
|
const reduced = {
|
|
11
7
|
collections: {},
|
|
12
8
|
relations: [],
|
|
13
9
|
};
|
|
14
|
-
const allowedFieldsInCollection = permissions
|
|
15
|
-
?.filter((permission) => actions.includes(permission.action))
|
|
16
|
-
.reduce((acc, permission) => {
|
|
17
|
-
if (!acc[permission.collection]) {
|
|
18
|
-
acc[permission.collection] = [];
|
|
19
|
-
}
|
|
20
|
-
if (permission.fields) {
|
|
21
|
-
acc[permission.collection] = uniq([...acc[permission.collection], ...permission.fields]);
|
|
22
|
-
}
|
|
23
|
-
return acc;
|
|
24
|
-
}, {}) ?? {};
|
|
25
10
|
for (const [collectionName, collection] of Object.entries(schema.collections)) {
|
|
26
|
-
if (!
|
|
11
|
+
if (!fieldMap[collectionName]) {
|
|
12
|
+
// Collection is not allowed at all
|
|
27
13
|
continue;
|
|
28
14
|
}
|
|
29
15
|
const fields = {};
|
|
30
16
|
for (const [fieldName, field] of Object.entries(schema.collections[collectionName].fields)) {
|
|
31
|
-
if (!
|
|
32
|
-
!allowedFieldsInCollection[collectionName]?.includes(fieldName)) {
|
|
17
|
+
if (!fieldMap[collectionName]?.includes('*') && !fieldMap[collectionName]?.includes(fieldName)) {
|
|
33
18
|
continue;
|
|
34
19
|
}
|
|
35
20
|
const o2mRelation = schema.relations.find((relation) => relation.related_collection === collectionName && relation.meta?.one_field === fieldName);
|
|
36
|
-
if (o2mRelation &&
|
|
37
|
-
!permissions?.some((permission) => permission.collection === o2mRelation.collection && actions.includes(permission.action))) {
|
|
21
|
+
if (o2mRelation && !fieldMap[collectionName]) {
|
|
38
22
|
continue;
|
|
39
23
|
}
|
|
40
24
|
fields[fieldName] = field;
|
|
@@ -47,29 +31,29 @@ export function reduceSchema(schema, permissions, actions = ['create', 'read', '
|
|
|
47
31
|
reduced.relations = schema.relations.filter((relation) => {
|
|
48
32
|
let collectionsAllowed = true;
|
|
49
33
|
let fieldsAllowed = true;
|
|
50
|
-
if (Object.keys(
|
|
34
|
+
if (Object.keys(fieldMap).includes(relation.collection) === false) {
|
|
51
35
|
collectionsAllowed = false;
|
|
52
36
|
}
|
|
53
37
|
if (relation.related_collection &&
|
|
54
|
-
(Object.keys(
|
|
38
|
+
(Object.keys(fieldMap).includes(relation.related_collection) === false ||
|
|
55
39
|
// Ignore legacy permissions with an empty fields array
|
|
56
|
-
|
|
40
|
+
fieldMap[relation.related_collection]?.length === 0)) {
|
|
57
41
|
collectionsAllowed = false;
|
|
58
42
|
}
|
|
59
43
|
if (relation.meta?.one_allowed_collections &&
|
|
60
|
-
relation.meta.one_allowed_collections.every((collection) => Object.keys(
|
|
44
|
+
relation.meta.one_allowed_collections.every((collection) => Object.keys(fieldMap).includes(collection)) === false) {
|
|
61
45
|
collectionsAllowed = false;
|
|
62
46
|
}
|
|
63
|
-
if (!
|
|
64
|
-
(
|
|
65
|
-
|
|
47
|
+
if (!fieldMap[relation.collection] ||
|
|
48
|
+
(fieldMap[relation.collection]?.includes('*') === false &&
|
|
49
|
+
fieldMap[relation.collection]?.includes(relation.field) === false)) {
|
|
66
50
|
fieldsAllowed = false;
|
|
67
51
|
}
|
|
68
52
|
if (relation.related_collection &&
|
|
69
53
|
relation.meta?.one_field &&
|
|
70
|
-
(!
|
|
71
|
-
(
|
|
72
|
-
|
|
54
|
+
(!fieldMap[relation.related_collection] ||
|
|
55
|
+
(fieldMap[relation.related_collection]?.includes('*') === false &&
|
|
56
|
+
fieldMap[relation.related_collection]?.includes(relation.meta?.one_field) === false))) {
|
|
73
57
|
fieldsAllowed = false;
|
|
74
58
|
}
|
|
75
59
|
return collectionsAllowed && fieldsAllowed;
|
|
@@ -2,7 +2,7 @@ import { useEnv } from '@directus/env';
|
|
|
2
2
|
import { InvalidQueryError } from '@directus/errors';
|
|
3
3
|
import { parseFilter, parseJSON } from '@directus/utils';
|
|
4
4
|
import { flatten, get, isPlainObject, merge, set } from 'lodash-es';
|
|
5
|
-
import { useLogger } from '../logger.js';
|
|
5
|
+
import { useLogger } from '../logger/index.js';
|
|
6
6
|
import { Meta } from '../types/index.js';
|
|
7
7
|
export function sanitizeQuery(rawQuery, accountability) {
|
|
8
8
|
const env = useEnv();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {} from 'knex';
|
|
2
2
|
import { getDatabaseClient } from '../database/index.js';
|
|
3
|
-
import { useLogger } from '../logger.js';
|
|
3
|
+
import { useLogger } from '../logger/index.js';
|
|
4
4
|
/**
|
|
5
5
|
* Execute the given handler within the current transaction or a newly created one
|
|
6
6
|
* if the current knex state isn't a transaction yet.
|
|
@@ -4,7 +4,7 @@ import { constants } from 'fs';
|
|
|
4
4
|
import { access } from 'node:fs/promises';
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import { getExtensionsPath } from '../extensions/lib/get-extensions-path.js';
|
|
7
|
-
import { useLogger } from '../logger.js';
|
|
7
|
+
import { useLogger } from '../logger/index.js';
|
|
8
8
|
export async function validateStorage() {
|
|
9
9
|
const env = useEnv();
|
|
10
10
|
const logger = useLogger();
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type FetchUserCountOptions } from './fetch-user-count/fetch-user-count.js';
|
|
2
|
+
export declare enum UserIntegrityCheckFlag {
|
|
3
|
+
None = 0,
|
|
4
|
+
/** Check if the number of remaining admin users is greater than 0 */
|
|
5
|
+
RemainingAdmins = 1,
|
|
6
|
+
/** Check if the number of users is within the limits */
|
|
7
|
+
UserLimits = 2,
|
|
8
|
+
All = 3
|
|
9
|
+
}
|
|
10
|
+
export interface ValidateUserCountIntegrityOptions extends Omit<FetchUserCountOptions, 'adminOnly'> {
|
|
11
|
+
flags: UserIntegrityCheckFlag;
|
|
12
|
+
}
|
|
13
|
+
export declare function validateUserCountIntegrity(options: ValidateUserCountIntegrityOptions): Promise<void>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { validateRemainingAdminCount } from '../permissions/modules/validate-remaining-admin/validate-remaining-admin-count.js';
|
|
2
|
+
import { checkUserLimits } from '../telemetry/utils/check-user-limits.js';
|
|
3
|
+
import { shouldCheckUserLimits } from '../telemetry/utils/should-check-user-limits.js';
|
|
4
|
+
import { fetchUserCount } from './fetch-user-count/fetch-user-count.js';
|
|
5
|
+
export var UserIntegrityCheckFlag;
|
|
6
|
+
(function (UserIntegrityCheckFlag) {
|
|
7
|
+
UserIntegrityCheckFlag[UserIntegrityCheckFlag["None"] = 0] = "None";
|
|
8
|
+
/** Check if the number of remaining admin users is greater than 0 */
|
|
9
|
+
UserIntegrityCheckFlag[UserIntegrityCheckFlag["RemainingAdmins"] = 1] = "RemainingAdmins";
|
|
10
|
+
/** Check if the number of users is within the limits */
|
|
11
|
+
UserIntegrityCheckFlag[UserIntegrityCheckFlag["UserLimits"] = 2] = "UserLimits";
|
|
12
|
+
UserIntegrityCheckFlag[UserIntegrityCheckFlag["All"] = 3] = "All";
|
|
13
|
+
})(UserIntegrityCheckFlag || (UserIntegrityCheckFlag = {}));
|
|
14
|
+
export async function validateUserCountIntegrity(options) {
|
|
15
|
+
const validateUserLimits = (options.flags & UserIntegrityCheckFlag.UserLimits) !== 0;
|
|
16
|
+
const validateRemainingAdminUsers = (options.flags & UserIntegrityCheckFlag.RemainingAdmins) !== 0;
|
|
17
|
+
const limitCheck = validateUserLimits && shouldCheckUserLimits();
|
|
18
|
+
if (!validateRemainingAdminUsers && !limitCheck) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const adminOnly = validateRemainingAdminUsers && !limitCheck;
|
|
22
|
+
const userCounts = await fetchUserCount({ ...options, adminOnly });
|
|
23
|
+
if (limitCheck) {
|
|
24
|
+
await checkUserLimits(userCounts);
|
|
25
|
+
}
|
|
26
|
+
if (validateRemainingAdminUsers) {
|
|
27
|
+
validateRemainingAdminCount(userCounts.admin);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import type { Accountability } from '@directus/types';
|
|
2
1
|
import type { BasicAuthMessage } from './messages.js';
|
|
3
2
|
import type { AuthenticationState } from './types.js';
|
|
4
3
|
export declare function authenticateConnection(message: BasicAuthMessage & Record<string, any>): Promise<AuthenticationState>;
|
|
5
|
-
export declare function refreshAccountability(accountability: Accountability | null | undefined): Promise<Accountability>;
|
|
6
4
|
export declare function authenticationSuccess(uid?: string | number, refresh_token?: string): string;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { DEFAULT_AUTH_PROVIDER } from '../constants.js';
|
|
2
2
|
import { AuthenticationService } from '../services/index.js';
|
|
3
3
|
import { getAccountabilityForToken } from '../utils/get-accountability-for-token.js';
|
|
4
|
-
import { getPermissions } from '../utils/get-permissions.js';
|
|
5
4
|
import { getSchema } from '../utils/get-schema.js';
|
|
6
5
|
import { WebSocketError } from './errors.js';
|
|
7
6
|
import { getExpiresAtForToken } from './utils/get-expires-at-for-token.js';
|
|
@@ -33,17 +32,6 @@ export async function authenticateConnection(message) {
|
|
|
33
32
|
throw new WebSocketError('auth', 'AUTH_FAILED', 'Authentication failed.', message['uid']);
|
|
34
33
|
}
|
|
35
34
|
}
|
|
36
|
-
export async function refreshAccountability(accountability) {
|
|
37
|
-
accountability = accountability ?? {
|
|
38
|
-
role: null,
|
|
39
|
-
user: null,
|
|
40
|
-
admin: false,
|
|
41
|
-
app: false,
|
|
42
|
-
};
|
|
43
|
-
const schema = await getSchema();
|
|
44
|
-
const permissions = await getPermissions(accountability, schema);
|
|
45
|
-
return { ...accountability, permissions };
|
|
46
|
-
}
|
|
47
35
|
export function authenticationSuccess(uid, refresh_token) {
|
|
48
36
|
const message = {
|
|
49
37
|
type: 'auth',
|
|
@@ -6,7 +6,7 @@ import { parse } from 'url';
|
|
|
6
6
|
import WebSocket, { WebSocketServer } from 'ws';
|
|
7
7
|
import { fromZodError } from 'zod-validation-error';
|
|
8
8
|
import emitter from '../../emitter.js';
|
|
9
|
-
import { useLogger } from '../../logger.js';
|
|
9
|
+
import { useLogger } from '../../logger/index.js';
|
|
10
10
|
import { createRateLimiter } from '../../rate-limiter.js';
|
|
11
11
|
import { getAccountabilityForToken } from '../../utils/get-accountability-for-token.js';
|
|
12
12
|
import { authenticateConnection, authenticationSuccess } from '../authenticate.js';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { useEnv } from '@directus/env';
|
|
2
2
|
import { CloseCode, MessageType, makeServer } from 'graphql-ws';
|
|
3
|
-
import { useLogger } from '../../logger.js';
|
|
3
|
+
import { useLogger } from '../../logger/index.js';
|
|
4
4
|
import { bindPubSub } from '../../services/graphql/subscription.js';
|
|
5
5
|
import { GraphQLService } from '../../services/index.js';
|
|
6
6
|
import { getSchema } from '../../utils/get-schema.js';
|
|
7
|
-
import { authenticateConnection
|
|
7
|
+
import { authenticateConnection } from '../authenticate.js';
|
|
8
8
|
import { handleWebSocketError } from '../errors.js';
|
|
9
9
|
import { ConnectionParams, WebSocketMessage } from '../messages.js';
|
|
10
10
|
import { getMessageType } from '../utils/message.js';
|
|
@@ -64,9 +64,6 @@ export class GraphQLSubscriptionController extends SocketController {
|
|
|
64
64
|
client.close(CloseCode.Forbidden, 'Forbidden');
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
|
-
else {
|
|
68
|
-
client.accountability = await refreshAccountability(client.accountability);
|
|
69
|
-
}
|
|
70
67
|
await cb(JSON.stringify(message));
|
|
71
68
|
}
|
|
72
69
|
catch (error) {
|
|
@@ -7,19 +7,23 @@ export function registerWebSocketEvents() {
|
|
|
7
7
|
actionsRegistered = true;
|
|
8
8
|
registerActionHooks([
|
|
9
9
|
'items',
|
|
10
|
+
'access',
|
|
10
11
|
'activity',
|
|
11
12
|
'collections',
|
|
12
13
|
'dashboards',
|
|
14
|
+
'flows',
|
|
13
15
|
'folders',
|
|
14
16
|
'notifications',
|
|
15
17
|
'operations',
|
|
16
18
|
'panels',
|
|
17
19
|
'permissions',
|
|
20
|
+
'policies',
|
|
18
21
|
'presets',
|
|
19
22
|
'revisions',
|
|
20
23
|
'roles',
|
|
21
24
|
'settings',
|
|
22
25
|
'shares',
|
|
26
|
+
'translations',
|
|
23
27
|
'users',
|
|
24
28
|
'versions',
|
|
25
29
|
'webhooks',
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { useEnv } from '@directus/env';
|
|
2
2
|
import { parseJSON } from '@directus/utils';
|
|
3
3
|
import emitter from '../../emitter.js';
|
|
4
|
-
import { useLogger } from '../../logger.js';
|
|
5
|
-
import { refreshAccountability } from '../authenticate.js';
|
|
4
|
+
import { useLogger } from '../../logger/index.js';
|
|
6
5
|
import { WebSocketError, handleWebSocketError } from '../errors.js';
|
|
7
6
|
import { WebSocketMessage } from '../messages.js';
|
|
8
7
|
import SocketController from './base.js';
|
|
@@ -20,7 +19,6 @@ export class WebSocketController extends SocketController {
|
|
|
20
19
|
client.on('parsed-message', async (message) => {
|
|
21
20
|
try {
|
|
22
21
|
message = WebSocketMessage.parse(await emitter.emitFilter('websocket.message', message, { client }));
|
|
23
|
-
client.accountability = await refreshAccountability(client.accountability);
|
|
24
22
|
emitter.emitAction('websocket.message', { message, client });
|
|
25
23
|
}
|
|
26
24
|
catch (error) {
|
package/dist/websocket/errors.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isDirectusError } from '@directus/errors';
|
|
2
2
|
import { ZodError } from 'zod';
|
|
3
3
|
import { fromZodError } from 'zod-validation-error';
|
|
4
|
-
import { useLogger } from '../logger.js';
|
|
4
|
+
import { useLogger } from '../logger/index.js';
|
|
5
5
|
export class WebSocketError extends Error {
|
|
6
6
|
type;
|
|
7
7
|
code;
|
|
@@ -4,7 +4,6 @@ import { useBus } from '../../bus/index.js';
|
|
|
4
4
|
import emitter from '../../emitter.js';
|
|
5
5
|
import { getSchema } from '../../utils/get-schema.js';
|
|
6
6
|
import { sanitizeQuery } from '../../utils/sanitize-query.js';
|
|
7
|
-
import { refreshAccountability } from '../authenticate.js';
|
|
8
7
|
import { WebSocketError, handleWebSocketError } from '../errors.js';
|
|
9
8
|
import { WebSocketSubscribeMessage } from '../messages.js';
|
|
10
9
|
import { getPayload } from '../utils/items.js';
|
|
@@ -112,7 +111,6 @@ export class SubscribeHandler {
|
|
|
112
111
|
continue;
|
|
113
112
|
}
|
|
114
113
|
try {
|
|
115
|
-
client.accountability = await refreshAccountability(client.accountability);
|
|
116
114
|
const result = await getPayload(subscription, client.accountability, schema, event);
|
|
117
115
|
if (Array.isArray(result?.['data']) && result?.['data']?.length === 0)
|
|
118
116
|
continue;
|
|
@@ -39,5 +39,5 @@ export declare function getFieldsPayload(subscription: PSubscription, accountabi
|
|
|
39
39
|
* @param event Event data
|
|
40
40
|
* @returns the fetched data
|
|
41
41
|
*/
|
|
42
|
-
export declare function getItemsPayload(subscription: PSubscription, accountability: Accountability | null, schema: SchemaOverview, event?: WebSocketEvent): Promise<string | number | import("@directus/types").Item |
|
|
42
|
+
export declare function getItemsPayload(subscription: PSubscription, accountability: Accountability | null, schema: SchemaOverview, event?: WebSocketEvent): Promise<string | number | (string | number)[] | import("@directus/types").Item | import("@directus/types").Item[]>;
|
|
43
43
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@directus/api",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "21.0.0-rc.0",
|
|
4
4
|
"description": "Directus is a real-time API and App dashboard for managing SQL database content",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"directus",
|
|
@@ -149,29 +149,29 @@
|
|
|
149
149
|
"ws": "8.18.0",
|
|
150
150
|
"zod": "3.23.8",
|
|
151
151
|
"zod-validation-error": "3.3.0",
|
|
152
|
-
"@directus/
|
|
153
|
-
"@directus/
|
|
154
|
-
"@directus/
|
|
155
|
-
"@directus/
|
|
156
|
-
"@directus/extensions
|
|
152
|
+
"@directus/constants": "11.1.0-rc.1",
|
|
153
|
+
"@directus/env": "1.3.1-rc.0",
|
|
154
|
+
"@directus/errors": "0.4.0-rc.1",
|
|
155
|
+
"@directus/app": "13.0.0-rc.2",
|
|
156
|
+
"@directus/extensions": "2.0.0-rc.1",
|
|
157
|
+
"@directus/extensions-registry": "1.0.10-rc.0",
|
|
158
|
+
"@directus/extensions-sdk": "11.0.10-rc.0",
|
|
159
|
+
"@directus/memory": "1.1.0-rc.1",
|
|
157
160
|
"@directus/format-title": "10.1.2",
|
|
158
|
-
"@directus/
|
|
159
|
-
"@directus/memory": "1.0.10",
|
|
160
|
-
"@directus/extensions-sdk": "11.0.9",
|
|
161
|
-
"@directus/pressure": "1.0.21",
|
|
161
|
+
"@directus/pressure": "1.0.22-rc.0",
|
|
162
162
|
"@directus/schema": "11.0.3",
|
|
163
163
|
"@directus/specs": "10.2.10",
|
|
164
|
-
"@directus/storage-driver-azure": "10.0.23",
|
|
165
164
|
"@directus/storage": "10.1.0",
|
|
166
|
-
"@directus/storage-driver-
|
|
167
|
-
"@directus/storage-driver-
|
|
165
|
+
"@directus/storage-driver-azure": "10.0.24-rc.0",
|
|
166
|
+
"@directus/storage-driver-cloudinary": "10.0.24-rc.0",
|
|
167
|
+
"@directus/storage-driver-gcs": "10.0.25-rc.0",
|
|
168
168
|
"@directus/storage-driver-local": "10.1.0",
|
|
169
|
-
"@directus/storage-driver-s3": "10.1.0",
|
|
170
|
-
"@directus/storage-driver-supabase": "1.0.
|
|
171
|
-
"@directus/
|
|
172
|
-
"
|
|
173
|
-
"@directus/
|
|
174
|
-
"directus": "
|
|
169
|
+
"@directus/storage-driver-s3": "10.1.1-rc.0",
|
|
170
|
+
"@directus/storage-driver-supabase": "1.0.16-rc.0",
|
|
171
|
+
"@directus/validation": "0.0.19-rc.0",
|
|
172
|
+
"directus": "11.0.0-rc.3",
|
|
173
|
+
"@directus/system-data": "2.0.0-rc.1",
|
|
174
|
+
"@directus/utils": "12.0.0-rc.1"
|
|
175
175
|
},
|
|
176
176
|
"devDependencies": {
|
|
177
177
|
"@ngneat/falso": "7.2.0",
|
|
@@ -212,13 +212,13 @@
|
|
|
212
212
|
"knex-mock-client": "2.0.1",
|
|
213
213
|
"typescript": "5.4.5",
|
|
214
214
|
"vitest": "1.5.3",
|
|
215
|
-
"@directus/tsconfig": "1.0.1",
|
|
216
215
|
"@directus/random": "0.2.8",
|
|
217
|
-
"@directus/
|
|
216
|
+
"@directus/tsconfig": "1.0.1",
|
|
217
|
+
"@directus/types": "12.0.0-rc.1"
|
|
218
218
|
},
|
|
219
219
|
"optionalDependencies": {
|
|
220
220
|
"@keyv/redis": "2.8.5",
|
|
221
|
-
"
|
|
221
|
+
"mysql2": "3.10.0",
|
|
222
222
|
"nodemailer-mailgun-transport": "2.1.5",
|
|
223
223
|
"nodemailer-sendgrid": "1.0.3",
|
|
224
224
|
"oracledb": "6.5.1",
|
|
@@ -233,6 +233,7 @@
|
|
|
233
233
|
"build": "tsc --project tsconfig.prod.json && copyfiles \"src/**/*.{yaml,liquid}\" -u 1 dist",
|
|
234
234
|
"cli": "NODE_ENV=development SERVE_APP=false tsx src/cli/run.ts",
|
|
235
235
|
"dev": "NODE_ENV=development SERVE_APP=true tsx watch --ignore extensions --clear-screen=false src/start.ts",
|
|
236
|
-
"test": "vitest
|
|
236
|
+
"test": "vitest run",
|
|
237
|
+
"test:watch": "vitest"
|
|
237
238
|
}
|
|
238
239
|
}
|