Skip to content

fix: Trigger same logic as login failure when Bearer token is not valid - #67315

Merged
come-nc merged 3 commits into
masterfrom
fix/fix-bearer-login-failure-handling
Dec 1, 2026
Merged

come-nc merged 3 commits into
masterfrom
fix/fix-bearer-login-failure-handling

Conversation

@come-nc

@come-nc come-nc commented Dec 1, 2026

Copy link
Copy Markdown
Contributor
  • Resolves: #

Summary

Checklist

AI (if applicable)

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

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
@come-nc come-nc added this to the Nextcloud 36 milestone Dec 1, 2026
@come-nc come-nc self-assigned this Dec 1, 2026
@come-nc
come-nc requested a review from a team as a code owner December 1, 2026 11:47
@come-nc
come-nc removed the request for review from a team December 1, 2026 11:47
@come-nc come-nc added the 3. to review Waiting for reviews label Dec 1, 2026
@come-nc

come-nc commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

/backport! to stable35

@come-nc

come-nc commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Hmm, playwright test are now failing with "429 too many requests" errors 🤔

Otherwise they get blocked

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
@come-nc
come-nc requested a review from a team as a code owner December 1, 2026 14:57
@come-nc
come-nc requested review from kristian-zendato and skjnldsv and removed request for a team December 1, 2026 14:57
Otherwise it gets enabled again afterwards

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
@come-nc
come-nc enabled auto-merge December 1, 2026 16:03
@come-nc
come-nc merged commit 753130b into master Dec 1, 2026
154 checks passed
@come-nc
come-nc deleted the fix/fix-bearer-login-failure-handling branch December 1, 2026 16:20
susnux added a commit to susnux/secret_santa that referenced this pull request Dec 1, 2026
Since nextcloud/server#67315 the server throttles more requests like
failed logins. All Playwright tests log in from the same address, so the
logins of later tests were refused with 429 Too Many Requests. The
server disabled both protections for its own Playwright tests in the
same change.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
@juliusknorr

juliusknorr commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

@come-nc this also breaks Collabora. It sends its WOPI access token as Authorization: Bearer <token>, which isn't a Nextcloud token, so every WOPI request now counts as a failed login for the Collabora server's IP. After 11 requests CheckFileInfo and GetFile return 429 and documents no longer open. #67427 only covers the session cookie case, the Bearer path is unchanged on master.

richdocuments Cypress runs against master on main and has been failing since this was merged, e.g. https://github.com/nextcloud/richdocuments/actions/runs/46753504564. stable35 fails the same way since the backport, cookie fix included, e.g. https://github.com/nextcloud/richdocuments/actions/runs/46915415739

Other apps whose clients send their own Bearer tokens are probably hit the same way, e.g. Nextcloud Office with Document Server's default JWT header. Could we avoid counting tokens that aren't meant for Nextcloud's own login, and hold the open backports (#67320-#67327) and the next maintenance releases until it's sorted?

@juliusknorr

Copy link
Copy Markdown
Member

It's not only Collabora. These get foreign Bearer tokens too and break on stable33-35:

  • eurooffice and ONLYOFFICE (Document Server JWT callbacks)
  • user_oidc on WebDAV (BearerAuth counts IdP tokens before handleApacheAuth() accepts them)
  • oidc as IdP (relying parties calling userinfo)
  • bookmarks with Floccus, whiteboard guests, likely Office Online Server

Once an IP is blocked, its valid Nextcloud tokens and password logins fail too.

Could the failed login be registered on the 401 path instead (NotLoggedInException, DAV auth failure), so requests that succeed with an app's own token don't count? Or revert the stable backports until then?

@juliusknorr

Copy link
Copy Markdown
Member

Maybe simpler than the 401 path: only throttle and count Bearer values that look like Nextcloud tokens. App passwords, OAuth2 and client-flow tokens are all 72 alphanumerics (AppPasswordController, OauthApiController, ClientFlowLoginController), so guesses still count, while WOPI tokens and JWTs are left alone. Doing the check before sleepDelayOrThrowOnMax too means an IP that's blocked for other reasons doesn't break these apps either. I couldn't find where OCM access tokens are created though, so their format would need a check.

AsherBond pushed a commit to AsherBond/rich_docs that referenced this pull request Dec 4, 2026
Collabora sends the WOPI access token in the access_token query parameter
and also as "Authorization: Bearer <token>", which we never read. Since
nextcloud/server#67315 every Bearer token that isn't a Nextcloud token
counts as a failed login, so the Collabora server soon gets 429 for its
WOPI requests and documents stop loading.

Post no_auth_header=1 with the token, so Collabora 25.04.3 and later
leave the header out. Older versions ignore the field. The settings
iframe only benefits once Collabora passes the flag on there as well.

Signed-off-by: Julius Knorr <jus@bitgrid.net>
Assisted-by: ClaudeCode:claude-opus-5-5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants