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

WIP: Admin setting iframe #4373

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

codewithvk
Copy link

  • Resolves: #
  • Target version: main

Summary

TODO

  • ...

Checklist

  • Code is properly formatted
  • Sign-off message is added to all commits
  • Documentation (manuals or wiki) has been updated or is not required

Signed-off-by: codewithvk <vivek.javiya@collabora.com>
Signed-off-by: codewithvk <vivek.javiya@collabora.com>
Signed-off-by: codewithvk <vivek.javiya@collabora.com>
Signed-off-by: codewithvk <vivek.javiya@collabora.com>
@codewithvk codewithvk force-pushed the private/codewithvk/cool_setting_iframe branch from 62c98ce to 104c780 Compare January 7, 2025 17:02
@codewithvk codewithvk marked this pull request as draft January 7, 2025 17:04
Copy link
Member

@juliusknorr juliusknorr left a comment

Choose a reason for hiding this comment

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

Some early feedback, general approach seems good 👍

$wopi = $this->tokenManager->generateWopiToken($fileId, null, $adminUserId);

$coolBaseUrl = $this->appConfig->getCollaboraUrlPublic();
$adminSettingsWopiSrc = $coolBaseUrl . '/browser/admin-settings.html?';
Copy link
Member

Choose a reason for hiding this comment

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

Ideally this would be an URL that can be obtained from the discovery endpoint of Collabora, could be a separate app element for settings

$owneruid = null;
$hideDownload = false;
$rootFolder = $this->rootFolder;

if ($fileId == "-1")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if ($fileId == "-1")
if ($fileId === "-1")

Best always use strict comparison in PHP

@@ -66,6 +66,34 @@ public function generateFileToken($fileId, $owner, $editor, $version, $updatable
return $wopi;
}

public function generateUserSettingsToken($fileId, $owner, $editor, $version, $updatable, $serverHost, ?string $guestDisplayname = null, $hideDownload = false, $direct = false, $templateId = 0, $share = null) {
Copy link
Member

Choose a reason for hiding this comment

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

We probably can simplify the signature of this method a lot. Most of it is passed in as dummy/default values

@@ -384,6 +384,25 @@ public function editOnlineTarget(int $fileId, ?string $target = null): RedirectR
#[PublicPage]
public function token(int $fileId, ?string $shareToken = null, ?string $path = null, ?string $guestName = null): DataResponse {
try {
if ($fileId === -1 && $path !== null && str_starts_with($path, 'admin-settings/')) {
$parts = explode('/', $path);
$adminUserId = $parts[1] ?? $this->userId; // fallback if needed
Copy link
Member

Choose a reason for hiding this comment

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

This seems dangerous, we should always use $this->userId and not let the user id be passed as request data.

Additionally we need to check if the user id is an admin (Can be done through https://github.com/nextcloud/server/blob/dff881544920f426b984f91b7bc8dece1f351342/lib/public/IGroupManager.php#L115

@@ -384,6 +384,25 @@ public function editOnlineTarget(int $fileId, ?string $target = null): RedirectR
#[PublicPage]
public function token(int $fileId, ?string $shareToken = null, ?string $path = null, ?string $guestName = null): DataResponse {
try {
if ($fileId === -1 && $path !== null && str_starts_with($path, 'admin-settings/')) {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we can even extract this part, so we don't need to extend the token endpoint. This logic could be moved to the SettingsController and generate a token directly there.

Copy link
Member

Choose a reason for hiding this comment

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

Would be safer as then we can be sure this can only be called by admins

Signed-off-by: codewithvk <vivek.javiya@collabora.com>
…directories

Signed-off-by: codewithvk <vivek.javiya@collabora.com>
…y of user and system settings.

Note: We will delete this commit/code after the entire prototype is ready. Reviewers can ignore this commit during the review process.
Signed-off-by: codewithvk <vivek.javiya@collabora.com>
TODO: We should try to centralize the path everywhere so that a change in one place updates it everywhere!
Signed-off-by: codewithvk <vivek.javiya@collabora.com>
… it to system-settings dir

Signed-off-by: codewithvk <vivek.javiya@collabora.com>
…equest

Signed-off-by: codewithvk <vivek.javiya@collabora.com>
- Implement dynamic routing for settings files, enabling URLs structured as /settings/{type}/{category}/{filename}.
- Support various setting types (e.g. userconfigs, sharedconfigs) and categories (e.g. autotext, wordbook) so that multiple files can be stored for each category.
- Ensure proper URL parsing and directory handling for uploading and retrieving files via the WOPI interface.

Signed-off-by: codewithvk <vivek.javiya@collabora.com>
@codewithvk codewithvk force-pushed the private/codewithvk/cool_setting_iframe branch from 905e1e2 to cc91ef8 Compare January 11, 2025 18:22
Signed-off-by: codewithvk <vivek.javiya@collabora.com>
@codewithvk
Copy link
Author

Related serverside PR : nextcloud/server#50145

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.

2 participants