directus 9.23.1 → 9.23.4
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 +25 -21
- package/dist/auth/auth.d.ts +3 -3
- package/dist/auth/auth.js +2 -0
- package/dist/auth/drivers/ldap.d.ts +1 -1
- package/dist/auth/drivers/ldap.js +57 -46
- package/dist/auth/drivers/local.d.ts +1 -1
- package/dist/auth/drivers/local.js +20 -17
- package/dist/auth/drivers/oauth2.d.ts +1 -1
- package/dist/auth/drivers/oauth2.js +44 -35
- package/dist/auth/drivers/openid.d.ts +1 -1
- package/dist/auth/drivers/openid.js +50 -41
- package/dist/auth/drivers/saml.d.ts +1 -1
- package/dist/auth/drivers/saml.js +20 -17
- package/dist/auth.d.ts +1 -1
- package/dist/auth.js +8 -7
- package/dist/cache.d.ts +9 -1
- package/dist/cache.js +66 -18
- package/dist/cli/commands/bootstrap/index.js +7 -6
- package/dist/cli/commands/init/index.js +3 -3
- package/dist/cli/commands/schema/apply.js +14 -15
- package/dist/cli/commands/schema/snapshot.js +2 -2
- package/dist/cli/utils/create-db-connection.d.ts +1 -1
- package/dist/cli/utils/create-db-connection.js +3 -2
- package/dist/cli/utils/create-env/index.d.ts +2 -2
- package/dist/cli/utils/create-env/index.js +1 -1
- package/dist/cli/utils/drivers.d.ts +1 -1
- package/dist/constants.d.ts +3 -2
- package/dist/constants.js +7 -7
- package/dist/controllers/activity.js +10 -11
- package/dist/controllers/assets.js +31 -25
- package/dist/controllers/auth.js +40 -26
- package/dist/controllers/collections.js +10 -10
- package/dist/controllers/dashboards.js +14 -11
- package/dist/controllers/extensions.js +3 -3
- package/dist/controllers/fields.js +20 -20
- package/dist/controllers/files.js +26 -20
- package/dist/controllers/flows.js +16 -13
- package/dist/controllers/folders.js +14 -11
- package/dist/controllers/graphql.js +6 -8
- package/dist/controllers/items.js +22 -19
- package/dist/controllers/not-found.d.ts +1 -1
- package/dist/controllers/not-found.js +1 -2
- package/dist/controllers/notifications.js +14 -11
- package/dist/controllers/operations.js +14 -11
- package/dist/controllers/panels.js +14 -11
- package/dist/controllers/permissions.js +14 -11
- package/dist/controllers/presets.js +14 -11
- package/dist/controllers/relations.js +10 -10
- package/dist/controllers/revisions.js +3 -3
- package/dist/controllers/roles.js +14 -11
- package/dist/controllers/schema.js +5 -5
- package/dist/controllers/server.js +7 -7
- package/dist/controllers/settings.js +2 -2
- package/dist/controllers/shares.js +21 -18
- package/dist/controllers/users.js +32 -36
- package/dist/controllers/utils.js +10 -15
- package/dist/controllers/webhooks.js +14 -11
- package/dist/database/helpers/fn/dialects/mssql.d.ts +1 -1
- package/dist/database/helpers/fn/dialects/mssql.js +10 -11
- package/dist/database/helpers/fn/dialects/mysql.d.ts +1 -1
- package/dist/database/helpers/fn/dialects/mysql.js +2 -3
- package/dist/database/helpers/fn/dialects/oracle.d.ts +1 -1
- package/dist/database/helpers/fn/dialects/oracle.js +10 -11
- package/dist/database/helpers/fn/dialects/postgres.d.ts +1 -1
- package/dist/database/helpers/fn/dialects/postgres.js +10 -11
- package/dist/database/helpers/fn/dialects/sqlite.d.ts +1 -1
- package/dist/database/helpers/fn/dialects/sqlite.js +10 -11
- package/dist/database/helpers/fn/types.d.ts +5 -6
- package/dist/database/helpers/fn/types.js +4 -5
- package/dist/database/helpers/geometry/dialects/mssql.d.ts +3 -3
- package/dist/database/helpers/geometry/dialects/mysql.d.ts +1 -1
- package/dist/database/helpers/geometry/dialects/oracle.d.ts +3 -3
- package/dist/database/helpers/geometry/dialects/postgres.d.ts +3 -3
- package/dist/database/helpers/geometry/dialects/postgres.js +1 -2
- package/dist/database/helpers/geometry/dialects/redshift.d.ts +2 -2
- package/dist/database/helpers/geometry/dialects/sqlite.d.ts +1 -1
- package/dist/database/helpers/geometry/types.d.ts +2 -2
- package/dist/database/helpers/geometry/types.js +1 -2
- package/dist/database/helpers/index.d.ts +5 -5
- package/dist/database/helpers/schema/dialects/cockroachdb.d.ts +1 -1
- package/dist/database/helpers/schema/dialects/mssql.d.ts +1 -1
- package/dist/database/helpers/schema/dialects/mysql.d.ts +1 -1
- package/dist/database/helpers/schema/dialects/mysql.js +1 -2
- package/dist/database/helpers/schema/dialects/oracle.d.ts +2 -2
- package/dist/database/helpers/schema/dialects/oracle.js +4 -6
- package/dist/database/helpers/schema/types.d.ts +4 -4
- package/dist/database/helpers/types.d.ts +1 -1
- package/dist/database/helpers/types.js +1 -0
- package/dist/database/index.d.ts +1 -1
- package/dist/database/index.js +13 -13
- package/dist/database/migrations/20201028A-remove-collection-foreign-keys.d.ts +1 -1
- package/dist/database/migrations/20201029A-remove-system-relations.d.ts +1 -1
- package/dist/database/migrations/20201029B-remove-system-collections.d.ts +1 -1
- package/dist/database/migrations/20201029C-remove-system-fields.d.ts +1 -1
- package/dist/database/migrations/20201105A-add-cascade-system-relations.d.ts +1 -1
- package/dist/database/migrations/20201105B-change-webhook-url-type.d.ts +1 -1
- package/dist/database/migrations/20210225A-add-relations-sort-field.d.ts +1 -1
- package/dist/database/migrations/20210225A-add-relations-sort-field.js +1 -2
- package/dist/database/migrations/20210304A-remove-locked-fields.d.ts +1 -1
- package/dist/database/migrations/20210312A-webhooks-collections-text.d.ts +1 -1
- package/dist/database/migrations/20210331A-add-refresh-interval.d.ts +1 -1
- package/dist/database/migrations/20210415A-make-filesize-nullable.d.ts +1 -1
- package/dist/database/migrations/20210416A-add-collections-accountability.d.ts +1 -1
- package/dist/database/migrations/20210422A-remove-files-interface.d.ts +1 -1
- package/dist/database/migrations/20210506A-rename-interfaces.d.ts +1 -1
- package/dist/database/migrations/20210510A-restructure-relations.d.ts +1 -1
- package/dist/database/migrations/20210518A-add-foreign-key-constraints.d.ts +1 -1
- package/dist/database/migrations/20210518A-add-foreign-key-constraints.js +1 -1
- package/dist/database/migrations/20210519A-add-system-fk-triggers.d.ts +1 -1
- package/dist/database/migrations/20210519A-add-system-fk-triggers.js +2 -2
- package/dist/database/migrations/20210521A-add-collections-icon-color.d.ts +1 -1
- package/dist/database/migrations/20210525A-add-insights.d.ts +1 -1
- package/dist/database/migrations/20210608A-add-deep-clone-config.d.ts +1 -1
- package/dist/database/migrations/20210626A-change-filesize-bigint.d.ts +1 -1
- package/dist/database/migrations/20210716A-add-conditions-to-fields.d.ts +1 -1
- package/dist/database/migrations/20210721A-add-default-folder.d.ts +1 -1
- package/dist/database/migrations/20210802A-replace-groups.d.ts +1 -1
- package/dist/database/migrations/20210803A-add-required-to-fields.d.ts +1 -1
- package/dist/database/migrations/20210805A-update-groups.d.ts +1 -1
- package/dist/database/migrations/20210805B-change-image-metadata-structure.d.ts +1 -1
- package/dist/database/migrations/20210805B-change-image-metadata-structure.js +15 -15
- package/dist/database/migrations/20210811A-add-geometry-config.d.ts +1 -1
- package/dist/database/migrations/20210831A-remove-limit-column.d.ts +1 -1
- package/dist/database/migrations/20210903A-add-auth-provider.d.ts +1 -1
- package/dist/database/migrations/20210907A-webhooks-collections-not-null.d.ts +1 -1
- package/dist/database/migrations/20210910A-move-module-setup.d.ts +1 -1
- package/dist/database/migrations/20210920A-webhooks-url-not-null.d.ts +1 -1
- package/dist/database/migrations/20210924A-add-collection-organization.d.ts +1 -1
- package/dist/database/migrations/20210927A-replace-fields-group.d.ts +1 -1
- package/dist/database/migrations/20210927B-replace-m2m-interface.d.ts +1 -1
- package/dist/database/migrations/20210929A-rename-login-action.d.ts +1 -1
- package/dist/database/migrations/20211007A-update-presets.d.ts +1 -1
- package/dist/database/migrations/20211007A-update-presets.js +7 -9
- package/dist/database/migrations/20211009A-add-auth-data.d.ts +1 -1
- package/dist/database/migrations/20211016A-add-webhook-headers.d.ts +1 -1
- package/dist/database/migrations/20211103A-set-unique-to-user-token.d.ts +1 -1
- package/dist/database/migrations/20211103B-update-special-geometry.d.ts +1 -1
- package/dist/database/migrations/20211104A-remove-collections-listing.d.ts +1 -1
- package/dist/database/migrations/20211118A-add-notifications.d.ts +1 -1
- package/dist/database/migrations/20211211A-add-shares.d.ts +1 -1
- package/dist/database/migrations/20211230A-add-project-descriptor.d.ts +1 -1
- package/dist/database/migrations/20220303A-remove-default-project-color.d.ts +1 -1
- package/dist/database/migrations/20220308A-add-bookmark-icon-and-color.d.ts +1 -1
- package/dist/database/migrations/20220314A-add-translation-strings.d.ts +1 -1
- package/dist/database/migrations/20220322A-rename-field-typecast-flags.d.ts +1 -1
- package/dist/database/migrations/20220323A-add-field-validation.d.ts +1 -1
- package/dist/database/migrations/20220325A-fix-typecast-flags.d.ts +1 -1
- package/dist/database/migrations/20220325B-add-default-language.d.ts +1 -1
- package/dist/database/migrations/20220402A-remove-default-value-panel-icon.d.ts +1 -1
- package/dist/database/migrations/20220429A-add-flows.d.ts +1 -1
- package/dist/database/migrations/20220429B-add-color-to-insights-icon.d.ts +1 -1
- package/dist/database/migrations/20220429C-drop-non-null-from-ip-of-activity.d.ts +1 -1
- package/dist/database/migrations/20220429D-drop-non-null-from-sender-of-notifications.d.ts +1 -1
- package/dist/database/migrations/20220614A-rename-hook-trigger-to-event.d.ts +1 -1
- package/dist/database/migrations/20220801A-update-notifications-timestamp-column.d.ts +1 -1
- package/dist/database/migrations/20220802A-add-custom-aspect-ratios.d.ts +1 -1
- package/dist/database/migrations/20220826A-add-origin-to-accountability.d.ts +1 -1
- package/dist/database/migrations/run.d.ts +1 -1
- package/dist/database/migrations/run.js +1 -1
- package/dist/database/run-ast.d.ts +3 -3
- package/dist/database/run-ast.js +21 -30
- package/dist/database/seeds/run.d.ts +1 -1
- package/dist/database/seeds/run.js +1 -2
- package/dist/database/system-data/app-access-permissions/index.d.ts +1 -1
- package/dist/database/system-data/collections/index.d.ts +1 -1
- package/dist/database/system-data/collections/index.js +2 -2
- package/dist/database/system-data/fields/collections.yaml +2 -0
- package/dist/database/system-data/fields/index.d.ts +1 -1
- package/dist/database/system-data/fields/index.js +3 -4
- package/dist/database/system-data/fields/settings.yaml +4 -0
- package/dist/database/system-data/relations/index.d.ts +1 -1
- package/dist/emitter.d.ts +1 -1
- package/dist/emitter.js +3 -0
- package/dist/env.js +11 -3
- package/dist/exceptions/database/dialects/mssql.d.ts +1 -1
- package/dist/exceptions/database/dialects/mssql.js +5 -6
- package/dist/exceptions/database/dialects/mysql.d.ts +1 -1
- package/dist/exceptions/database/dialects/mysql.js +19 -25
- package/dist/exceptions/database/dialects/oracle.d.ts +1 -1
- package/dist/exceptions/database/dialects/postgres.d.ts +1 -1
- package/dist/exceptions/database/dialects/sqlite.d.ts +1 -1
- package/dist/exceptions/database/translate.d.ts +1 -1
- package/dist/exceptions/database/value-out-of-range.js +1 -1
- package/dist/exceptions/range-not-satisfiable.js +2 -3
- package/dist/extensions.d.ts +1 -1
- package/dist/extensions.js +43 -33
- package/dist/flows.js +65 -46
- package/dist/logger.d.ts +2 -1
- package/dist/logger.js +35 -19
- package/dist/logger.test.d.ts +1 -0
- package/dist/mailer.js +16 -16
- package/dist/messenger.js +9 -7
- package/dist/middleware/authenticate.d.ts +1 -1
- package/dist/middleware/authenticate.js +13 -6
- package/dist/middleware/cache.d.ts +1 -1
- package/dist/middleware/cache.js +16 -16
- package/dist/middleware/check-ip.d.ts +1 -1
- package/dist/middleware/check-ip.js +1 -1
- package/dist/middleware/collection-exists.d.ts +1 -1
- package/dist/middleware/collection-exists.js +5 -5
- package/dist/middleware/cors.d.ts +1 -1
- package/dist/middleware/cors.js +7 -7
- package/dist/middleware/error-handler.d.ts +1 -1
- package/dist/middleware/error-handler.js +11 -12
- package/dist/middleware/extract-token.d.ts +1 -1
- package/dist/middleware/extract-token.js +2 -2
- package/dist/middleware/get-permissions.d.ts +1 -1
- package/dist/middleware/graphql.d.ts +1 -1
- package/dist/middleware/graphql.js +15 -9
- package/dist/middleware/rate-limiter-global.d.ts +5 -0
- package/dist/middleware/rate-limiter-global.js +48 -0
- package/dist/middleware/{rate-limiter.d.ts → rate-limiter-ip.d.ts} +2 -2
- package/dist/middleware/{rate-limiter.js → rate-limiter-ip.js} +5 -5
- package/dist/middleware/respond.d.ts +1 -1
- package/dist/middleware/respond.js +18 -19
- package/dist/middleware/sanitize-query.d.ts +1 -1
- package/dist/middleware/sanitize-query.js +1 -1
- package/dist/middleware/schema.d.ts +1 -1
- package/dist/middleware/use-collection.d.ts +1 -1
- package/dist/operations/condition/index.d.ts +1 -1
- package/dist/operations/exec/index.js +15 -4
- package/dist/operations/item-create/index.js +1 -2
- package/dist/operations/item-delete/index.d.ts +1 -1
- package/dist/operations/item-read/index.d.ts +1 -1
- package/dist/operations/item-update/index.d.ts +1 -1
- package/dist/operations/item-update/index.js +1 -2
- package/dist/operations/notification/index.js +1 -2
- package/dist/operations/request/index.js +19 -19
- package/dist/operations/trigger/index.js +2 -3
- package/dist/rate-limiter.d.ts +1 -1
- package/dist/rate-limiter.js +9 -9
- package/dist/request/validate-ip.js +2 -2
- package/dist/server.js +12 -13
- package/dist/services/activity.d.ts +1 -1
- package/dist/services/activity.js +17 -16
- package/dist/services/assets.d.ts +3 -3
- package/dist/services/assets.js +35 -37
- package/dist/services/authentication.d.ts +2 -2
- package/dist/services/authentication.js +22 -19
- package/dist/services/authorization.d.ts +3 -3
- package/dist/services/authorization.js +27 -31
- package/dist/services/collections.d.ts +5 -5
- package/dist/services/collections.js +54 -50
- package/dist/services/dashboards.d.ts +1 -1
- package/dist/services/fields.d.ts +5 -5
- package/dist/services/fields.js +50 -50
- package/dist/services/files.d.ts +1 -2
- package/dist/services/files.js +33 -27
- package/dist/services/flows.d.ts +2 -2
- package/dist/services/folders.d.ts +1 -1
- package/dist/services/graphql/index.d.ts +4 -4
- package/dist/services/graphql/index.js +259 -252
- package/dist/services/graphql/utils/add-path-to-validation-error.js +1 -2
- package/dist/services/graphql/utils/process-error.d.ts +2 -2
- package/dist/services/graphql/utils/process-error.js +11 -4
- package/dist/services/import-export.d.ts +3 -3
- package/dist/services/import-export.js +30 -27
- package/dist/services/items.d.ts +3 -3
- package/dist/services/items.js +42 -36
- package/dist/services/mail/index.d.ts +4 -4
- package/dist/services/mail/index.js +14 -10
- package/dist/services/meta.d.ts +3 -3
- package/dist/services/meta.js +11 -9
- package/dist/services/notifications.d.ts +3 -3
- package/dist/services/notifications.js +10 -9
- package/dist/services/operations.d.ts +2 -2
- package/dist/services/panels.d.ts +1 -1
- package/dist/services/payload.d.ts +3 -3
- package/dist/services/payload.js +124 -122
- package/dist/services/permissions.d.ts +3 -3
- package/dist/services/permissions.js +11 -11
- package/dist/services/presets.d.ts +1 -1
- package/dist/services/relations.d.ts +6 -6
- package/dist/services/relations.js +45 -43
- package/dist/services/revisions.d.ts +1 -1
- package/dist/services/revisions.js +3 -3
- package/dist/services/roles.d.ts +2 -2
- package/dist/services/roles.js +7 -7
- package/dist/services/schema.d.ts +3 -3
- package/dist/services/schema.js +9 -11
- package/dist/services/server.d.ts +3 -3
- package/dist/services/server.js +88 -32
- package/dist/services/settings.d.ts +1 -1
- package/dist/services/shares.d.ts +1 -1
- package/dist/services/shares.js +14 -15
- package/dist/services/specifications.d.ts +4 -4
- package/dist/services/specifications.js +137 -119
- package/dist/services/tfa.d.ts +2 -2
- package/dist/services/tfa.js +7 -5
- package/dist/services/users.d.ts +2 -6
- package/dist/services/users.js +37 -40
- package/dist/services/utils.d.ts +3 -3
- package/dist/services/utils.js +10 -8
- package/dist/services/webhooks.d.ts +2 -2
- package/dist/services/webhooks.js +2 -1
- package/dist/storage/register-locations.js +1 -1
- package/dist/types/assets.d.ts +1 -1
- package/dist/types/ast.d.ts +1 -1
- package/dist/types/auth.d.ts +2 -2
- package/dist/types/collection.d.ts +2 -2
- package/dist/types/events.d.ts +2 -2
- package/dist/types/graphql.d.ts +2 -2
- package/dist/types/items.d.ts +3 -3
- package/dist/types/services.d.ts +5 -5
- package/dist/types/snapshot.d.ts +4 -4
- package/dist/utils/apply-diff.d.ts +3 -3
- package/dist/utils/apply-diff.js +25 -28
- package/dist/utils/apply-query.d.ts +3 -3
- package/dist/utils/apply-query.js +10 -12
- package/dist/utils/apply-snapshot.d.ts +3 -3
- package/dist/utils/apply-snapshot.js +5 -6
- package/dist/utils/construct-flow-tree.d.ts +1 -1
- package/dist/utils/construct-flow-tree.js +2 -2
- package/dist/utils/dynamic-import.js +1 -1
- package/dist/utils/filter-items.d.ts +1 -1
- package/dist/utils/generate-hash.js +1 -1
- package/dist/utils/get-accountability-for-role.d.ts +2 -2
- package/dist/utils/get-accountability-for-role.js +1 -1
- package/dist/utils/get-ast-from-query.d.ts +3 -3
- package/dist/utils/get-ast-from-query.js +22 -28
- package/dist/utils/get-auth-providers.js +1 -1
- package/dist/utils/get-cache-headers.d.ts +1 -1
- package/dist/utils/get-cache-headers.js +6 -7
- package/dist/utils/get-cache-key.d.ts +1 -1
- package/dist/utils/get-cache-key.js +2 -3
- package/dist/utils/get-collection-from-alias.d.ts +1 -1
- package/dist/utils/get-collection-from-alias.js +1 -0
- package/dist/utils/get-column-path.d.ts +2 -2
- package/dist/utils/get-column-path.js +3 -4
- package/dist/utils/get-column.d.ts +4 -4
- package/dist/utils/get-column.js +4 -5
- package/dist/utils/get-default-value.d.ts +2 -2
- package/dist/utils/get-default-value.js +2 -3
- package/dist/utils/get-graphql-query-and-variables.d.ts +1 -1
- package/dist/utils/get-graphql-query-and-variables.js +1 -2
- package/dist/utils/get-graphql-type.d.ts +2 -2
- package/dist/utils/get-graphql-type.js +1 -1
- package/dist/utils/get-ip-from-req.d.ts +1 -1
- package/dist/utils/get-ip-from-req.js +2 -2
- package/dist/utils/get-local-type.d.ts +1 -1
- package/dist/utils/get-local-type.js +3 -3
- package/dist/utils/get-milliseconds.js +1 -2
- package/dist/utils/get-permissions.d.ts +1 -1
- package/dist/utils/get-permissions.js +12 -12
- package/dist/utils/get-relation-info.d.ts +1 -1
- package/dist/utils/get-relation-info.js +3 -5
- package/dist/utils/get-relation-type.d.ts +1 -1
- package/dist/utils/get-relation-type.js +3 -4
- package/dist/utils/get-schema.d.ts +2 -2
- package/dist/utils/get-schema.js +20 -22
- package/dist/utils/get-snapshot-diff.js +2 -3
- package/dist/utils/get-snapshot.d.ts +3 -3
- package/dist/utils/get-snapshot.js +6 -8
- package/dist/utils/is-directus-jwt.js +1 -1
- package/dist/utils/is-url-allowed.js +5 -2
- package/dist/utils/job-queue.js +2 -0
- package/dist/utils/jwt.d.ts +1 -1
- package/dist/utils/merge-permissions-for-share.d.ts +1 -1
- package/dist/utils/merge-permissions-for-share.js +3 -4
- package/dist/utils/merge-permissions.d.ts +3 -3
- package/dist/utils/reduce-schema.d.ts +1 -1
- package/dist/utils/reduce-schema.js +12 -12
- package/dist/utils/sanitize-query.d.ts +1 -1
- package/dist/utils/sanitize-query.js +27 -27
- package/dist/utils/sanitize-schema.d.ts +2 -2
- package/dist/utils/should-skip-cache.d.ts +7 -0
- package/dist/utils/should-skip-cache.js +21 -0
- package/dist/utils/should-skip-cache.test.d.ts +1 -0
- package/dist/utils/track.js +16 -16
- package/dist/utils/transformations.d.ts +1 -1
- package/dist/utils/transformations.js +2 -4
- package/dist/utils/url.js +7 -2
- package/dist/utils/user-name.d.ts +1 -1
- package/dist/utils/validate-diff.js +7 -8
- package/dist/utils/validate-keys.d.ts +2 -2
- package/dist/utils/validate-keys.js +1 -1
- package/dist/utils/validate-query.d.ts +1 -1
- package/dist/utils/validate-query.js +3 -3
- package/dist/utils/validate-storage.js +8 -8
- package/dist/webhooks.js +3 -3
- package/package.json +36 -37
- package/dist/utils/with-timeout.d.ts +0 -1
- package/dist/utils/with-timeout.js +0 -16
package/dist/rate-limiter.js
CHANGED
|
@@ -8,28 +8,28 @@ const lodash_1 = require("lodash");
|
|
|
8
8
|
const rate_limiter_flexible_1 = require("rate-limiter-flexible");
|
|
9
9
|
const env_1 = __importDefault(require("./env"));
|
|
10
10
|
const get_config_from_env_1 = require("./utils/get-config-from-env");
|
|
11
|
-
function createRateLimiter(configOverrides) {
|
|
12
|
-
switch (env_1.default
|
|
11
|
+
function createRateLimiter(configPrefix = 'RATE_LIMITER', configOverrides) {
|
|
12
|
+
switch (env_1.default['RATE_LIMITER_STORE']) {
|
|
13
13
|
case 'redis':
|
|
14
|
-
return new rate_limiter_flexible_1.RateLimiterRedis(getConfig('redis', configOverrides));
|
|
14
|
+
return new rate_limiter_flexible_1.RateLimiterRedis(getConfig('redis', configPrefix, configOverrides));
|
|
15
15
|
case 'memcache':
|
|
16
|
-
return new rate_limiter_flexible_1.RateLimiterMemcache(getConfig('memcache', configOverrides));
|
|
16
|
+
return new rate_limiter_flexible_1.RateLimiterMemcache(getConfig('memcache', configPrefix, configOverrides));
|
|
17
17
|
case 'memory':
|
|
18
18
|
default:
|
|
19
|
-
return new rate_limiter_flexible_1.RateLimiterMemory(getConfig('memory', configOverrides));
|
|
19
|
+
return new rate_limiter_flexible_1.RateLimiterMemory(getConfig('memory', configPrefix, configOverrides));
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
exports.createRateLimiter = createRateLimiter;
|
|
23
|
-
function getConfig(store = 'memory', overrides) {
|
|
24
|
-
const config = (0, get_config_from_env_1.getConfigFromEnv)(
|
|
23
|
+
function getConfig(store = 'memory', configPrefix = 'RATE_LIMITER', overrides) {
|
|
24
|
+
const config = (0, get_config_from_env_1.getConfigFromEnv)(`${configPrefix}_`, `${configPrefix}_${store}_`);
|
|
25
25
|
if (store === 'redis') {
|
|
26
26
|
const Redis = require('ioredis');
|
|
27
27
|
delete config.redis;
|
|
28
|
-
config.storeClient = new Redis(env_1.default
|
|
28
|
+
config.storeClient = new Redis(env_1.default[`${configPrefix}_REDIS`] || (0, get_config_from_env_1.getConfigFromEnv)(`${configPrefix}_REDIS_`));
|
|
29
29
|
}
|
|
30
30
|
if (store === 'memcache') {
|
|
31
31
|
const Memcached = require('memcached');
|
|
32
|
-
config.storeClient = new Memcached(env_1.default
|
|
32
|
+
config.storeClient = new Memcached(env_1.default[`${configPrefix}_MEMCACHE`], (0, get_config_from_env_1.getConfigFromEnv)(`${configPrefix}_MEMCACHE_`));
|
|
33
33
|
}
|
|
34
34
|
delete config.enabled;
|
|
35
35
|
delete config.store;
|
|
@@ -8,10 +8,10 @@ const node_os_1 = __importDefault(require("node:os"));
|
|
|
8
8
|
const env_1 = require("../env");
|
|
9
9
|
const validateIP = async (ip, url) => {
|
|
10
10
|
const env = (0, env_1.getEnv)();
|
|
11
|
-
if (env
|
|
11
|
+
if (env['IMPORT_IP_DENY_LIST'].includes(ip)) {
|
|
12
12
|
throw new Error(`Requested URL "${url}" resolves to a denied IP address`);
|
|
13
13
|
}
|
|
14
|
-
if (env
|
|
14
|
+
if (env['IMPORT_IP_DENY_LIST'].includes('0.0.0.0')) {
|
|
15
15
|
const networkInterfaces = node_os_1.default.networkInterfaces();
|
|
16
16
|
for (const networkInfo of Object.values(networkInterfaces)) {
|
|
17
17
|
if (!networkInfo)
|
package/dist/server.js
CHANGED
|
@@ -32,14 +32,14 @@ const http = __importStar(require("http"));
|
|
|
32
32
|
const https = __importStar(require("https"));
|
|
33
33
|
const lodash_1 = require("lodash");
|
|
34
34
|
const qs_1 = __importDefault(require("qs"));
|
|
35
|
+
const update_check_1 = __importDefault(require("update-check"));
|
|
35
36
|
const url_1 = __importDefault(require("url"));
|
|
37
|
+
const package_json_1 = __importDefault(require("../package.json"));
|
|
36
38
|
const app_1 = __importDefault(require("./app"));
|
|
37
39
|
const database_1 = __importDefault(require("./database"));
|
|
40
|
+
const emitter_1 = __importDefault(require("./emitter"));
|
|
38
41
|
const env_1 = __importDefault(require("./env"));
|
|
39
42
|
const logger_1 = __importDefault(require("./logger"));
|
|
40
|
-
const emitter_1 = __importDefault(require("./emitter"));
|
|
41
|
-
const update_check_1 = __importDefault(require("update-check"));
|
|
42
|
-
const package_json_1 = __importDefault(require("../package.json"));
|
|
43
43
|
const get_config_from_env_1 = require("./utils/get-config-from-env");
|
|
44
44
|
async function createServer() {
|
|
45
45
|
const server = http.createServer(await (0, app_1.default)());
|
|
@@ -47,12 +47,11 @@ async function createServer() {
|
|
|
47
47
|
server.on('request', function (req, res) {
|
|
48
48
|
const startTime = process.hrtime();
|
|
49
49
|
const complete = (0, lodash_1.once)(function (finished) {
|
|
50
|
-
var _a, _b, _c, _d;
|
|
51
50
|
const elapsedTime = process.hrtime(startTime);
|
|
52
51
|
const elapsedNanoseconds = elapsedTime[0] * 1e9 + elapsedTime[1];
|
|
53
52
|
const elapsedMilliseconds = elapsedNanoseconds / 1e6;
|
|
54
|
-
const previousIn =
|
|
55
|
-
const previousOut =
|
|
53
|
+
const previousIn = req.socket._metrics?.in || 0;
|
|
54
|
+
const previousOut = req.socket._metrics?.out || 0;
|
|
56
55
|
const metrics = {
|
|
57
56
|
in: req.socket.bytesRead - previousIn,
|
|
58
57
|
out: req.socket.bytesWritten - previousOut,
|
|
@@ -85,13 +84,13 @@ async function createServer() {
|
|
|
85
84
|
size: metrics.out,
|
|
86
85
|
headers: res.getHeaders(),
|
|
87
86
|
},
|
|
88
|
-
ip: req.headers['x-forwarded-for'] ||
|
|
87
|
+
ip: req.headers['x-forwarded-for'] || req.socket?.remoteAddress,
|
|
89
88
|
duration: elapsedMilliseconds.toFixed(),
|
|
90
89
|
};
|
|
91
90
|
emitter_1.default.emitAction('response', info, {
|
|
92
91
|
database: (0, database_1.default)(),
|
|
93
92
|
schema: req.schema,
|
|
94
|
-
accountability:
|
|
93
|
+
accountability: req.accountability ?? null,
|
|
95
94
|
});
|
|
96
95
|
});
|
|
97
96
|
res.once('finish', complete.bind(null, true));
|
|
@@ -107,7 +106,7 @@ async function createServer() {
|
|
|
107
106
|
(0, terminus_1.createTerminus)(server, terminusOptions);
|
|
108
107
|
return server;
|
|
109
108
|
async function beforeShutdown() {
|
|
110
|
-
if (env_1.default
|
|
109
|
+
if (env_1.default['NODE_ENV'] !== 'development') {
|
|
111
110
|
logger_1.default.info('Shutting down...');
|
|
112
111
|
}
|
|
113
112
|
}
|
|
@@ -122,7 +121,7 @@ async function createServer() {
|
|
|
122
121
|
schema: null,
|
|
123
122
|
accountability: null,
|
|
124
123
|
});
|
|
125
|
-
if (env_1.default
|
|
124
|
+
if (env_1.default['NODE_ENV'] !== 'development') {
|
|
126
125
|
logger_1.default.info('Directus shut down OK. Bye bye!');
|
|
127
126
|
}
|
|
128
127
|
}
|
|
@@ -130,8 +129,8 @@ async function createServer() {
|
|
|
130
129
|
exports.createServer = createServer;
|
|
131
130
|
async function startServer() {
|
|
132
131
|
const server = await createServer();
|
|
133
|
-
const host = env_1.default
|
|
134
|
-
const port = env_1.default
|
|
132
|
+
const host = env_1.default['HOST'];
|
|
133
|
+
const port = env_1.default['PORT'];
|
|
135
134
|
server
|
|
136
135
|
.listen(port, host, () => {
|
|
137
136
|
(0, update_check_1.default)(package_json_1.default)
|
|
@@ -151,7 +150,7 @@ async function startServer() {
|
|
|
151
150
|
});
|
|
152
151
|
})
|
|
153
152
|
.once('error', (err) => {
|
|
154
|
-
if (
|
|
153
|
+
if (err?.code === 'EADDRINUSE') {
|
|
155
154
|
logger_1.default.error(`Port ${port} is already in use`);
|
|
156
155
|
process.exit(1);
|
|
157
156
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AbstractServiceOptions, Item, MutationOptions, PrimaryKey } from '../types';
|
|
1
|
+
import type { AbstractServiceOptions, Item, MutationOptions, PrimaryKey } from '../types';
|
|
2
2
|
import { ItemsService } from './items';
|
|
3
3
|
import { NotificationsService } from './notifications';
|
|
4
4
|
import { UsersService } from './users';
|
|
@@ -18,16 +18,17 @@ const items_1 = require("./items");
|
|
|
18
18
|
const notifications_1 = require("./notifications");
|
|
19
19
|
const users_1 = require("./users");
|
|
20
20
|
class ActivityService extends items_1.ItemsService {
|
|
21
|
+
notificationsService;
|
|
22
|
+
usersService;
|
|
21
23
|
constructor(options) {
|
|
22
24
|
super('directus_activity', options);
|
|
23
25
|
this.notificationsService = new notifications_1.NotificationsService({ schema: this.schema });
|
|
24
26
|
this.usersService = new users_1.UsersService({ schema: this.schema });
|
|
25
27
|
}
|
|
26
28
|
async createOne(data, opts) {
|
|
27
|
-
|
|
28
|
-
if (data.action === types_1.Action.COMMENT && typeof data.comment === 'string') {
|
|
29
|
+
if (data['action'] === types_1.Action.COMMENT && typeof data['comment'] === 'string') {
|
|
29
30
|
const usersRegExp = new RegExp(/@[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}/gi);
|
|
30
|
-
const mentions = (0, lodash_1.uniq)(
|
|
31
|
+
const mentions = (0, lodash_1.uniq)(data['comment'].match(usersRegExp) ?? []);
|
|
31
32
|
const sender = await this.usersService.readOne(this.accountability.user, {
|
|
32
33
|
fields: ['id', 'first_name', 'last_name', 'email'],
|
|
33
34
|
});
|
|
@@ -38,30 +39,30 @@ class ActivityService extends items_1.ItemsService {
|
|
|
38
39
|
});
|
|
39
40
|
const accountability = {
|
|
40
41
|
user: userID,
|
|
41
|
-
role:
|
|
42
|
-
admin:
|
|
43
|
-
app:
|
|
42
|
+
role: user['role']?.id ?? null,
|
|
43
|
+
admin: user['role']?.admin_access ?? null,
|
|
44
|
+
app: user['role']?.app_access ?? null,
|
|
44
45
|
};
|
|
45
46
|
accountability.permissions = await (0, get_permissions_1.getPermissions)(accountability, this.schema);
|
|
46
47
|
const authorizationService = new authorization_1.AuthorizationService({ schema: this.schema, accountability });
|
|
47
48
|
const usersService = new users_1.UsersService({ schema: this.schema, accountability });
|
|
48
49
|
try {
|
|
49
|
-
await authorizationService.checkAccess('read', data
|
|
50
|
+
await authorizationService.checkAccess('read', data['collection'], data['item']);
|
|
50
51
|
const templateData = await usersService.readByQuery({
|
|
51
52
|
fields: ['id', 'first_name', 'last_name', 'email'],
|
|
52
53
|
filter: { id: { _in: mentions.map((mention) => mention.substring(1)) } },
|
|
53
54
|
});
|
|
54
55
|
const userPreviews = templateData.reduce((acc, user) => {
|
|
55
|
-
acc[user
|
|
56
|
+
acc[user['id']] = `<em>${(0, user_name_1.userName)(user)}</em>`;
|
|
56
57
|
return acc;
|
|
57
58
|
}, {});
|
|
58
|
-
let comment = data
|
|
59
|
+
let comment = data['comment'];
|
|
59
60
|
for (const mention of mentions) {
|
|
60
61
|
const uuid = mention.substring(1);
|
|
61
62
|
// We only match on UUIDs in the first place. This is just an extra sanity check
|
|
62
63
|
if ((0, uuid_validate_1.default)(uuid) === false)
|
|
63
64
|
continue;
|
|
64
|
-
comment = comment.replace(new RegExp(mention, 'gm'),
|
|
65
|
+
comment = comment.replace(new RegExp(mention, 'gm'), userPreviews[uuid] ?? '@Unknown User');
|
|
65
66
|
}
|
|
66
67
|
comment = `> ${comment.replace(/\n+/gm, '\n> ')}`;
|
|
67
68
|
const message = `
|
|
@@ -71,17 +72,17 @@ ${(0, user_name_1.userName)(sender)} has mentioned you in a comment:
|
|
|
71
72
|
|
|
72
73
|
${comment}
|
|
73
74
|
|
|
74
|
-
<a href="${new url_1.Url(env_1.default
|
|
75
|
-
.addPath('admin', 'content', data
|
|
75
|
+
<a href="${new url_1.Url(env_1.default['PUBLIC_URL'])
|
|
76
|
+
.addPath('admin', 'content', data['collection'], data['item'])
|
|
76
77
|
.toString()}">Click here to view.</a>
|
|
77
78
|
`;
|
|
78
79
|
await this.notificationsService.createOne({
|
|
79
80
|
recipient: userID,
|
|
80
|
-
sender: sender
|
|
81
|
-
subject: `You were mentioned in ${data
|
|
81
|
+
sender: sender['id'],
|
|
82
|
+
subject: `You were mentioned in ${data['collection']}`,
|
|
82
83
|
message,
|
|
83
|
-
collection: data
|
|
84
|
-
item: data
|
|
84
|
+
collection: data['collection'],
|
|
85
|
+
item: data['item'],
|
|
85
86
|
});
|
|
86
87
|
}
|
|
87
88
|
catch (err) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { Range, Stat } from '@directus/storage';
|
|
3
|
-
import { Accountability } from '@directus/shared/types';
|
|
4
|
-
import { Knex } from 'knex';
|
|
3
|
+
import type { Accountability } from '@directus/shared/types';
|
|
4
|
+
import type { Knex } from 'knex';
|
|
5
5
|
import type { Readable } from 'node:stream';
|
|
6
|
-
import { AbstractServiceOptions, TransformationParams, TransformationPreset } from '../types';
|
|
6
|
+
import type { AbstractServiceOptions, TransformationParams, TransformationPreset } from '../types';
|
|
7
7
|
import { AuthorizationService } from './authorization';
|
|
8
8
|
export declare class AssetsService {
|
|
9
9
|
knex: Knex;
|
package/dist/services/assets.js
CHANGED
|
@@ -27,7 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.AssetsService = void 0;
|
|
30
|
-
const
|
|
30
|
+
const lodash_1 = require("lodash");
|
|
31
31
|
const mime_types_1 = require("mime-types");
|
|
32
32
|
const object_hash_1 = __importDefault(require("object-hash"));
|
|
33
33
|
const path_1 = __importDefault(require("path"));
|
|
@@ -36,24 +36,22 @@ const uuid_validate_1 = __importDefault(require("uuid-validate"));
|
|
|
36
36
|
const database_1 = __importDefault(require("../database"));
|
|
37
37
|
const env_1 = __importDefault(require("../env"));
|
|
38
38
|
const exceptions_1 = require("../exceptions");
|
|
39
|
+
const service_unavailable_1 = require("../exceptions/service-unavailable");
|
|
39
40
|
const logger_1 = __importDefault(require("../logger"));
|
|
40
41
|
const storage_1 = require("../storage");
|
|
41
42
|
const get_milliseconds_1 = require("../utils/get-milliseconds");
|
|
42
43
|
const TransformationUtils = __importStar(require("../utils/transformations"));
|
|
43
|
-
const with_timeout_1 = require("../utils/with-timeout");
|
|
44
44
|
const authorization_1 = require("./authorization");
|
|
45
|
-
sharp_1.default.concurrency(1);
|
|
46
|
-
// Note: don't put this in the service. The service can be initialized in multiple places, but they
|
|
47
|
-
// should all share the same semaphore instance.
|
|
48
|
-
const semaphore = new async_mutex_1.Semaphore(env_1.default.ASSETS_TRANSFORM_MAX_CONCURRENT);
|
|
49
45
|
class AssetsService {
|
|
46
|
+
knex;
|
|
47
|
+
accountability;
|
|
48
|
+
authorizationService;
|
|
50
49
|
constructor(options) {
|
|
51
50
|
this.knex = options.knex || (0, database_1.default)();
|
|
52
51
|
this.accountability = options.accountability || null;
|
|
53
52
|
this.authorizationService = new authorization_1.AuthorizationService(options);
|
|
54
53
|
}
|
|
55
54
|
async getAsset(id, transformation, range) {
|
|
56
|
-
var _a;
|
|
57
55
|
const storage = await (0, storage_1.getStorage)();
|
|
58
56
|
const publicSettings = await this.knex
|
|
59
57
|
.select('project_logo', 'public_background', 'public_foreground')
|
|
@@ -68,7 +66,7 @@ class AssetsService {
|
|
|
68
66
|
const isValidUUID = (0, uuid_validate_1.default)(id, 4);
|
|
69
67
|
if (isValidUUID === false)
|
|
70
68
|
throw new exceptions_1.ForbiddenException();
|
|
71
|
-
if (systemPublicKeys.includes(id) === false &&
|
|
69
|
+
if (systemPublicKeys.includes(id) === false && this.accountability?.admin !== true) {
|
|
72
70
|
await this.authorizationService.checkAccess('read', 'directus_files', id);
|
|
73
71
|
}
|
|
74
72
|
const file = (await this.knex.select('*').from('directus_files').where({ id }).first());
|
|
@@ -133,38 +131,38 @@ class AssetsService {
|
|
|
133
131
|
const { width, height } = file;
|
|
134
132
|
if (!width ||
|
|
135
133
|
!height ||
|
|
136
|
-
width > env_1.default
|
|
137
|
-
height > env_1.default
|
|
134
|
+
width > env_1.default['ASSETS_TRANSFORM_IMAGE_MAX_DIMENSION'] ||
|
|
135
|
+
height > env_1.default['ASSETS_TRANSFORM_IMAGE_MAX_DIMENSION']) {
|
|
138
136
|
throw new exceptions_1.IllegalAssetTransformation(`Image is too large to be transformed, or image size couldn't be determined.`);
|
|
139
137
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
sequentialRead: true,
|
|
145
|
-
failOn: env_1.default.ASSETS_INVALID_IMAGE_SENSITIVITY_LEVEL,
|
|
138
|
+
const { queue, process } = sharp_1.default.counters();
|
|
139
|
+
if (queue + process > env_1.default['ASSETS_TRANSFORM_MAX_CONCURRENT']) {
|
|
140
|
+
throw new service_unavailable_1.ServiceUnavailableException('Server too busy', {
|
|
141
|
+
service: 'files',
|
|
146
142
|
});
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
143
|
+
}
|
|
144
|
+
const readStream = await storage.location(file.storage).read(file.filename_disk, range);
|
|
145
|
+
const transformer = (0, sharp_1.default)({
|
|
146
|
+
limitInputPixels: Math.pow(env_1.default['ASSETS_TRANSFORM_IMAGE_MAX_DIMENSION'], 2),
|
|
147
|
+
sequentialRead: true,
|
|
148
|
+
failOn: env_1.default['ASSETS_INVALID_IMAGE_SENSITIVITY_LEVEL'],
|
|
149
|
+
});
|
|
150
|
+
transformer.timeout({
|
|
151
|
+
seconds: (0, lodash_1.clamp)(Math.round((0, get_milliseconds_1.getMilliseconds)(env_1.default['ASSETS_TRANSFORM_TIMEOUT'], 0) / 1000), 1, 3600),
|
|
152
|
+
});
|
|
153
|
+
if (transforms.find((transform) => transform[0] === 'rotate') === undefined)
|
|
154
|
+
transformer.rotate();
|
|
155
|
+
transforms.forEach(([method, ...args]) => transformer[method].apply(transformer, args));
|
|
156
|
+
readStream.on('error', (e) => {
|
|
157
|
+
logger_1.default.error(e, `Couldn't transform file ${file.id}`);
|
|
158
|
+
readStream.unpipe(transformer);
|
|
159
|
+
});
|
|
160
|
+
await storage.location(file.storage).write(assetFilename, readStream.pipe(transformer), type);
|
|
161
|
+
return {
|
|
162
|
+
stream: await storage.location(file.storage).read(assetFilename, range),
|
|
163
|
+
stat: await storage.location(file.storage).stat(assetFilename),
|
|
164
|
+
file,
|
|
165
|
+
};
|
|
168
166
|
}
|
|
169
167
|
else {
|
|
170
168
|
const readStream = await storage.location(file.storage).read(file.filename_disk, range);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Accountability, SchemaOverview } from '@directus/shared/types';
|
|
2
|
-
import { Knex } from 'knex';
|
|
3
|
-
import { AbstractServiceOptions, LoginResult } from '../types';
|
|
2
|
+
import type { Knex } from 'knex';
|
|
3
|
+
import type { AbstractServiceOptions, LoginResult } from '../types';
|
|
4
4
|
import { ActivityService } from './activity';
|
|
5
5
|
export declare class AuthenticationService {
|
|
6
6
|
knex: Knex;
|
|
@@ -20,8 +20,12 @@ const stall_1 = require("../utils/stall");
|
|
|
20
20
|
const activity_1 = require("./activity");
|
|
21
21
|
const settings_1 = require("./settings");
|
|
22
22
|
const tfa_1 = require("./tfa");
|
|
23
|
-
const loginAttemptsLimiter = (0, rate_limiter_1.createRateLimiter)({ duration: 0 });
|
|
23
|
+
const loginAttemptsLimiter = (0, rate_limiter_1.createRateLimiter)('RATE_LIMITER', { duration: 0 });
|
|
24
24
|
class AuthenticationService {
|
|
25
|
+
knex;
|
|
26
|
+
accountability;
|
|
27
|
+
activityService;
|
|
28
|
+
schema;
|
|
25
29
|
constructor(options) {
|
|
26
30
|
this.knex = options.knex || (0, database_1.default)();
|
|
27
31
|
this.accountability = options.accountability || null;
|
|
@@ -35,9 +39,8 @@ class AuthenticationService {
|
|
|
35
39
|
* to handle password existence checks elsewhere
|
|
36
40
|
*/
|
|
37
41
|
async login(providerName = constants_1.DEFAULT_AUTH_PROVIDER, payload, otp) {
|
|
38
|
-
var _a, _b, _c;
|
|
39
42
|
const { nanoid } = await import('nanoid');
|
|
40
|
-
const STALL_TIME = env_1.default
|
|
43
|
+
const STALL_TIME = env_1.default['LOGIN_STALL_TIME'];
|
|
41
44
|
const timeStart = perf_hooks_1.performance.now();
|
|
42
45
|
const provider = (0, auth_1.getAuthProvider)(providerName);
|
|
43
46
|
let userId;
|
|
@@ -56,7 +59,7 @@ class AuthenticationService {
|
|
|
56
59
|
.first();
|
|
57
60
|
const updatedPayload = await emitter_1.default.emitFilter('auth.login', payload, {
|
|
58
61
|
status: 'pending',
|
|
59
|
-
user: user
|
|
62
|
+
user: user?.id,
|
|
60
63
|
provider: providerName,
|
|
61
64
|
}, {
|
|
62
65
|
database: this.knex,
|
|
@@ -67,7 +70,7 @@ class AuthenticationService {
|
|
|
67
70
|
emitter_1.default.emitAction('auth.login', {
|
|
68
71
|
payload: updatedPayload,
|
|
69
72
|
status,
|
|
70
|
-
user: user
|
|
73
|
+
user: user?.id,
|
|
71
74
|
provider: providerName,
|
|
72
75
|
}, {
|
|
73
76
|
database: this.knex,
|
|
@@ -75,9 +78,9 @@ class AuthenticationService {
|
|
|
75
78
|
accountability: this.accountability,
|
|
76
79
|
});
|
|
77
80
|
};
|
|
78
|
-
if (
|
|
81
|
+
if (user?.status !== 'active') {
|
|
79
82
|
emitStatus('fail');
|
|
80
|
-
if (
|
|
83
|
+
if (user?.status === 'suspended') {
|
|
81
84
|
await (0, stall_1.stall)(STALL_TIME, timeStart);
|
|
82
85
|
throw new exceptions_1.UserSuspendedException();
|
|
83
86
|
}
|
|
@@ -139,7 +142,7 @@ class AuthenticationService {
|
|
|
139
142
|
};
|
|
140
143
|
const customClaims = await emitter_1.default.emitFilter('auth.jwt', tokenPayload, {
|
|
141
144
|
status: 'pending',
|
|
142
|
-
user: user
|
|
145
|
+
user: user?.id,
|
|
143
146
|
provider: providerName,
|
|
144
147
|
type: 'login',
|
|
145
148
|
}, {
|
|
@@ -147,19 +150,19 @@ class AuthenticationService {
|
|
|
147
150
|
schema: this.schema,
|
|
148
151
|
accountability: this.accountability,
|
|
149
152
|
});
|
|
150
|
-
const accessToken = jsonwebtoken_1.default.sign(customClaims, env_1.default
|
|
151
|
-
expiresIn: env_1.default
|
|
153
|
+
const accessToken = jsonwebtoken_1.default.sign(customClaims, env_1.default['SECRET'], {
|
|
154
|
+
expiresIn: env_1.default['ACCESS_TOKEN_TTL'],
|
|
152
155
|
issuer: 'directus',
|
|
153
156
|
});
|
|
154
157
|
const refreshToken = nanoid(64);
|
|
155
|
-
const refreshTokenExpiration = new Date(Date.now() + (0, get_milliseconds_1.getMilliseconds)(env_1.default
|
|
158
|
+
const refreshTokenExpiration = new Date(Date.now() + (0, get_milliseconds_1.getMilliseconds)(env_1.default['REFRESH_TOKEN_TTL'], 0));
|
|
156
159
|
await this.knex('directus_sessions').insert({
|
|
157
160
|
token: refreshToken,
|
|
158
161
|
user: user.id,
|
|
159
162
|
expires: refreshTokenExpiration,
|
|
160
|
-
ip:
|
|
161
|
-
user_agent:
|
|
162
|
-
origin:
|
|
163
|
+
ip: this.accountability?.ip,
|
|
164
|
+
user_agent: this.accountability?.userAgent,
|
|
165
|
+
origin: this.accountability?.origin,
|
|
163
166
|
});
|
|
164
167
|
await this.knex('directus_sessions').delete().where('expires', '<', new Date());
|
|
165
168
|
if (this.accountability) {
|
|
@@ -182,7 +185,7 @@ class AuthenticationService {
|
|
|
182
185
|
return {
|
|
183
186
|
accessToken,
|
|
184
187
|
refreshToken,
|
|
185
|
-
expires: (0, get_milliseconds_1.getMilliseconds)(env_1.default
|
|
188
|
+
expires: (0, get_milliseconds_1.getMilliseconds)(env_1.default['ACCESS_TOKEN_TTL']),
|
|
186
189
|
id: user.id,
|
|
187
190
|
};
|
|
188
191
|
}
|
|
@@ -277,12 +280,12 @@ class AuthenticationService {
|
|
|
277
280
|
schema: this.schema,
|
|
278
281
|
accountability: this.accountability,
|
|
279
282
|
});
|
|
280
|
-
const accessToken = jsonwebtoken_1.default.sign(customClaims, env_1.default
|
|
281
|
-
expiresIn: env_1.default
|
|
283
|
+
const accessToken = jsonwebtoken_1.default.sign(customClaims, env_1.default['SECRET'], {
|
|
284
|
+
expiresIn: env_1.default['ACCESS_TOKEN_TTL'],
|
|
282
285
|
issuer: 'directus',
|
|
283
286
|
});
|
|
284
287
|
const newRefreshToken = nanoid(64);
|
|
285
|
-
const refreshTokenExpiration = new Date(Date.now() + (0, get_milliseconds_1.getMilliseconds)(env_1.default
|
|
288
|
+
const refreshTokenExpiration = new Date(Date.now() + (0, get_milliseconds_1.getMilliseconds)(env_1.default['REFRESH_TOKEN_TTL'], 0));
|
|
286
289
|
await this.knex('directus_sessions')
|
|
287
290
|
.update({
|
|
288
291
|
token: newRefreshToken,
|
|
@@ -295,7 +298,7 @@ class AuthenticationService {
|
|
|
295
298
|
return {
|
|
296
299
|
accessToken,
|
|
297
300
|
refreshToken: newRefreshToken,
|
|
298
|
-
expires: (0, get_milliseconds_1.getMilliseconds)(env_1.default
|
|
301
|
+
expires: (0, get_milliseconds_1.getMilliseconds)(env_1.default['ACCESS_TOKEN_TTL']),
|
|
299
302
|
id: record.user_id,
|
|
300
303
|
};
|
|
301
304
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Accountability, PermissionsAction, SchemaOverview } from '@directus/shared/types';
|
|
2
|
-
import { Knex } from 'knex';
|
|
3
|
-
import { AbstractServiceOptions, AST, Item, PrimaryKey } from '../types';
|
|
1
|
+
import type { Accountability, PermissionsAction, SchemaOverview } from '@directus/shared/types';
|
|
2
|
+
import type { Knex } from 'knex';
|
|
3
|
+
import type { AbstractServiceOptions, AST, Item, PrimaryKey } from '../types';
|
|
4
4
|
import { PayloadService } from './payload';
|
|
5
5
|
export declare class AuthorizationService {
|
|
6
6
|
knex: Knex;
|