-
Notifications
You must be signed in to change notification settings - Fork 0
Authentication (token 400 or 401) and Authorization (user permissions) Audit #441
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
base: development
Are you sure you want to change the base?
Conversation
|
@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. |
|
Okay yeah I guess just do your own pull request that feels right. I guess mine is just trash. |
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.
Pull request overview
Copilot reviewed 18 out of 18 changed files in this pull request and generated no new comments.
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