Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BC-5424 - persistent storage for tldraw #4685

Merged
merged 34 commits into from
Jan 30, 2024
Merged

Conversation

davwas
Copy link
Contributor

@davwas davwas commented Jan 9, 2024

Description

Links to Tickets or other pull requests

https://ticketsystem.dbildungscloud.de/browse/BC-5424

hpi-schul-cloud/nuxt-client#3002
hpi-schul-cloud/tldraw-client#47

Changes

Datasecurity

Deployment

New Repos, NPM pakages or vendor scripts

Approval for review

  • DEV: If api was changed - generate-client:server was executed in vue frontend and changes were tested and put in a PR with the same branch name.
  • QA: In addition to review, the code has been manually tested (if manual testing is possible)
  • All points were discussed with the ticket creator, support-team or product owner. The code upholds all quality guidelines from the PR-template.

Notice: Please remove the WIP label if the PR is ready to review, otherwise nobody will review it.

@davwas davwas added the WIP This feature branch is in progress, do not merge into master. label Jan 9, 2024
@davwas davwas removed the WIP This feature branch is in progress, do not merge into master. label Jan 19, 2024
@@ -72,7 +75,7 @@ export class BoardDoAuthorizableService implements AuthorizationLoaderService {
userId: user.id,
firstName: user.firstName,
lastName: user.lastName,
roles: [BoardRoles.READER],
roles: isDrawingElement ? [BoardRoles.EDITOR] : [BoardRoles.READER],
Copy link
Contributor

@CeEv CeEv Jan 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the default value of this boolean?
For me is this change unclear, can we speak about it?
With this line you create a exception for one element that invert the authorisation (logic/role), it look like the first step into the wrong direction.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default should be false and only set the student to editors when accessing a drawing element.

Currently all students are readers. In the submission case we actually overrule the permission in the UC layer.
As this is a temporary solution until we have the proper authZ set in place.

protected async checkSubmissionItemWritePermission(userId: EntityId, submissionItem: SubmissionItem) {

I would be better to set exceptions outside this function like how the submission is handling it to keep the core code clean for now.

Copy link
Contributor Author

@davwas davwas Jan 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default is false.

We want to store uploaded assets from tldraw in s3 storage - by default every authorized user is supposed to be able to upload to tldraw. There is already a logic in place to upload files to column board nodes. If requested board node is an instance of DrawingElement (which is Tldraw) we want to give student role access to upload.

The alternative I can think of is to create new authorizable service only for DrawingElements which would basically be a copy paste of board-do-authorizable.service with just this one line changed. We are open to any other suggestions.

Copy link
Contributor

@EzzatOmar EzzatOmar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will introduce a new BOARD_ROLES to handle the case for TLDraw.

This will be merged next week. Please wait for the new code before continuing here.

@@ -54,7 +55,9 @@ export class ElementUc extends BaseUc {
if (isSubmissionItem(parent)) {
await this.checkSubmissionItemWritePermission(userId, parent);
} else {
await this.checkPermission(userId, element, Action.write);
// TODO: fix this temporary hack to prevent students from deleting the DrawingElement
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add also that the roles are hacked for the drawing element.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -54,7 +55,9 @@ export class ElementUc extends BaseUc {
if (isSubmissionItem(parent)) {
await this.checkSubmissionItemWritePermission(userId, parent);
} else {
await this.checkPermission(userId, element, Action.write);
// TODO: fix this temporary hack to prevent students from deleting the DrawingElement
const requiredRole = isDrawingElement(element) ? UserRoleEnum.TEACHER : undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (isSubmissionItem(parent))
if else (isDrawingElement(element))
const requiredRole
await this.checkPermission
else
await this.checkPermission

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@CeEv
Copy link
Contributor

CeEv commented Jan 29, 2024

Please solve the merge conflicts.

# Conflicts:
#	apps/server/src/modules/tldraw/config.ts
#	apps/server/src/modules/tldraw/controller/tldraw.ws.ts
#	apps/server/src/modules/tldraw/repo/tldraw-board.repo.ts
#	apps/server/src/modules/tldraw/tldraw.module.ts
#	config/default.schema.json
#	config/test.json
#	package-lock.json
#	package.json
#	src/services/config/publicAppConfigService.js
Copy link
Contributor

@CeEv CeEv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CeEv CeEv dismissed EzzatOmar’s stale review January 29, 2024 12:52

The open work, should be done later. Let speak @EzzatOmar how we proceed.

Copy link

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

2 New issues
0 Security Hotspots
100.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

@davwas davwas merged commit 46c0648 into main Jan 30, 2024
47 checks passed
@davwas davwas deleted the BC-5424-tldraw-persistent-storage branch January 30, 2024 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants