Skip to content

Allow custom public share tokens for form links#3311

Open
alexander-rebello wants to merge 13 commits intonextcloud:mainfrom
alexander-rebello:main
Open

Allow custom public share tokens for form links#3311
alexander-rebello wants to merge 13 commits intonextcloud:mainfrom
alexander-rebello:main

Conversation

@alexander-rebello
Copy link
Copy Markdown

This adds admin-gated custom tokens for public Forms share links. By default the feature is disabled, so existing instances keep the current random-token behavior. When enabled by an admin, form owners can edit the token of an existing public link directly in the sharing sidebar, save it explicitly, and the old URL becomes invalid immediately.

It also adds the necessary backend support for token updates, keeps public-link routing compatible with custom tokens, and includes tests plus API documentation updates.

Signed-off-by: Alexander Rebello <me@alexander-rebello.de>
Signed-off-by: Alexander Rebello <me@alexander-rebello.de>
Signed-off-by: Alexander Rebello <me@alexander-rebello.de>
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Signed-off-by: Alexander Rebello <me@alexander-rebello.de>
Signed-off-by: Alexander Rebello <me@alexander-rebello.de>
Signed-off-by: Alexander Rebello <me@alexander-rebello.de>
Chartman123
Chartman123 previously approved these changes Apr 24, 2026
Copy link
Copy Markdown
Collaborator

@Chartman123 Chartman123 left a comment

Choose a reason for hiding this comment

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

Added some review comments on the PHP part

Comment thread docs/API_v3.md Outdated
Comment thread lib/Controller/PageController.php Outdated
Comment thread lib/Controller/PageController.php Outdated
#[NoCSRFRequired()]
#[PublicPage()]
#[FrontpageRoute(verb: 'GET', url: '/s/{hash}', requirements: ['hash' => '[a-zA-Z0-9]{24,}'])]
#[FrontpageRoute(verb: 'GET', url: '/s/{hash}', requirements: ['hash' => self::PUBLIC_SHARE_HASH_REQUIREMENT])]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Would probably be good if we can decide here wether custom share tokens are allowed on that instance. But IIRC it's not working with dynamically defined requirements.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Meaning it would be good, but can't be done in this instance? Or should I try?

Comment thread lib/Controller/ShareApiController.php Outdated
Signed-off-by: Alexander Rebello <me@alexander-rebello.de>
Signed-off-by: Alexander Rebello <me@alexander-rebello.de>
@alexander-rebello alexander-rebello marked this pull request as draft April 24, 2026 08:53
@alexander-rebello alexander-rebello marked this pull request as ready for review April 24, 2026 08:57
@Chartman123 Chartman123 added enhancement New feature or request 3. to review Waiting for reviews feature: 👥 sharing settings labels Apr 24, 2026
@Chartman123 Chartman123 added this to the 5.3 milestone Apr 24, 2026
@Chartman123 Chartman123 dismissed their stale review April 24, 2026 09:58

Accidentally approved the PR instead of just adding the review comments

Signed-off-by: Alexander Rebello <me@alexander-rebello.de>
@alexander-rebello
Copy link
Copy Markdown
Author

Whats the holdup? Could we check if this version works?

Comment thread .github/workflows/lint-eslint.yml
Comment thread lib/Controller/ShareApiController.php Outdated
alexander-rebello and others added 4 commits April 28, 2026 15:35
Co-authored-by: Christian Hartmann <chris-hartmann@gmx.de>
Signed-off-by: Alexander Rebello <me@alexander-rebello.de>
Signed-off-by: Alexander Rebello <me@alexander-rebello.de>
@Chartman123
Copy link
Copy Markdown
Collaborator

Please don't merge the main branch into your dev branch, always rebase your branch on current main. :)

@Chartman123
Copy link
Copy Markdown
Collaborator

Oh and I just saw it: please use some other branch name for your changes in your forked repository...

Comment thread src/FormsSettings.vue
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please rebase your branch on our current main and adjust this file accordingly to the changes merged into main lately. We had a bug in this file that prevented sending the requests to the server.

@Chartman123
Copy link
Copy Markdown
Collaborator

Chartman123 commented Apr 30, 2026

@alexander-rebello could you please rework the front-end so that it looks/works more like for the file sharing?

grafik

The field should also auto-save upon changes and don't have to rely on clicking a save button in the menu. The button on the right to go back to some auto-generated token is also nice and should be implemented here, too. And I think that we should also hide the token input behind some "customize share token" (instead of the "advanced settings") section.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants