-
Notifications
You must be signed in to change notification settings - Fork 17
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-7737 - Bump h5p server #5140
Merged
Merged
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
abd4cf1
Bump h5p server
bischofmax b118570
Add permission system
bischofmax 2a9bb52
Merge branch 'main' into BC-7737-bump-h5p-server
bischofmax 4d994f0
Add editor permission system and add specific permissions
bischofmax 9f6b626
Merge branch 'main' into BC-7737-bump-h5p-server
bischofmax bf20760
Merge branch 'main' into BC-7737-bump-h5p-server
CeEv f5f04e5
Merge branch 'main' into BC-7737-bump-h5p-server
bischofmax de2cca7
Add tests
bischofmax a4c3400
Merge branch 'BC-7737-bump-h5p-server' of github.com:hpi-schul-cloud/…
bischofmax 94fec06
Fix tests
bischofmax 806d4ce
Fix test descriptions
bischofmax 102fb45
Add test to meet coverage
bischofmax File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
apps/server/src/modules/h5p-editor/provider/editor-permission-system.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
import { | ||
ContentPermission, | ||
GeneralPermission, | ||
IPermissionSystem, | ||
IUser, | ||
TemporaryFilePermission, | ||
UserDataPermission, | ||
} from '@lumieducation/h5p-server'; | ||
|
||
export default class EditorPermissionSystem implements IPermissionSystem<IUser> { | ||
checkForUserData( | ||
actingUser: IUser, | ||
permission: UserDataPermission, | ||
contentId: string, | ||
affectedUserId?: string | ||
): Promise<boolean> { | ||
return Promise.resolve(false); | ||
} | ||
|
||
async checkForContent( | ||
actingUser: IUser | undefined, | ||
permission: ContentPermission, | ||
contentId?: string | ||
): Promise<boolean> { | ||
return Promise.resolve(true); | ||
} | ||
|
||
async checkForTemporaryFile( | ||
user: IUser | undefined, | ||
permission: TemporaryFilePermission, | ||
filename?: string | ||
): Promise<boolean> { | ||
return Promise.resolve(true); | ||
} | ||
|
||
async checkForGeneralAction(actingUser: IUser | undefined, permission: GeneralPermission): Promise<boolean> { | ||
return Promise.resolve(false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,22 @@ | ||
import { | ||
H5PConfig, | ||
cacheImplementations, | ||
LibraryManager, | ||
ContentTypeCache, | ||
H5PConfig, | ||
ILibraryAdministrationOverviewItem, | ||
IUser, | ||
LibraryAdministration, | ||
ILibraryAdministrationOverviewItem, | ||
LibraryManager, | ||
} from '@lumieducation/h5p-server'; | ||
import ContentManager from '@lumieducation/h5p-server/build/src/ContentManager'; | ||
import ContentTypeInformationRepository from '@lumieducation/h5p-server/build/src/ContentTypeInformationRepository'; | ||
import { IHubContentType } from '@lumieducation/h5p-server/build/src/types'; | ||
import { Injectable, InternalServerErrorException, NotFoundException } from '@nestjs/common'; | ||
import { ConfigService } from '@nestjs/config'; | ||
import { ContentStorage, LibraryStorage } from '@src/modules/h5p-editor'; | ||
import { readFileSync } from 'fs'; | ||
import { parse } from 'yaml'; | ||
import { ConfigService } from '@nestjs/config'; | ||
import { IHubContentType } from '@lumieducation/h5p-server/build/src/types'; | ||
import { IH5PLibraryManagementConfig } from './h5p-library-management.config'; | ||
import LibraryManagementPermissionSystem from './library-management-permission-system'; | ||
|
||
const h5pConfig = new H5PConfig(undefined, { | ||
baseUrl: '/api/v3/h5p-editor', | ||
|
@@ -75,8 +76,14 @@ export class H5PLibraryManagementService { | |
undefined, | ||
h5pConfig | ||
); | ||
this.contentTypeRepo = new ContentTypeInformationRepository(this.contentTypeCache, this.libraryManager, h5pConfig); | ||
const contentManager = new ContentManager(this.contentStorage); | ||
const permissionSystem = new LibraryManagementPermissionSystem(); | ||
this.contentTypeRepo = new ContentTypeInformationRepository( | ||
this.contentTypeCache, | ||
this.libraryManager, | ||
h5pConfig, | ||
permissionSystem | ||
); | ||
const contentManager = new ContentManager(this.contentStorage, permissionSystem); | ||
this.libraryAdministration = new LibraryAdministration(this.libraryManager, contentManager); | ||
const filePath = this.configService.get<string>('H5P_EDITOR__LIBRARY_LIST_PATH'); | ||
|
||
|
@@ -115,9 +122,6 @@ export class H5PLibraryManagementService { | |
|
||
private createDefaultIUser(): IUser { | ||
const user: IUser = { | ||
canCreateRestricted: true, | ||
canInstallRecommended: true, | ||
canUpdateAndInstallLibraries: true, | ||
email: '[email protected]', | ||
id: 'a', | ||
name: 'a', | ||
|
49 changes: 49 additions & 0 deletions
49
...server/src/modules/h5p-library-management/service/library-management-permission-system.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
import { | ||
ContentPermission, | ||
GeneralPermission, | ||
IPermissionSystem, | ||
IUser, | ||
TemporaryFilePermission, | ||
UserDataPermission, | ||
} from '@lumieducation/h5p-server'; | ||
|
||
export default class LibraryManagementPermissionSystem implements IPermissionSystem<IUser> { | ||
checkForUserData( | ||
actingUser: IUser, | ||
permission: UserDataPermission, | ||
contentId: string, | ||
affectedUserId?: string | ||
): Promise<boolean> { | ||
return Promise.resolve(false); | ||
} | ||
|
||
async checkForContent( | ||
actingUser: IUser | undefined, | ||
permission: ContentPermission, | ||
contentId?: string | ||
): Promise<boolean> { | ||
return Promise.resolve(false); | ||
} | ||
|
||
async checkForTemporaryFile( | ||
user: IUser | undefined, | ||
permission: TemporaryFilePermission, | ||
filename?: string | ||
): Promise<boolean> { | ||
return Promise.resolve(false); | ||
} | ||
|
||
async checkForGeneralAction(actingUser: IUser | undefined, permission: GeneralPermission): Promise<boolean> { | ||
switch (permission) { | ||
case GeneralPermission.InstallRecommended: | ||
return Promise.resolve(true); | ||
case GeneralPermission.UpdateAndInstallLibraries: | ||
return Promise.resolve(true); | ||
case GeneralPermission.CreateRestricted: | ||
return Promise.resolve(true); | ||
default: | ||
return false; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spannend das hier dann kein Promise.resolve gefordert ist von ts. Könntest du noch mal kurz schauen ob mit den ts update die oberen Promise.resolve raus könnten?