79 Commits

Author SHA1 Message Date
Philip Molares ff062d7500 test(backend/e2e): fix /private/explore/pin/:noteAlias forbidden alias test
The test checked the wrong error code, that was thrown because we don't provide the correct request body. The test never failed because of the forbidden alias

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2026-05-13 23:59:37 +02:00
Erik Michelson ea9e0bdbd1 fix(backend): type and linting fixes found by oxlint type-aware check
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
2026-05-09 13:05:59 +02:00
Erik Michelson 475231b39a feat(oidc): add backchannel logout
Docker / build-and-push (backend) (push) Has been cancelled
Docker / build-and-push (frontend) (push) Has been cancelled
Deploy HD2 docs to Netlify / Deploys to netlify (push) Has been cancelled
E2E Tests / backend-sqlite (push) Has been cancelled
E2E Tests / backend-mariadb (push) Has been cancelled
E2E Tests / backend-postgres (push) Has been cancelled
Lint and check format / Lint files and check formatting (push) Has been cancelled
REUSE Compliance Check / reuse (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
Static Analysis / Njsscan code scanning (push) Has been cancelled
Static Analysis / CodeQL analysis (javascript) (push) Has been cancelled
Run tests & build / Test and build with NodeJS 24 (push) Has been cancelled
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
2026-05-02 11:35:33 +02:00
Erik Michelson 95f28442c3 chore(tests): performance improvements for backend tests
Docker / build-and-push (backend) (push) Has been cancelled
Docker / build-and-push (frontend) (push) Has been cancelled
E2E Tests / backend-sqlite (push) Has been cancelled
E2E Tests / backend-mariadb (push) Has been cancelled
E2E Tests / backend-postgres (push) Has been cancelled
Lint and check format / Lint files and check formatting (push) Has been cancelled
REUSE Compliance Check / reuse (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
Static Analysis / Njsscan code scanning (push) Has been cancelled
Static Analysis / CodeQL analysis (javascript) (push) Has been cancelled
Run tests & build / Test and build with NodeJS 24 (push) Has been cancelled
The backend end-to-end tests run with many parallel workers that
each start a full NestJS application including database connection
pools, HTTP server and so on. This can easily result in performance
bottlenecks - which is even the reason why we added the --runInBand
option for the CI. The performance can be improved by constraining
the number of workers and memory allocated per worker in our jest
config. Furthermore, we can forcefully close open HTTP connections
in the test cleanup. This terminates connections with a keepalive
flag, that would persist for a while longer otherwise. The following
`this.app.close()` waits for keepalive requests, so this reduces the
wait time.

Signed-off-by: Erik Michelson <github@erik.michelson.eu>
2026-04-15 19:34:53 +02:00
Philip Molares 57234ee810 feat(backend): set charset to utf8mb4 for mariadb
Docker / build-and-push (backend) (push) Has been cancelled
Docker / build-and-push (frontend) (push) Has been cancelled
E2E Tests / backend-sqlite (push) Has been cancelled
E2E Tests / backend-mariadb (push) Has been cancelled
E2E Tests / backend-postgres (push) Has been cancelled
Lint and check format / Lint files and check formatting (push) Has been cancelled
REUSE Compliance Check / reuse (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
Static Analysis / Njsscan code scanning (push) Has been cancelled
Static Analysis / CodeQL analysis (javascript) (push) Has been cancelled
Run tests & build / Test and build with NodeJS 24 (push) Has been cancelled
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2026-03-29 12:27:03 +02:00
Erik Michelson 284d562913 fix(tests): remove Content-Type override for e2e test
This causes errors for two reasons:
1. A DELETE request should not have a body and therefore
   should not have a content-type set.
2. The explicit .set(...) call overrides the set which is
   done in agent setup for extending the agent with CSRF-
   token submission.

Signed-off-by: Erik Michelson <github@erik.michelson.eu>
2026-03-24 12:49:12 +01:00
Philip Molares 5eb15e43d8 feat(username): allow mixed case usernames
Usernames should be saved as is, but in the search we should use like

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2026-03-24 12:49:12 +01:00
Philip Molares 2a2bd92265 feat(alias): allow mixed case aliases
Aliases should be saved as is, but in the search we should use like

Co-authored-by: Erik Michelson <github@erik.michelson.eu>
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2026-03-24 12:49:12 +01:00
Philip Molares 6e4470b626 feat(knex): extend knex with whereEqualLowercase
This allows us to reuse the same logic instead of copying it all over the place

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2026-03-24 12:49:12 +01:00
Erik Michelson a99f99d6ac feat(security): add rate limiting
This adds rate-limiting using the @fastify/rate-limit module with sane
default values, configuration options, the possibility to disable limits
and differentiation between logged-in users and unauthenticated requests.

Signed-off-by: Erik Michelson <github@erik.michelson.eu>
2026-02-04 22:13:07 +01:00
Erik Michelson 66d052d611 feat(security): add CSRF protection to private API endpoints
This adds a new endpoint /api/private/csrf/token which serves a CSRF-token that
is stored in the user's session. Following requests with POST, PUT, PATCH or DELETE
request methods, need to provide this token in the CSRF-Token header. Since this
is not possible to do via HTML forms or other cross-site effects, this prevents
cross-site attacks. The frontend loads the CSRF token on app initialization and
stores it in the redux. It keeps using the token for up to one hour and then
updates the stored token from the API endpoint again.

Signed-off-by: Erik Michelson <github@erik.michelson.eu>
2026-02-04 21:36:52 +01:00
Erik Michelson ac2255579f refactor(backend): switch from express to fastify
Fastify is a more modern web framework than express. Although it
shares almost the same API it has a way better performance and
supports more modern features. Several modules like csurf for
CSRF-protection aren't maintained for express anymore but there
is a Fastify replacement.

Signed-off-by: Erik Michelson <github@erik.michelson.eu>
2026-02-04 21:36:52 +01:00
Erik Michelson 1cf3cb15af chore(docs): update ESDocs to match changes
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
2026-01-22 00:39:20 +01:00
Philip Molares eef4d9ed87 feat(private): add alias/:alias
This route allows us to get all aliases of a note

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2026-01-22 00:39:20 +01:00
Philip Molares dbf102efe7 feat(private): add notes/:noteAlias/metadata/permissions route
This route should be used to get only the permissions of a specific note.
It's useful when we update the permissions and only want to get an update for that.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2026-01-22 00:39:20 +01:00
Erik Michelson 5574d23889 chore(format): reformat using oxfmt
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
2026-01-14 19:46:27 +01:00
Erik Michelson a880864b2c chore(lint): replace ESLint with OXLint for performance
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
2026-01-14 19:46:27 +01:00
Philip Molares 0a34f11e29 test(explore): allow some notes to be publiclyVisible
For our testing it necessary to allow some notes to be publicly visible

Co-authored-by: Erik Michelson <github@erik.michelson.eu>
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2026-01-11 20:21:00 +01:00
Philip Molares a4c590230e feat(permissions): publiclyVisible flag for note listing on explore
This field should allow the user to allow pages to be found
easily on the public explore page without exposing all pages directly.

Co-authored-by: Erik Michelson <github@erik.michelson.eu>
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2026-01-11 20:21:00 +01:00
Erik Michelson cef615433b fix(explore): show tags only once for notes with multiple visits
Co-authored-by: Philip Molares <philip.molares@udo.edu>
Signed-off-by: Philip Molares <philip.molares@udo.edu>
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
2026-01-11 20:21:00 +01:00
Philip Molares adb0d71c2c test: add e2e test for explore api
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2026-01-11 20:21:00 +01:00
Erik Michelson faef272eff fix(e2e-tests): update variables in tests after rebasing e2e tests
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
2025-12-21 10:56:57 +01:00
Philip Molares 398588f519 chore: lint fix
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2025-12-17 22:28:45 +01:00
Philip Molares ec8eb4d43e fix(test-setup): testId can't contain '-'
As uuidv4 contain '-', but databases we want to support don't,
we need to change the testId.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2025-12-17 20:27:48 +01:00
Philip Molares b7f76b73e2 refactor(test-setup): force databases to return datetime as string
As we need to handle datetime in a very specific way,
we need to force strings as the db output.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2025-12-17 20:27:48 +01:00
Philip Molares 224d02fde9 refactor(test-setup): add asAdmin flag to getTestDatabaseConfig
As we want to create a new databases for each test, we need to login
as the root / admin user into the DB in the setup.
This extra flag allows us to create a true admin knex instance in the
createTestDatabase method

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2025-12-17 20:27:48 +01:00
Philip Molares 0cff118d7e refactor(datetime): add utility methods for datetime
As we encountered problems with different databases, it's
easier if we have one implementation that is used around
our codebase.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2025-12-17 20:27:48 +01:00
Philip Molares 2403d96378 ci: activate e2e tests again
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2025-12-17 20:27:48 +01:00
Philip Molares 4b3ef487fa test(e2e): fix private api
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2025-12-17 20:27:48 +01:00
Philip Molares 762da6ac28 test: add setup-agent utility for private api test
This functions logs in three users and creates on client without a user to be used in the private api tests

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2025-12-17 20:27:48 +01:00
Philip Molares e79442bc1b test(e2e): fix public api
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2025-12-17 20:27:48 +01:00
Erik Michelson ef90c7390c fix(backend): use noteAlias instead of noteIdOrAlias terminology
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
2025-11-06 00:55:21 +01:00
Erik Michelson dc83e15e8f chore(deps): replace old mysql package with mysql2
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
2025-11-06 00:55:21 +01:00
Erik Michelson 61fe1367e3 fix(lint): remove unused imports, update import in frontend
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
2025-11-06 00:55:21 +01:00
Erik Michelson a12eb4a98f test(backend): update e2e tests for knex database integration
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
2025-11-06 00:55:21 +01:00
Erik Michelson 9d7bde167c chore(esdoc): update and unify ESDoc and parameter names (1)
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
2025-11-06 00:55:21 +01:00
Erik Michelson c39d2f4988 refactor: replace TypeORM with knex.js
Co-authored-by: Philip Molares <philip.molares@udo.edu>
Signed-off-by: Philip Molares <philip.molares@udo.edu>
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
2025-11-06 00:55:21 +01:00
Erik Michelson b677331171 feat(knex): create database interfaces and knexjs nest integration
Co-authored-by: Philip Molares <philip.molares@udo.edu>
Signed-off-by: Philip Molares <philip.molares@udo.edu>
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
2025-11-06 00:55:21 +01:00
Erik Michelson ff2dce1692 test(backend): remove app.e2e-spec as it is unnecessary
This test is unnecessary since it does not use the shared app-init which
 is used to set up tests and the real main app.

Signed-off-by: Erik Michelson <github@erik.michelson.eu>
2025-04-20 18:09:57 +02:00
Philip Molares b11dbd51c8 refactor(backend): use @hedgedoc/commons DTOs
Co-authored-by: Erik Michelson <github@erik.michelson.eu>
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2025-03-29 22:09:01 +01:00
Erik Michelson b24f8b0a76 refactor(auth): rename identity-module to auth-module
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
2024-12-18 20:02:19 +01:00
Erik Michelson a15ece1e7f chore(deps): upgrade dependencies for backend + lint fixes
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
2024-11-01 17:31:27 +01:00
Erik Michelson 2c6717e1ee refactor(api-token): drop passport, rename to ApiToken
We don't need a library that requires as much boilerplate code as
writing the AuthGuard ourselves, especially since the token validation
was already custom code by us.

The previous name PublicAuthToken was a bit misleading, since PublicAuth
 could also be interpreted as being used for the public frontend in
contrast to the API. The old name before that (AuthToken) wasn't better
since it wasn't clear what type of auth is meant. I know, this is the
second renaming of the same module in less than a month. However, I
would say the name ApiToken seems rather reasonable and understandable.

Signed-off-by: Erik Michelson <github@erik.michelson.eu>
2024-09-18 19:14:32 +02:00
Erik Michelson 157a0fe278 refactor(media): store filenames, use pre-signed s3/azure URLs, UUIDs
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
2024-09-12 14:49:17 +02:00
Erik Michelson 7f665fae4b feat(auth): refactor auth, add oidc
Thanks to all HedgeDoc team members for the time discussing,
helping with weird Nest issues, providing feedback
and suggestions!

Co-authored-by: Philip Molares <philip.molares@udo.edu>
Signed-off-by: Philip Molares <philip.molares@udo.edu>
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
2024-09-11 21:29:49 +02:00
Erik Michelson 73d9c3231b refactor(backend): rename auth to public-auth-token
Signed-off-by: Yannick Bungers <git@innay.de>
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
2024-09-02 10:33:08 +02:00
Erik Michelson 9597ac5422 feat(notes): check for equal alias or note id
When creating a new note or adding a new alias to one,
it is checked that the new name
is neither forbidden nor already in use.

Co-authored-by: David Mehren <git@herrmehren.de>
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
2024-04-18 22:15:11 +02:00
Erik Michelson 8693edbf6a refactor(media): add media redirection endpoint
Previous versions of HedgeDoc suffered from the problem
that changing the media backend required manipulation of
the media links in all created notes. We discussed in
#3704 that it's favourable to have an endpoint that
redirects to the image's original URL. When changing the
media backend, the link stays the same but just the
redirect changes.

Signed-off-by: Erik Michelson <github@erik.michelson.eu>
2024-04-18 22:11:49 +02:00
Erik Michelson 92bde4d281 enhancement(api-tokens): add prefix and more strict validation
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
2024-04-09 10:54:35 +02:00
David Mehren f8f198f9c9 feat: add initial database migration
Signed-off-by: David Mehren <git@herrmehren.de>
2023-10-08 17:58:32 +02:00