-
Notifications
You must be signed in to change notification settings - Fork 13.8k
fix(api): return 403 for authorization failures, reserve 401 for missing session #41659
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "@rocket.chat/meteor": patch | ||
| "@rocket.chat/http-router": patch | ||
| --- | ||
|
|
||
| fix(api)!: return 403 for authorization failures, reserve 401 for missing session | ||
|
Comment on lines
+1
to
+6
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win Remove this changeset from the PR. The PR objective states that this change includes no changeset. This file schedules patch releases for two packages. Delete it before merge. 🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1136,6 +1136,7 @@ API.v1.get( | |
| }), | ||
| 400: validateBadRequestErrorResponse, | ||
| 401: validateUnauthorizedErrorResponse, | ||
| 403: validateForbiddenErrorResponse, | ||
| 404: validateNotFoundErrorResponse, | ||
| }, | ||
| }, | ||
|
|
@@ -1154,7 +1155,7 @@ API.v1.get( | |
| } | ||
|
|
||
| if (findResult.broadcast && !(await hasPermissionAsync(this.user, 'view-broadcast-member-list', findResult._id))) { | ||
| return API.v1.unauthorized(); | ||
| return API.v1.forbidden(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a requester can access a broadcast room but lacks Useful? React with 👍 / 👎.
cubic-dev-ai[bot] marked this conversation as resolved.
|
||
| } | ||
|
|
||
| // Ensures that role priorities for the specified room are synchronized correctly. | ||
|
|
@@ -1294,13 +1295,14 @@ API.v1.post( | |
| 200: successResponseSchema, | ||
| 400: validateBadRequestErrorResponse, | ||
| 401: validateUnauthorizedErrorResponse, | ||
| 403: validateForbiddenErrorResponse, | ||
| }, | ||
| }, | ||
| async function action() { | ||
| const { roomId } = this.bodyParams; | ||
|
|
||
| if (!(await canAccessRoomIdAsync(roomId, this.userId))) { | ||
| return API.v1.unauthorized(); | ||
| return API.v1.forbidden(); | ||
| } | ||
|
|
||
| const user = await Users.findOneById(this.userId, { projection: { _id: 1 } }); | ||
|
|
@@ -1697,13 +1699,14 @@ export const roomEndpoints = API.v1 | |
| response: { | ||
| 200: roomsBannedUsersResponseSchema, | ||
| 401: validateUnauthorizedErrorResponse, | ||
| 403: validateForbiddenErrorResponse, | ||
| }, | ||
| }, | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| async function action() { | ||
| const { roomId } = this.queryParams; | ||
|
|
||
| if (!(await canAccessRoomIdAsync(roomId, this.userId))) { | ||
| return API.v1.unauthorized(); | ||
| return API.v1.forbidden(); | ||
| } | ||
|
|
||
| const { offset, count } = await getPaginationItems(this.queryParams); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -245,7 +245,7 @@ export class Router< | |
| return c.json( | ||
| { | ||
| success: false, | ||
| errorType: 'invalid-params', | ||
| errorType: 'error-invalid-params', | ||
|
coderabbitai[bot] marked this conversation as resolved.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For invalid request bodies on routes using this router, this now emits Useful? React with 👍 / 👎.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: This change makes body validation return Prompt for AI agents
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: This change alters the Prompt for AI agents |
||
| error: validatorFn.errors?.map((error: any) => error.message).join('\n '), | ||
| }, | ||
| 400, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: The PR description states this change has no changeset, yet this file schedules patch releases for @rocket.chat/meteor and @rocket.chat/http-router. Remove this changeset before merge to match the stated intent, or update the PR description if a release is actually intended.
Prompt for AI agents