-
Notifications
You must be signed in to change notification settings - Fork 24
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
Feat: add endpoint to check user access for sample and proposal #1327
Feat: add endpoint to check user access for sample and proposal #1327
Conversation
07839f0
to
d723ac9
Compare
The decision on whether to allow users to update the isPublished status of proposals requires further investigation. In the proposalAuthorization test file, test cases for public proposals are temporarily commented out. |
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.
Please check my comments and let me know if we need to discuss
test/config/pretest.js
Outdated
const testDbName = process.env.MONGODB_TEST || "scicat-test"; | ||
const uri = `mongodb://localhost:27017/${testDbName}`; |
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.
I'm not sure what is the correct solution, but I think that have a separate variable to set the dataset in testing will lead to confusion.
I think we should rely only on the value MONGODB_URI. If you are testing locally, you will change the value of MONGODB_URI according in order to use your local database.
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.
I think we should try to avoid relying on MONGODB_URI for testing.
If you by accident, run the test locally without changing the MONGODB_URI the test will wipe off all the local DB data
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.
I see your point, but by using the two environmental variables, we are forcing developers to change the database name in two places instead of one.
Also I feel that we are not minimizing the risk to wipe a local DB data. It is still very much present.
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.
I'd suggest to just hardcode test db as scicat-test-db
in this file like the appUrl
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.
Waiting for the changes on pretest
Description
This pull request introduces new endpoints to check user access for specific samples and proposals. It includes updates to the authorization mechanisms and related test cases to ensure proper access control based on user roles and permissions.
Additional:
Motivation
When a user opens a dataset detail page, the frontend makes requests to fetch the Sample and Proposal attached to the dataset, regardless of whether the user has permission to access them. By utilizing user access endpoints, we can pre-check if the user has access to the Sample or Proposal before making subsequent requests. This can reduce the collection of
FALSY
errors.Changes
New Endpoints:
/samples/:id/authorization
and/proposals/:pid/authorization
endpoints to check if the user has access to specific samples and proposals.Authorization Updates:
Tests:
Tests included
Documentation
official documentation info
If you have updated the official documentation, please provide PR # and URL of the pages where the updates are included