Commit Graph

20 Commits

Author SHA1 Message Date
Kristaps Fabians Geikins bd9faa2415 fix(server): more legible auth errors (#2361) 2024-06-13 10:34:01 +03:00
Gergő Jedlicska 105f1c0b54 refactor(server authz): rework validateServerRole 2023-08-01 14:58:55 +02:00
Gergő Jedlicska 23989174d3 refactor(server scopes): use constants for streams contributor role 2023-07-26 14:12:41 +02:00
Gergő Jedlicska a2bb36e43e refactor(server scopes): use constants for streams owner role 2023-07-26 14:08:47 +02:00
Gergő Jedlicska bb5778bf2d refactor(server scopes): use constants for streams read scopes 2023-07-26 13:09:34 +02:00
Gergő Jedlicska 6ea7aa8236 refactor roles to shared constants 2023-07-26 11:59:54 +02:00
Gergő Jedlicska 7d8ff2048a fix(test): make sure users are created sequentially (#1437) 2023-03-06 14:40:35 +01:00
Gergő Jedlicska f2803432b4 gergo/fix flaky admin override tests (#1420)
* fix(server authz tests): force wait until env vars are reloaded in authz tests

* test(server): fix flaky admin override tests with mocking
2023-02-27 13:59:16 +01:00
Gergő Jedlicska c80c2a2602 fix(server authz tests): force wait until env vars are reloaded in authz tests (#1403) 2023-02-22 14:05:56 +01:00
Gergő Jedlicska 40a6701799 feat(server): add switchable admin authz override (#1378)
* feat(server): add switchable admin authz override

* fix(server): make sure tests work with the new admin override

* feat(server authz): make sure to add all requested roles to server admins in admin override mode
2023-02-17 16:31:06 +01:00
Iain Sproat a537d34dcc Rate limit all endpoints (#1213)
* Demonstration of bug to test when middleware added
- Adding middleware, even no-op, causes test to fail

* Make middleware async, but introduce delay.
Revert test back to original.

* Revert tests

* Add a 1ms sleep to the test to reduce likelihood of flakiness

* Rate limiting on all express endpoints using middleware

* Adds all configuration for existing rate limited endpoints

* It is helpful to add the package to yarn first

* Implements respectsLimits using Redis rate limiter

* Fix for test `Should rate-limit user creation`
- if rate limit error, post to `/auth/local/register` will return a 429 status code

* All rate limiting provided by new ratelimiter.ts

* Consolidate typescript interfaces

* Amend signature of function to require source to be passed in, and not try to guess it from the request

* Rename respectsLimits to isWithinRateLimits

* Throw within catch of Promise

* Replace rejectsRequestWithRatelimitStatusIfNeeded throughout code

* Sending rate limit response should deal with other types of error
- Sentry notified of the error

* Express middleware rate limits by a 3 second burst or a daily rate
- Provide action when generating 429 response

* Prevent DOS of Redis

* Add 'Retry-After' for all cases when responding with 429 status code
- default of 1 day, but dynamic based on available information

* Generate rate limiters once, on init
- Improved and consistent handling of exit from functions
- fixed environment variable names

* WIP Refactor rate limiting setup

Co-authored-by: Iain Sproat <iainsproat@users.noreply.github.com>

* WIP: fixed references, now runs but tests fail

* Use getSourceFromRequest where possible

* WIP: unit tests for rate limiter

* Unit tests for ratelimiter

* feat(IFC): WIP IFC parser improvements

* Revert "feat(IFC): WIP IFC parser improvements"

This reverts commit 093089a2c4.

* refactor authz, rate limiting middleware to global

Co-authored-by: Kristaps Fabians Geikins <fabis94@users.noreply.github.com>
Co-authored-by: Iain Sproat <iainsproat@users.noreply.github.com>

* invites tests fix

* fix(server ratelimiter): export public interfaces

* Unit test for rate limiter use in memory rate limiter
- in memory rate limiter is configured with zero limit by default

* Fixed #1219 (#1221)

* WIP: improve auth test for rate limiting user creation

* ci(circleci config): publishing was broken when main branch was tagged (i.e. for releases) (#1224)

* Gitignore CPU profiles

* All tests are  now passing locally

* Fixed an issue in the frontend which was causing the views not to work. Fixed an issue with object selection camera animation where the dolly lerp factor was much too high for smooth animation (#1225)

* feat(structured logging): implements structured logging for backend (#1217)

* each log line is a json object
* structured logging allows logs to be ingested by machines and the logs to be indexed and queried addresses #1105
* structured logging allows arbitrary properties to be appended to each log line, and ingestion of logs to remain robust
* Structured logging provided by `pino` library
* Add `express-pino-logger` dependency
* Remove `debug`, `morgan`, and `morgan-debug` and replace with structured logging
* `console.log` & `console.error` replaced with structured logging in backend
* Remove `DEBUG` environment variable and replace with `LOG_LEVEL`
- Note that there is a test which reads from a logged line on `stdout`. This is not robust, it would be better to use the childProcess.pid to look up the port number.
* Log errors at points we explicitly send error to Sentry
* Amend indentation of a couple of log messages to align indentation with others

* Revert "feat(structured logging): implements structured logging for backend (#1217)" (#1227)

This reverts commit 84cb74e8b3.

* Move error to core/errors
- augmented typescript types moved to type-augmentations

* Added a missing wait in the screenshot generation loop (#1228)

* refactor(server rest api): remove duplicate rate limit requests

* feat(server rate limits): increase rate limits for the upload endpoints

* chore(server rate limits): final cleanup

Co-authored-by: Gergő Jedlicska <gergo@jedlicska.com>
Co-authored-by: Iain Sproat <iainsproat@users.noreply.github.com>
Co-authored-by: Dimitrie Stefanescu <didimitrie@gmail.com>
Co-authored-by: Kristaps Fabians Geikins <fabis94@users.noreply.github.com>
Co-authored-by: Kristaps Fabians Geikins <fabis94@live.com>
Co-authored-by: Alexandru Popovici <alexandrupopoviciioan@gmail.com>
2022-11-29 17:06:11 +01:00
Gergő Jedlicska 0ac118e05c (refactor) server for less app-root-path 2022-05-03 13:10:00 +02:00
Fabians 1c7436e7ff extra prefer-const & object-shorthand 2022-04-04 19:00:24 +03:00
Gergő Jedlicska 7906307a8f fix(server tests): fixed all non awaited rejected promisses 2022-03-31 15:21:13 +02:00
Gergő Jedlicska d53df11f77 style(server): fix all eslint errors and break the tests 2022-03-31 14:18:44 +02:00
Gergő Jedlicska 569b4688fa style(all): reformat with print width 88 2022-03-29 19:46:49 +02:00
Kristaps Fabians Geikins aeeb88340d feat: favoriting streams #620 (#633) 2022-03-29 16:30:49 +03:00
Gergő Jedlicska 68a4a95d90 refactor(server): rework test hooks
drop db migration before and after hooks, add helpers and root hooks

fix #531
2022-02-05 15:05:17 +01:00
Gergő Jedlicska 8050c30d6d test((server) archival tests): add archived user scope tests
also i'm trying to fix flaky tests
2021-11-04 13:33:22 +01:00
Dimitrie Stefanescu cd95c28939 refactor(global): restructures repo with lerna 2021-01-03 13:35:53 +02:00