Commit Graph

144 Commits

Author SHA1 Message Date
Azri Kahar
220398f177 prevent ambiguous role selection in middleware (#8334) 2021-09-27 10:29:13 -04:00
Azri Kahar
0575cb4836 Add custom JWTs support for static token (#7830)
* add support for custom JWTs as static token

* check issuer during jwt.verify in authentication

* add issuer in JWTs for pwd resets & user invites
2021-09-09 14:47:28 -04:00
Nicola Krumschmidt
d64ca14348 Explicitly set catch parameters to any type (#7654)
This fixes not being able to build the repo due to type issues
introduced by the Typescript 4.4 option "useUnknownInCatchVariables",
which is enabled by default in strict mode.
2021-08-27 10:33:30 -04:00
Sam Milledge
19424feefa Fixes for GraphQL variables in HTTP GET requests (#7416)
* Fix missing GraphQL variables in HTTP GET requests

* Fix GraphQL query request caching

 - Fix incorrect response when the query contains variables
 - Added tests for cache keys and cache middleware

* Update api/src/utils/get-cache-key.test.ts

Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
2021-08-16 23:16:41 +00:00
Rijk van Zanten
faa71c7595 Add cache connection fallbacks (#7226) 2021-08-05 22:27:10 +02:00
Rijk van Zanten
d0f6cb35e3 Support dynamic variables in conditional fields (#7202)
* Move accountability type to shared

* Rely on shared for parse-filter

* Install date-fns

* Support dynamic variables in conditional fields

Closes #7157
2021-08-05 01:51:15 +02:00
rijkvanzanten
e4add23ce6 Fix linter warnings 2021-08-03 17:30:36 -04:00
Rijk van Zanten
ef3d618d6c Add support for app-required field state (#7166)
* Add "required" option to fields

* Move some exceptions to shared

* Do client side validation for required

* Add conditional required support
2021-08-03 23:04:24 +02:00
Rijk van Zanten
206f2380b5 Fix cache-key causing problems in memcached (#7021)
* Add memcached to docker-compose

* Use object hash for cache key

Fixes #6823
2021-07-28 01:18:09 +02:00
Rijk van Zanten
44082c60e1 Add schema caching (#6456)
* Rework cache handler to be function export

* Add default schema caching

* Add schema cache

* Auto purge schema cache on schema change from api

* Only set last_access value on login

* Add note on schema cache setting
2021-06-22 20:50:20 -04:00
Nacho García
0b8fb9fae8 Change cache-control heeaders (#6355) 2021-06-17 14:55:27 -04:00
Rijk van Zanten
d56f02697a Allow overriding the s-maxage cache header (#6294)
* Allow overriding the s-maxage cache header

* Only load expiry / set headers when cache exists
2021-06-15 17:11:29 -04:00
Rijk van Zanten
77e00b7db4 Don't initialize database on file require (#6003) 2021-06-02 11:41:42 -04:00
Rijk van Zanten
9ac9a8d44b Add JSON/CSV Import (#5660)
* Add async/destroy packages

* Target node 12+

* Return payload data in json export

* Import JSON from Stream

* Add CSV import support

* Add CSV Import

* Add docs

* Add missing types
2021-05-14 11:03:12 -04:00
Rijk van Zanten
b6964fa1a1 Add XML export (#5526) 2021-05-07 12:55:03 -04:00
Pyll Gomez
09b19b9191 Session store knex (#5432)
* Rotate JPG image on upload #4206

* fixes #3949 width/height generated for gif and tif

* API hooks for event added for auth.login #4079

* updated doc for api hooks for new auth.login event

* Style tweaks

* Update docs

* Tweak docs some more

* Spelling error

* Allow non-required flags and pass to hook

* SDK - Persistent login refresh fixes #4113

* Fixed #4145 SDK, Token Expired error

* Spell check

* Docs Spell check

* Docs Spell check

* Docs Spell check

* update docs for sdk-js

* To delete all expired session from db on login

* corrected the condition for the delete

* changed the from Date.now to new date .

* Move it inline

* Added Knex option for Session store

Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
2021-05-03 11:46:42 -04:00
Rijk van Zanten
a3898fa321 Add SESSION_STORE options (#5403)
* Allow configuring the session storage driver

Fixes #3814

* Document SESSION_STORE env var

* Add missing dependency

* Docs tweak
2021-04-30 18:18:39 -04:00
rijkvanzanten
3c5c0a043c Fix error handler not being recognized 2021-04-29 18:09:04 -04:00
rijkvanzanten
801e868554 Fix remaining eslint errors
h/t @paescuj
2021-04-29 15:55:12 -04:00
Pascal Jufer
acd41eb0be Syntax fixes (#5367)
* Declare return types on functions

And a very few other type related minor fixes

* Minor syntax fixes

* Remove unnecessary escape chars in regexes
* Remove unnecessary awaits
* Replace deprecated req.connection with req.socket
* Replace deprecated upload with uploadOne
* Remove unnecessary eslint-disable-next-line comments
* Comment empty functions / catch or finally clauses
* Fix irregular whitespaces
* Add missing returns (null)
* Remove unreachable code
* A few logical fixes
* Remove / Handle non-null assertions which are certainly unnecessary (e.g. in
tests)
2021-04-29 12:11:43 -04:00
Rijk van Zanten
f1e2338142 Add auth password policy / login attempts support (#5225)
* Check auth password policy on user modifications

* Show validation errors in drawer-batch

* Allow custom password policy, add placeholder

* Add UserSuspended exception

* Add user suspended error translation

* Move rate limiter creation into root helper

* Add login attempts support to authentication service

* Don't authenticate into settings service when checking password policy
2021-04-23 17:42:46 -04:00
José Varela
5f425e4595 api: ignore singleton on validate-batch (#5209) 2021-04-23 12:48:25 +00:00
Rijk van Zanten
b40c62d257 Add support for SEARCH method (#5183)
* Add search method support for advanced get

* Add docs for SEARCH
2021-04-21 13:35:16 -04:00
rijkvanzanten
f836c90990 Set cache-control no-cache for private resources
Forces the browser to revalidate the cached item with the server, ensuring you don't pull the wrong records from the browser cache.

Fixes #5175
2021-04-21 13:27:15 -04:00
Rijk van Zanten
3b05372713 Finalize services API (#5170)
* Start the xOne/xMany work

* Update update/upsert

* Finish updating itemsservice

* Add comments, add nested revisions on update

* Use new internal api

* Update collectionService to one/many structure

* Move files to one/many structure

* Move permissions to one/many structure

* Move relations service to one/many structure

* Move roles to one/many structure

* Move users service over

* Move webhooks to updated structure

* Move deprecated methods to the bottom

* Replace deprecated uses

* Use new methods in controllers, add batch update/delete by query

* Use updated methods in API

* Fix email being required

* Remove unnecessary DB call

* Fix batch update/delete validation
2021-04-20 18:06:27 -04:00
Rijk van Zanten
dd551f3571 Add non-items system Resolvers (#4863)
* Add auth resolvers

* Add password request/reset

* Add up until file import

* Make revisions read only

* Add server resolvers

* Add utils

* Add schema resolvers for schema manipulation
2021-04-06 18:04:35 -04:00
Rijk van Zanten
f90c31b798 GraphQL 2.0 (#4625)
* Start on GraphQL "2.0", add methodnotallowed exceptoin

* Fix relative file pointer in peer dep

* [WIP] Add pre-filtered schema to SchemaOverview

* Use root schema as is, add reduce-schema util

* Use reduceSchema in the wild

* Base schema on local reduced schema

* Remove todo

* Use graphql-compose to build out schema

* Start restructuring resolvers

* Add create mutation

* Return boolean true for empty create mutation selections

* Add update mutation

* Add delete mutation

* Add system/items scoping

* Fix merge conflicts for real now

* Use system services, rename ids->keys

* Start on docs on mutations

* Updates to match main

* Add fetch-by-id

* Add one/many resolvers for mutations

* Check system collection rows for singleton

* Fix resolver extraction for single read

* Share delete return type

* Add comments

* Use collection root name for readable type

* Add specs endpoint for GraphQL SDL

* Update docs

* Add note on SDL spec

* Fix delete single example

* Remove package-lock

* Fix collection read scoping in non-read
2021-03-30 17:06:35 -04:00
Rijk van Zanten
971a18c219 Database Error Abstraction (#4465)
* Start on database-error abstraction layer

* Add SQLite error abstraction

* Enable SQLite foreign key support

* Cleanup sqlite dialect slightly

Does it matter? Not really!

* Add MySQL error abstraction

* WIP Almost done with MSSQL

* Add correct error handling for MS SQL

* Fix mysql errors by not relying on value order

* Don't rely on sql in postgres exception translation

* Fix sqlite error parsing

* Remove foreign key constraint from activity to collections

A collection can be DB-only, but we still want to track activity for non-meta collections

* Translate error on update as well
2021-03-10 17:16:15 -05:00
rijkvanzanten
f088074d48 Only return full 500 stack trace to authenticated admin users 2021-02-25 19:12:18 -05:00
Rijk van Zanten
0beaf56dc3 Add on-error hook (#4233)
* Add on-error hook

Closes #2906

* Ignore unspecified listeners

* Document error hook
2021-02-22 19:00:53 -05:00
rijkvanzanten
510cbe4ed4 Fix missing type info 2021-02-11 18:14:55 -05:00
Rijk van Zanten
b7d87e581a System permissions for app access (#4004)
* Pass relations through schema, instead of individual reads

* Fetch field transforms upfront

* Fix length check

* List if user has app access or not in accountability

* Load permissions up front, merge app access minimal permissions

* Show app access required permissions in permissions overview

* Show system minimal permissions in permissions detail

* Fix app access check in authenticate for jwt use

* Fix minimal permissions for presets

* Remove /permissions/me in favor of root use w/ permissions

* Fix logical nested OR in an AND

* Use root permissions endpoint with filter instead of /me

* Allow filter query on /permissions

* Add system minimal app access permissions into result of /permissions

* Remove stray console log

* Remove stray console.dir

* Set current role as role for minimal permissions

* Fix no-permissions state for user detail

* Add filter items function that allows altering existing result set
2021-02-11 12:50:56 -05:00
rijkvanzanten
55951a6f68 Don't crash on empty CSV export
Fixes #3820
2021-01-27 15:36:30 -05:00
rijkvanzanten
d98300d528 Fix graphql response type 2021-01-14 12:52:57 -05:00
rijkvanzanten
178e91106b Remove unused imports 2021-01-12 16:15:44 -05:00
rijkvanzanten
6b029b416b iRemove imported types that aren't needed 2021-01-12 16:11:08 -05:00
Rijk van Zanten
a41559b32f Merge branch 'main' into fix/async-handlers 2021-01-12 12:27:27 -07:00
rijkvanzanten
c54f9f70d6 Don't send cache header when no-cache has been requested 2020-12-31 15:17:43 -05:00
rijkvanzanten
2b64449f6c Check for capitalized cache control header 2020-12-22 17:53:33 -05:00
WoLfulus
c5f3802da3 Replace express-async-handler for a local function. 2020-12-22 17:11:08 -03:00
rijkvanzanten
9974cb6050 Add health endpoint 2020-12-21 15:22:39 -05:00
rijkvanzanten
d08c91389a Remove quotes from max-age in cache-control 2020-12-17 18:57:33 -05:00
rijkvanzanten
766911cba0 Allow for no-cache Cache-Control request header 2020-12-16 18:09:41 -05:00
rijkvanzanten
578b761ded Add auto-purge option
And add cache-control header when auto purge is disabled

Fixes #3425
2020-12-16 14:26:38 -05:00
Igor Savin
7cddb458cb Run prettier across app and api 2020-12-08 02:22:00 +02:00
rijkvanzanten
5bedda945c Warn, don't error, on missing PKs in schema
Fixes #3251
2020-12-07 18:24:33 -05:00
rijkvanzanten
33c3f69d9e Fix naming in schema middleware 2020-11-10 09:29:41 -05:00
rijkvanzanten
4d09f4a07e Add oracle/mssql 2020-11-09 18:50:08 -05:00
rijkvanzanten
64d34933d1 Add overview method for SQLite3 2020-11-09 18:37:00 -05:00
rijkvanzanten
8cbdfb409b Use prefetched schema info 2020-11-09 17:13:48 -05:00