Skip to content

fix(settings): reject empty app password names - #65762

Merged
come-nc merged 2 commits into
nextcloud:masterfrom
MarioPym:fix/reject-empty-app-password-name
Nov 12, 2026
Merged

come-nc merged 2 commits into
nextcloud:masterfrom
MarioPym:fix/reject-empty-app-password-name

Conversation

@MarioPym

Copy link
Copy Markdown
Contributor

Summary

An app password can be renamed to an empty or whitespace-only name: the request returns 200 and the token is saved without a visible name in the list. On creation, an empty name is already rejected, but a whitespace-only name is accepted.

update() now returns 400 when the new name is empty after trimming, before anything is changed, so the frontend shows its existing error and restores the previous name. Tokens that already have an empty name can still change their filesystem scope, since the check only applies when the name changes. create() now also treats a whitespace-only name as empty and keeps the existing 503 response.

How to test

  1. Go to Personal settings → Security → Devices & sessions and create an app password
  2. Rename it to an empty name or to a few spaces
  3. Before: the request returns 200 and the name is saved blank. After: it returns 400, an error is shown and the previous name is kept

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@MarioPym
MarioPym requested a review from a team as a code owner October 21, 2026 16:44
@MarioPym
MarioPym requested review from Altahrim, come-nc, icewind1991 and leftybournes and removed request for a team October 21, 2026 16:44
@susnux susnux added bug 3. to review Waiting for reviews labels Oct 21, 2026
@MarioPym
MarioPym force-pushed the fix/reject-empty-app-password-name branch from 5ee1239 to 36a213b Compare October 30, 2026 21:07
@MarioPym

Copy link
Copy Markdown
Contributor Author

Rebased onto master to resolve the conflict with the TokenScopes changes in update(). The fix itself is unchanged.

@come-nc come-nc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn’t we trim the name at the beginning then, to forbid confusing spaces at start&end ?

@MarioPym

MarioPym commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Shouldn’t we trim the name at the beginning then, to forbid confusing spaces at start&end ?

Good point, done. The name is now trimmed on create and on rename. On update it's only trimmed when the name actually changes, so existing tokens whose names already have surrounding spaces aren't renamed when only the scope is changed.

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

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.)

@susnux

susnux commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

@MarioPym please rebase

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Mario Alfonso Pym Mejía <pymm@hitss.com>
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Mario Alfonso Pym Mejía <pymm@hitss.com>
@MarioPym
MarioPym force-pushed the fix/reject-empty-app-password-name branch from 5b05338 to 20900d4 Compare November 11, 2026 18:30
@MarioPym

Copy link
Copy Markdown
Contributor Author

Rebased onto master, thanks!

@come-nc
come-nc merged commit 8f9db02 into nextcloud:master Nov 12, 2026
166 of 168 checks passed
@welcome

welcome Bot commented Nov 12, 2026

Copy link
Copy Markdown

Thanks for your first pull request and welcome to the community! Feel free to keep them coming! If you are looking for issues to tackle then have a look at this selection: https://github.com/nextcloud/server/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22

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.

4 participants