Commit Graph

569 Commits

Author SHA1 Message Date
ian
307cef8f5e Add permissions check for relational field only if child has filter (#12549)
* Add permissions check for relational field only if child has filter

* Allow id field for actions such as update and delete

* Use primary key instead of id

* Add test
2022-04-06 11:30:50 -04:00
ian
c6736c4f19 Fix access to count(*) aggregation (#12607) 2022-04-06 11:14:51 -04:00
Wryn (yage) Wagner
0930c2df97 Safe Metadata Upload (#12511)
* [Related to #11292] Safe Metadata Upload
- Created FILE_METADATA_ALLOWLIST
- Added test library for `FilesService`

* Rename ALLOWLIST->ALLOW_LIST to be consistent with other env vars

* Make sure it still works for files without Exif

* Prevent breaking changes in metadata formatting

* Allow * for all

* Fix md sup

Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
2022-04-04 20:43:56 -04:00
Christian Rendl
0206a3d2cc Added default locale before login (#8196)
* Added default locale before login

* Use project_language as default language for new users

* Revert "Use project_language as default language for new users"

* Allow user's language field to be nullable; Use project_language whenever language is unset;

* Apply suggestions from code review

Co-authored-by: Nicola Krumschmidt <nicola.krumschmidt@freenet.de>

* Make "Project Default" option in system-language interface configurable

* Set language only if user language is not null

* Introduced translation for project_language field; Use translation in system-language interface

* Set app language only from app.vue;
Included watcher to restore project_language if user's language is (re)set to null

* Removed .alter() in knex migration since it's not needed for changing default and breaks checks

* Reverted previous change in migration; .alter() is needed for changing column defaults

* Reverted migration to use .defaultTo(null) to set default value

* Update position of project language field in settings

* Fix cockroachdb test error in knex migration

* Fix cockroachdb test error in knex migration

* Apply migration fix also on oracle databases

* Apply changes from code review

* Rename migration to fix migration key error

* Move setLanguage calls to server.ts and hydrate.ts

Co-authored-by: Nicola Krumschmidt <nicola.krumschmidt@freenet.de>
Co-authored-by: jaycammarano <jay.cammarano@gmail.com>
Co-authored-by: Christian Rendl <cr@mutor.at>
Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
2022-04-01 14:30:56 -04:00
ian
8139b5b467 Fix filter permissions for relational fields (#12426)
* Fix filter permissions for relational fields

* Add tests for filtering of top level relational field with and without permissions on relational table

* Find read permission only

* Update test with more permissions
2022-04-01 14:20:44 -04:00
Rijk van Zanten
3307bed5fd Improve cache reliability in DDL operations (#12400)
* Add TTL to schema cache

* Clear caches on unexpected errors in DDL

* Consistent return value use

* Don't set a default value for schema ttl
2022-04-01 13:24:20 -04:00
Rijk van Zanten
175fb849c4 Add field-level validation (#12363)
* Add field validation column

* Add frontend config for validation

* Make it work

* Add regex to filter configuration

* Fix const/let

* Add custom validation message support

* Add custom validation message tooltip inline

* Fix custom names in validation errors up top

* Fix type error

* Nog eentje om het af te leren

* resolve unused import warnings
2022-03-25 18:03:36 -04:00
Spencer Jones
7d391ed4fa fix: handle nulls when processing m2m (#12187)
fixes #12099

Co-authored-by: Spencer Jones <sjones@morningconsult.com>
2022-03-25 13:42:55 -04:00
CommanderRoot
d81adcd674 refactor: replace deprecated String.prototype.substr() (#12344)
.substr() is deprecated so we replace it with .slice() which works similarily but isn't deprecated

Signed-off-by: Tobias Speicher <rootcommander@gmail.com>
2022-03-25 13:36:18 -04:00
Rijk van Zanten
caf698ed2f Use Url util to construct urls everywhere (#12394)
Fixes #12345
2022-03-25 13:21:59 -04:00
Rijk van Zanten
de152d1995 Fix inconsistent delete action payload (#12328)
Fixes #12326
2022-03-23 10:40:16 -04:00
ian
e2eb2801c5 Prefix existing field typecasting flags with "cast-" (#12141)
* Prefix typecasting field flags

* Fix payload test

* Update flags for system tables and for field creation in app

* Revert cast-hash and cast-uuid

* Rename migrations file to current date
2022-03-21 14:46:48 -04:00
ian
72180f7027 Add query filter validation with permissions (#12190)
* Add query filter validation with permissions

* Allow all fields in test

* Revert test and add check for permissions with empty fields

* Add check for deep filters

* Add tests

Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
2022-03-21 18:19:37 +00:00
ian
5068ca096b Add lock for system cache (#12017)
* Add lock for system cache

* Add lock when forcing a flush

* Simplify code

Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
2022-03-18 15:54:02 -04:00
Azri Kahar
e6e129615e fix M2O field deletion (#11538)
* fix M2O field deletion

* fix lint

* fix for MySQL

* Pull final dropColumn out of transaction

* Forget that, check for existing constraint before deleting it instead

* Fix lint warning in unrelated file

Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
2022-03-18 15:36:50 -04:00
Rijk van Zanten
1c3e94d830 Add new export experience (#12201)
* Use script setup

* Start on export dialog

* Use new system field interface, replace limit with numeric input

* Set placeholder

* Add sort config

* Use folder picker, correct layoutQuery use

* Add local download button

* Allow writing exports to file

* Add notification after export

* Fix sort config, use new export endpoint

* Setup notification hints

* Add information notice

* Fix local limit, cancel button

* Add (basic) docs for export functionality

* Fix json export file format

* Implement xml batch stitching

* Resolve review points
2022-03-17 15:43:45 -04:00
ian
a79290e4a2 Export authorization service (#12208) 2022-03-17 08:52:42 -04:00
Rijk van Zanten
6da3f1ed50 Add support for import ip deny list (#12025)
* Add support for import ip deny list

* Fix typo
2022-03-07 18:09:08 -05:00
Rijk van Zanten
eec21d8d9a Add "items.sort" event (#11954)
* Adds the 'sort_updated' event emit after items are sorted

Signed-off-by: Mihovil Ilakovac <mihovil.ilakovac@gmail.com>

* Updates the event name to 'sort_update'. Docs.

Signed-off-by: Mihovil Ilakovac <mihovil.ilakovac@gmail.com>

* Updates the event name to `sort`

* Add item/to to hook, fix docs

Co-authored-by: Mihovil Ilakovac <mihovil.ilakovac@gmail.com>
2022-03-04 19:58:47 -05:00
Rijk van Zanten
6a3eb823c3 Update base theme of the App (#11952)
* Add migration to remove default value from project_color

* Upgrade the default theme

* Do a pass over the header buttons

* Do another pass over --warning uses

* Little things

* Tweak smoke

* Use updated map

* Use dark system elements in dark mode

* Remove outdated files, update toasts

* Use correct delete button style for role

* Use primary for created point

* Tweak spacing in revisions section

* Use primary for sidebar sections

* Various color tweaks and changes

* Update base color palette

* Update "css reset" code

* Remove splashscreens, add default favicon

* Add primary highlight to datamodel page

* dark mode color update

* fix sign out hover color

* Does this help?!

* This fixes some loading issues

Fixes https://github.com/directus/directus/issues/10707

* Calculate default pretty background?

* Fix public view with logo

* Fix responsiveness of login page

* adjust notification group width to be equal

* Do an absolute pointless task that doesn't do anything

It was suggested that it could fix the stylelint error in tests, but alas

* Remove stylelint

Doesn't seem to play nice with script setup and other changes

Co-authored-by: Ben Haynes <ben@rngr.org>
2022-03-04 18:53:39 -05:00
Azri Kahar
9148062247 fix permission for field functions (#11771) 2022-02-21 11:19:03 -05:00
ian
773ef6dda9 Prevent creation of relationships on primary keys (#11441)
* Prevent creation of relationships on primary keys

* Use schema instead of schemaInspector
2022-02-16 15:17:33 +00:00
Oreille
c0fab454fd Explicitly set column nullable when unspecified (#11572) 2022-02-10 11:41:55 -05:00
Nitwel
8af5ddfceb Fix not being able to delete folder in data-model (#11432)
* fix not being able to delete folder in data-model

* add e2e tests

* fix e2e tests

* fix e2e tests
2022-02-04 13:13:42 -05:00
Rijk van Zanten
eee8725140 Resolve transaction unreliability issues in schema alterations (#11279)
* Start with test setup

* Reorder operations in transaction

Prevent dead roaches

* Fix test post payload

* Fix tests for real now?
2022-02-03 20:34:00 -05:00
Aiden Foxx
4e0c27db73 Fixed issue when updating columns in Oracle (#11359)
* Fixed issue when updating columns in Oracle

* Fix lint error

* Removed optional chaining
2022-01-31 13:47:06 -05:00
Rijk van Zanten
7164dd8ae3 Return empty string as empty array in CSV type (#11256)
* Fix empty strings in CSV being returned wrong

Fixes #11194

* Add tests for CSV
2022-01-25 00:47:57 +00:00
Jay Cammarano
ef9b30c0e1 Integration tests set up and examples (#10419)
* tsconfig loosened to match api

* integration test folder and script

* .env mock isn't needed

* mock-env, locations of tests

* I was wrong.

* Updated progress

* schemas => getSchema(), exported getColumnPreprocessor()

* change imports to allow build

* add MockClient as DB Client (should mock getDBClient())

* move authservice into. not used elsewhere

* test passing

* remove unneeded test for this PR

* removed unneded fields from rawItem

* formatting

* createOne test passing

* typo

* removed int specific jest.config

* use systemSchema over getSchema()

* this.knex over getDatabase()

* mock getDatabaseClient

* removed unused mock-env

* formatting

* removed unused collections from schema

* response => responseOnce

* more direct

* unused var

* more tests please!

* test for: createOne no permissions

* removed broken test for now

* clean up

* readOne tests what does into db and returned

* added bindings check

* added into db sql check

* moved tests outside src

* changed ts config

* cli test location changed

* removed looking for tests in src

* readding it for e2e tests? Seems fishy

* Integration tests for ItemsService user tables (#11208)

* renamed ItemsService test to match src file name

* add user table schema

* system/user tables use .each, formatting needed

* format system and user better in title

* tables/table=> schemas/schema

* filter _eq test passing

* comment for later and formatting

* everything in it's right place

* future proofing as more fields are added

* removed duplicate test

* formatting

* readMany() filter: _or

Co-authored-by: Jay Cammarano <jaycammarano@gmail.com>

* added knex check before getDatabase()

* Move util test to tests folder

Co-authored-by: Jay Cammarano <jaycammarano@gmail.com>
Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
2022-01-24 19:55:08 +00:00
ian
191d72c156 Fix nested transactions on SQLite (#11227)
* Fix nested transactions on SQLite

* Increase MSSQL request timeout
2022-01-24 10:16:32 -05:00
Azri Kahar
6368f641e5 Add CSV/JSON Import capability via App (#11050)
* Allow import data to collections via App directly

* clear file input after import

* tweak translations

* reduce vertical gap

* fix clear file input logic

* Change export data button text

* update start import button disabled color

* undo unintended changes to translations quotes

* add docs for importing items sidebar

* update exporting items docs

* Combine import/export sidebar details

* Remove unused import detail

* Fix docs

Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
2022-01-20 16:57:29 -05:00
Michael Schramm
75b5f33727 Implement CockroachDB support (#10113)
* base changes for cockroachdb

* allow creating of tables

* allow deleting of fields

* allow deleting of tables

* rebase

* fix migrations

* bump knex-schema-inspector to 1.7.0

* Update package-lock

* Add cockroach to debugging docker-compose file

* Remove unused import

* Tweak name in example.env

* Force nullable primary keys in cockroach

* Tweak shares migration to run on cockroach

* Rename var for clarification

* suggestion for migration helper

* change to schema and update remaining migrations

* Remove custom cockroach schema in favor of sharing with pg

* Fix migrations for CockroachDB

* Hopefully fix Oracle migrations 🤞🏻

* Make ~~aiden~~ oracle happy

* Resolve branching paths in migrations

* Enable tests for cockroach

* Fix test config

* One more config change for good measure

* Adjust test to match cockroach's bigint auto-int structure

* Increase request timeout for mssql

* Update api/src/database/helpers/schema/types.ts

Co-authored-by: Aiden Foxx <aiden.foxx.mail@gmail.com>

Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
Co-authored-by: Oreille <33065839+Oreilles@users.noreply.github.com>
Co-authored-by: Aiden Foxx <aiden.foxx.mail@gmail.com>
2022-01-20 14:14:38 -05:00
John Huffsmith
e7ada1f173 Moving schema and relation types into shared package (#11179)
* moving schema and relation types into shared package

* updating SchemaOverview imports

* removing duplicate import
2022-01-20 13:36:19 -05:00
Nicola Krumschmidt
b96fb77cbf Clean up emitting "items" events (#11163) 2022-01-19 13:17:48 -05:00
Azri Kahar
c40585c9c8 fix onIn values (#11129) 2022-01-19 11:36:16 -05:00
Aiden Foxx
f61ed2fb26 Fixed broken auth SQL on Oracle (#11077)
* Fixed broken auth SQL on Oracle

* Fix JS context issue

* Make linter happy
2022-01-17 16:25:56 -05:00
Azri Kahar
74bb4a7c9a Add Unsupported Media Type Exception (#11096)
* add unsuported media type exception

* throw error when not multipart/form-data

* use unsupportedMediaType when checking import file

* add `UNSUPPORTED_MEDIA_TYPE` to Error Codes docs
2022-01-17 10:09:26 -05:00
Nicola Krumschmidt
42f26dc55f Add extension auto reloading to the API (#10881)
* Add extension auto reloading to the API

This can be enabled by using the `EXTENSIONS_AUTO_RELOAD` env var.

* Add logger message indicating watch mode

Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
2022-01-06 20:02:43 +00:00
Rijk van Zanten
e4db9b2f05 Fix refresh token payload structure on shared refresh (#10875)
Fixes #10822
2022-01-05 15:59:27 -05:00
John Huffsmith
8a05018883 Left Join-ing on roles to allow users without roles to login (#10836)
* Left Join-ing on roles to allow users without roles to login

* moving filter logic to more appropriate location
2022-01-04 12:24:44 -05:00
José Varela
cc076494ff Check if is UUID before check permissions (#10837)
On checking permissions it reads the value from database, so we need to verify if is UUID before this process
2022-01-04 10:04:04 -05:00
Wryn (yage) Wagner
b9636e3243 [#10500] update_users_me to graphql; added documentation for users/me update for both REST and graphql api (#10622)
Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
2021-12-30 20:11:48 -05:00
Ben Haynes
cbe139d7e9 style tweaks (#10760)
* style tweaks

* fix linting

* Make project descriptor configurable

* Add missing import

Co-authored-by: Azri Kahar <42867097+azrikahar@users.noreply.github.com>
Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
2021-12-30 19:40:38 -05:00
ian
8a0fba0691 Replace knex.fn.now() in DB queries (#10736) 2021-12-28 11:03:03 -05:00
Azri Kahar
15ffe6bd3f check system deny list in relations for GraphQL (#10674) 2021-12-24 13:21:49 -05:00
Rijk van Zanten
dbf35a1736 Add ability to share items with people outside the platform (#10663)
* Add directus_shares

* Don't check for usage limit on refresh

* Add all endpoints to the shares controller

* Move route `/auth/shared` to `/shared/auth`

* Add password protection

* Add `share` action in permissions

* Add `shares/:pk/info`

* Start on shared-view

* Add basic styling for full shared view

* Fixed migrations

* Add inline style for shared view

* Allow title override

* Finish /info endpoint for shares

* Add basic UUID validation to share/info endpont

* Add UUID validation to other routes

* Add not found state

* Cleanup /extract/finish share login endpoint

* Cleanup auth

* Added `share_start` and `share_end`

* Add share sidebar details.

* Allow share permissions configuration

* Hide the `new_share` button for unauthorized users

* Fix uses_left displayed value

* Show expired / upcoming shares

* Improved expired/upcoming styling

* Fixed share login query

* Fix check-ip and get-permissions middlewares behaviour when role is null

* Simplify cache key

* Fix typescript linting issues

* Handle app auth flow for shared page

* Fixed /users/me response

* Show when user is authenticated

* Try showing item drawer in shared page

* Improved shared card styling

* Add shares permissions and change share card styling

* Pull in schema/permissions on share

* Create getPermissionForShare file

* Change getPermissionsForShare signature

* Render form + item on share after auth

* Finalize public front end

* Handle fake o2m field in applyQuery

* [WIP]

* New translations en-US.yaml (Bulgarian) (#10585)

* smaller label height (#10587)

* Update to the latest Material Icons (#10573)

The icons are based on https://fonts.google.com/icons

* New translations en-US.yaml (Arabic) (#10593)

* New translations en-US.yaml (Arabic) (#10594)

* New translations en-US.yaml (Portuguese, Brazilian) (#10604)

* New translations en-US.yaml (French) (#10605)

* New translations en-US.yaml (Italian) (#10613)

* fix M2A list not updating (#10617)

* Fix filters

* Add admin filter on m2o role selection

* Add admin filter on m2o role selection

* Add o2m permissions traversing

* Finish relational tree permissions generation

* Handle implicit a2o relation

* Update implicit relation regex

* Fix regex

* Fix implicitRelation unnesting for new regex

* Fix implicitRelation length check

* Rename m2a to a2o internally

* Add auto-gen permissions for a2o

* [WIP] Improve share UX

* Add ctx menu options

* Add share dialog

* Add email notifications

* Tweak endpoint

* Tweak file interface disabled state

* Add nicer invalid state to password input

* Dont return info for expired/upcoming shares

* Tweak disabled state for relational interfaces

* Fix share button for non admin roles

* Show/hide edit/delete based on permissions to shares

* Fix imports of mutationtype

* Resolve (my own) suggestions

* Fix migration for ms sql

* Resolve last suggestion

Co-authored-by: Oreilles <oreilles.github@nitoref.io>
Co-authored-by: Oreilles <33065839+oreilles@users.noreply.github.com>
Co-authored-by: Ben Haynes <ben@rngr.org>
Co-authored-by: Thien Nguyen <72242664+tatthien@users.noreply.github.com>
Co-authored-by: Azri Kahar <42867097+azrikahar@users.noreply.github.com>
2021-12-23 18:51:59 -05:00
keesvanbemmel
549b9ee8e1 Expanded try catch around extracting metadata (#10497)
* Expanded try catch around extracting metadata

* Run linter

* Added extra try catch block

* Run linter

Co-authored-by: ian <licitdev@gmail.com>
2021-12-14 09:31:13 -05:00
ian
ef0091f2f4 Add password policy check during password reset (#10409)
* Add password policy check during password reset

* Prevent token reuse after password reset
2021-12-10 15:16:07 -05:00
Oreille
52deb28fc2 Add items.read filter hook (#10284)
* Add items.read filter hook

* Fix issue cause by query being wrongly modified

Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
2021-12-03 13:36:49 -05:00
ian
851199a9fd Check if file exists in assets service (#10261)
* Check if file exists in assets service

* Remove dupliate check from assets controller

Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
2021-12-03 17:29:41 +00:00
Oreille
e03bb391b0 Add items.read filter hook (#10279) 2021-12-03 16:37:04 +00:00