[PR #7627] [CLOSED] fix(device-anthorization): authentication requirement in deny endpoint #24352

Closed
opened 2026-04-15 22:19:36 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7627
Author: @himself65
Created: 1/27/2026
Status: Closed

Base: canaryHead: cursor/device-deny-authentication-requirement-2829


📝 Commits (1)

  • 654545a fix(device-authorization): require authentication for /device/deny endpoint

📊 Changes

2 files changed (+36 additions, -3 deletions)

View changed files

📝 packages/better-auth/src/plugins/device-authorization/device-authorization.test.ts (+25 -2)
📝 packages/better-auth/src/plugins/device-authorization/routes.ts (+11 -1)

📄 Description

Add session requirement to the /device/deny endpoint to prevent denial-of-service attacks.

The /device/deny endpoint previously lacked authentication, allowing anyone with a valid userCode to deny pending device authorization requests. This fix aligns its security requirements with the /device/approve endpoint, requiring an authenticated user session to perform the denial.


Slack Thread

Open in Cursor Open in Web


Summary by cubic

Require authentication for the /device/deny endpoint to block denial-of-service via public userCode. Aligns security with /device/approve.

  • Bug Fixes

    • Enforce auth on /device/deny using requireHeaders and getSessionFromCtx.
    • Add "unauthorized" error type; return "Authentication required" when no session.
    • Update tests to use authenticated headers and verify the new requirement.
  • Migration

    • Call /device/deny with an authenticated user session and include auth headers.

Written for commit 654545a4ed. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/7627 **Author:** [@himself65](https://github.com/himself65) **Created:** 1/27/2026 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `cursor/device-deny-authentication-requirement-2829` --- ### 📝 Commits (1) - [`654545a`](https://github.com/better-auth/better-auth/commit/654545a4ed6f06f2da28b1528bbfe34bfe6b7aef) fix(device-authorization): require authentication for /device/deny endpoint ### 📊 Changes **2 files changed** (+36 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/device-authorization/device-authorization.test.ts` (+25 -2) 📝 `packages/better-auth/src/plugins/device-authorization/routes.ts` (+11 -1) </details> ### 📄 Description Add session requirement to the `/device/deny` endpoint to prevent denial-of-service attacks. The `/device/deny` endpoint previously lacked authentication, allowing anyone with a valid `userCode` to deny pending device authorization requests. This fix aligns its security requirements with the `/device/approve` endpoint, requiring an authenticated user session to perform the denial. --- [Slack Thread](https://betterauth.slack.com/archives/C0A8B5BARUK/p1769481117322019?thread_ts=1769481117.322019&cid=C0A8B5BARUK) <a href="https://cursor.com/background-agent?bcId=bc-d32f6c0c-3bb2-4bb3-b83b-2b66e354617f"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/open-in-cursor-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/open-in-cursor-light.svg"><img alt="Open in Cursor" src="https://cursor.com/open-in-cursor.svg"></picture></a>&nbsp;<a href="https://cursor.com/agents?id=bc-d32f6c0c-3bb2-4bb3-b83b-2b66e354617f"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/open-in-web-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/open-in-web-light.svg"><img alt="Open in Web" src="https://cursor.com/open-in-web.svg"></picture></a> <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Require authentication for the /device/deny endpoint to block denial-of-service via public userCode. Aligns security with /device/approve. - **Bug Fixes** - Enforce auth on /device/deny using requireHeaders and getSessionFromCtx. - Add "unauthorized" error type; return "Authentication required" when no session. - Update tests to use authenticated headers and verify the new requirement. - **Migration** - Call /device/deny with an authenticated user session and include auth headers. <sup>Written for commit 654545a4ed6f06f2da28b1528bbfe34bfe6b7aef. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-15 22:19:36 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#24352