Authentication (token 400 or 401) and Authorization (user permissions) Audit#441
Merged
cubap merged 5 commits intodevelopmentfrom Jan 9, 2026
Merged
Authentication (token 400 or 401) and Authorization (user permissions) Audit#441cubap merged 5 commits intodevelopmentfrom
cubap merged 5 commits intodevelopmentfrom
Conversation
Member
Author
|
@copilot review this pull request. Make sure to look at the pull request description to get a good understanding of what the code changes are doing. |
Member
Author
|
Okay yeah I guess just do your own pull request that feels right. I guess mine is just trash. |
cubap
approved these changes
Jan 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #440
Unblocks #437 (express-oauth2-jwt-bearer package update)
Currently ignores #442
Summary
This PR adds permission checks to project read endpoints and standardizes authentication error handling.
Note that the
express-oauth2-jwt-bearerlibrary behavior changed with the last update. Previously if theAuthorizationheader was omitted from a request the library returned a401. Now it is returning a400in this scenario. This is temporary as the library developers are currently working on reverting the behavior so that it returns a401again.The following test files were updated to expect 400 as a temporary workaround:
When the library is patched, these tests should be reverted to expect 401.
Changes
Added permission checks to previously unprotected authenticated endpoints:
GET /project/:id- now checks READ permissionGET /project/:id/manifest- now checks UPDATE permission (export)GET /project/:id/deploymentStatus- now checks READ permissionAdded missing authentication check to
POST /project/importendpoint:user.agentwithout verifying user exists after auth middlewareStandardized 401 error message across all protected endpoints:
Updated tests to expect 400 for missing Authorization header (this is the
express-oauth2-jwt-bearerlibrary behavior, not a body validation error)Key Files Modified
project/projectReadRouter.jscheckUserAccesspermission checks to all 3 GET endpointsproject/projectCreateRouter.js/importendpointproject/projectCopyRouter.jsproject/memberRouter.jsproject/customRolesRouter.jsproject/projectToolsRouter.jsuserProfile/privateProfile.jsline/index.jslayer/index.jspage/index.jsBearer Token Authentication Audit
How Authentication Errors Work
express-oauth2-jwt-bearerreturns Bad Request"Not authenticated. Please provide a valid, unexpired Bearer token"Public Endpoints (No Bearer Token Required)
//api/user/:id/project/:projectId/layer/:layerId/project/:projectId/page/:pageId/project/:projectId/page/:pageId/resolved/project/:projectId/page/:pageId/line/:lineId/:projectId/collaborator/:collaboratorId/decline/:projectId/collaborator/:collaboratorId/agent/:agentIdProtected Endpoints
User Profile (
/my/*)/my/profile/my/profile/my/projectsProject Read (
/project/*)/project/:id/project/:id/manifest/project/:id/deploymentStatus/project/:projectId/labelProject Creation
/project/create/project/import/project/import-imageProject Copy
/project/:projectId/copy/project/:projectId/copy-without-annotations/project/:projectId/copy-with-group/project/:projectId/copy-with-customizationsProject Members
/project/:id/invite-member/project/:id/remove-member/:projectId/collaborator/:id/addRoles/:projectId/collaborator/:id/setRoles/:projectId/collaborator/:id/removeRoles/:projectId/switch/owner/project/:id/leaveProject Tools
/project/:projectId/tool/project/:projectId/tool/project/:projectId/toggleToolProject Custom Roles
/project/:projectId/customRoles/project/:projectId/addCustomRoles/project/:projectId/updateCustomRoles/project/:projectId/removeCustomRolesProject Metadata
/project/:projectId/metadata/project/:id/custom/project/:id/custom/project/:id/customTPEN 2.8 Import
/project/deletecookie/project/import28/:uid/project/import28/selectedproject/:idLayer Routes
/project/:projectId/layer/:layerId/project/:projectId/layer/Page Routes
/project/:projectId/page/:pageId/project/:projectId/page/:pageId/column/project/:projectId/page/:pageId/column/project/:projectId/page/:pageId/column/project/:projectId/page/:pageId/clear-columnsLine Routes
/project/:projectId/page/:pageId/line//project/:projectId/page/:pageId/line/:lineId/.../line/:lineId/text/.../line/:lineId/boundsFeedback Routes
/beta/feedback/beta/bug