Commit graph

560 commits

Author SHA1 Message Date
David Mehren
c5c7307552
docs(permissions): document why we can't lazy-load
Signed-off-by: David Mehren <git@herrmehren.de>
2021-12-13 21:45:03 +01:00
David Mehren
f164e84081
refactor(tag): lazy-load relations
Signed-off-by: David Mehren <git@herrmehren.de>
2021-12-13 21:45:03 +01:00
David Mehren
3c0c11e3d4
refactor(note): lazy-load relations
Signed-off-by: David Mehren <git@herrmehren.de>
2021-12-13 21:45:03 +01:00
David Mehren
9e608c75d3
refactor(alias): lazy-load relations
Signed-off-by: David Mehren <git@herrmehren.de>
2021-12-13 21:45:03 +01:00
David Mehren
facdc456cd
refactor(media-upload): lazy-load relations
Signed-off-by: David Mehren <git@herrmehren.de>
2021-12-13 21:45:03 +01:00
David Mehren
8aae5cb574
docs(history-entry): document why we can't lazy-load
Signed-off-by: David Mehren <git@herrmehren.de>
2021-12-05 19:42:49 +01:00
David Mehren
8eabfbc0a5
refactor(group): lazy-load relations
Signed-off-by: David Mehren <git@herrmehren.de>
2021-12-05 19:42:47 +01:00
David Mehren
244e3f76ea
refactor(author): lazy-load relations
Signed-off-by: David Mehren <git@herrmehren.de>
2021-12-05 19:40:25 +01:00
David Mehren
552d06f182
refactor(auth-token): lazy-load relations
Signed-off-by: David Mehren <git@herrmehren.de>
2021-12-05 19:40:25 +01:00
Philip Molares
6fddeebc56 feat: replace GetNotePipe with GetNoteInterceptor and RequestNote
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-12-02 21:57:51 +01:00
Philip Molares
9e2a138a14 feat: add request note decorator
This extracts the note inserted with the get note interceptor into the request to be used by the controller service.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-12-02 20:41:45 +01:00
Philip Molares
ea0588f02e feat: refactor get note pipe to interceptor
This is necessary, because of the order of operations in nestjs, the validation pipe is not able to get the note as the noteIdOrAlias will be transformed by the get note pipe after the validation did run.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-12-02 20:41:45 +01:00
Philip Molares
d27c531d9a refactor: move permissions service calls into permissions guard
This commit removes all previous calls to the permissions service at the beginning of the controller methods to the permissions guard. This should make the code a bit cleaner and remove boilerplate code.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-12-02 20:41:14 +01:00
Philip Molares
f6ae0d30a1 feat: create permissions guard
This guard protects resources and let's users only access them if they hold the correct permission

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-12-02 20:41:12 +01:00
Philip Molares
6f7cfced39 feat: create permission decorator
This gathers the permission a user needs to hold to access a resource for the PermissionsGuard.

See https://docs.nestjs.com/guards#setting-roles-per-handler

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-11-30 19:48:47 +01:00
Philip Molares
c30a06d90b feat: create permission enum
This enum makes it possible which permissions a user needs to hold to access a specific resource

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-11-30 19:48:47 +01:00
Philip Molares
dbf467fea5 chore: extract getNote code from GetNotePipe.transform
This was done so the same code could be used in the PermissionsGuard

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-11-30 19:48:47 +01:00
Philip Molares
4b3c726101 chore: move get-note-pipe to api utils
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-11-30 19:48:47 +01:00
Yannick Bungers
15e2e177fb Add missing null in type in permissions service
The parameters of the permission checking methods were missing a null value for not set user. This is the case if user is not logged in and operating as guest.

Signed-off-by: Yannick Bungers <git@innay.de>
2021-11-29 22:42:31 +01:00
David Mehren
bcd38e14c0
Merge pull request #1680 from hedgedoc/fix/createMethods 2021-11-16 19:07:00 +01:00
David Mehren
3a47e962ea
test(mockconfig): generate unique upload paths
This stops multiple concurrently running tests disturbing each other.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-11-16 18:26:34 +01:00
David Mehren
db1d44cb69
fix(seed): fix create method usage
Signed-off-by: David Mehren <git@herrmehren.de>
2021-11-14 21:49:31 +01:00
David Mehren
9c08ff94fe
fix(note): fix type for owner param
To make the create method easier to use in conjunction
with the authentication framework, this commit changes the type of
the `owner` parameter from `User | undefined` to `User | null`.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-11-14 21:46:04 +01:00
David Mehren
01b53d3858
fix(alias): remove default for primary
To make the create method more consistent with the
guidelines,
this commit removes the default value from the `primary` parameter.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-11-14 21:46:04 +01:00
David Mehren
9258863dbd
fix(media-upload): remove backendData parameter
`Create` methods should only contain optional properties

Signed-off-by: David Mehren <git@herrmehren.de>
2021-11-14 21:46:04 +01:00
David Mehren
a08d8c58ed
fix(identity): remove default for syncSource
To make the create method more consistent with the
guidelines,
this commit removes the default value from the `syncSource` parameter.

An Identity will be created as sync source,
when the associated account is created using an external provider.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-11-14 21:46:04 +01:00
David Mehren
5ba6b4ab67
fix(group): add special flag to create method
To make the create method more consistent with the
guidelines, this commit adds the `special` flag to
the parameters.
As this function will only be used to create the two hard-coded groups
and to handle API requests at one or two places, adding the parameter
should not be too problematic.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-11-14 21:46:04 +01:00
Philip Molares
09f0d7c389 fix(media-upload): rework create and media services saveFile
This was done to make the create method more concise.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-11-11 22:07:20 +01:00
Philip Molares
58d8ff71fe fix: the tests use the new typing from create methods
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-11-11 22:07:20 +01:00
Philip Molares
d18d23cb16 fix: services use the new typings from create methods
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-11-11 22:07:20 +01:00
Philip Molares
b896f954b9 feat: consolidate entities create
This was done to give better typings to the function signatures of entities `create` methods.
It also ensures that each field that should be set to `null` is set to `null` and doesn't leave that up to the typeorm handlers.

See: #1641
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-11-11 22:07:20 +01:00
Philip Molares
3291b43423 docs: fix createUser and test docs
this ports the fixes applied to createGroup to this method as well

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-11-06 11:51:13 +01:00
Philip Molares
5d6863d03c feat: setupSpecialGroups in bootstrap
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-11-06 11:51:13 +01:00
Philip Molares
b5ab3d830c fix: permissions service use new SpecialGroup enum
instead of random strings the permissions service now uses the SpecialGroup enum

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-11-06 11:51:13 +01:00
Philip Molares
371c7dfe11 feat: add createGroup function
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-11-06 11:51:13 +01:00
Philip Molares
4a717551b9 feat: add SpecialGroup enum
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-10-30 23:58:17 +02:00
David Mehren
5a16047f50
AuthController: Return 409 Conflict when user already exists
The previously used HTTP error 400 'Bad Request' is not really
applicable here, as the client did not send a malformed message.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-10-28 10:18:05 +02:00
David Mehren
1710b7c00a
Merge pull request #1751 from hedgedoc/fix/privateMediaAPIDoc 2021-10-21 19:40:47 +02:00
Yannick Bungers
a2ebd16260 Remove unnecessary exception handling in private notes.controller.ts
and change noteIdOrAlias to Note as parameter

Signed-off-by: Yannick Bungers <git@innay.de>
2021-10-18 22:35:47 +02:00
Yannick Bungers
04dca6aa68 Add API doc for private media API
Signed-off-by: Yannick Bungers <git@innay.de>
2021-10-18 20:20:14 +02:00
Alexandru Văleanu
b3d3015ce7
Add delete media in private API (#1736)
Adds the missing API route of deleting media in the private API.
2021-10-18 20:00:28 +02:00
Yannick Bungers
9d4fc6d7c6
Merge pull request #1735 from hedgedoc/fix-username 2021-10-15 21:37:10 +02:00
Yannick Bungers
325e1893f8 Change createTokenForUser signature
user is now used instead of username

Signed-off-by: Yannick Bungers <git@innay.de>
2021-10-13 22:59:51 +02:00
Yannick Bungers
d33cfa4541 fix username spelling from userName
Signed-off-by: Yannick Bungers <git@innay.de>
2021-10-13 22:54:00 +02:00
Yannick Bungers
aa8455a079 change getTokensByUsername to getTokensByUser
Signed-off-by: Yannick Bungers <git@innay.de>
2021-10-13 22:22:08 +02:00
David Mehren
a4749d60f7
Add dev-proxy to frontend dev server
This adds a reverse proxy to the backend, that automatically
redirects requests that are not handled by the backend to the React
dev server running on port 3001.

The reverse proxy is only enabled when NODE_ENV is set to
'development'.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-10-13 21:36:38 +02:00
Yannick Bungers
e5750b0084
Merge pull request #1673 from hedgedoc/remove-hardcoded 2021-10-13 21:14:33 +02:00
Yannick Bungers
28266bca0b Get user from Session instead of hardcoded value
Signed-off-by: Yannick Bungers <git@innay.de>
2021-10-13 20:52:39 +02:00
David Mehren
9d785100e8
Merge pull request #1671 from hedgedoc/enhancement/validation_logs 2021-10-07 20:38:38 +02:00
David Mehren
9bf75614e2
Log errors in ValidationPipe
Previously, when an error was encountered while validating
the request, only an HTTP 400 status code was returned to the client.
This adds logging of the error message,
so invalid requests can be debugged.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-09-23 22:10:19 +02:00