You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Context:
This fix takes care of one special case where let's say we have a entity Book in which the READ operation has no column exposed i.e. include = [], or more generally when no field is exposed for READ operation on the entity.
In such a case, when the DAB engine receives a READ request where the url does not contain any key and there are no other clauses like order by/select/filter etc. (eg. the url is https://localhost:5001/api/Book/), all the authorization checks would pass. This is the only case when we would hit the code block in question in this issue here. This however is an invalid case, where the user is not authorized to access any field for the READ operation on the entity and should be failed at the authorization stage itself. The changes in the PR do exactly that.
What is this change?
Removed incorrect code block here. What the code block used to do?
In case when the Columns.Count == 0 (where Columns is the list of columns which the query selects), this code block used to add all the fields present in the Entity to the Columns list, which should not be done because if the Columns.Count ==0 at that stage, the user is not authorised to access any field in the entity for the READ operation.
We should fail such a request in the authorization stage itself.
To fail the request in authorization stage, adding additional during column authorization check for READ operation : When OperationMetaData.AllowedExposedColumns.Count() ==0 => The user is not authorized to access any field in the entity for this operation. We thus fail the request.
Example Request to see the issue:
Set permission for an READ operation entity lets say Book to have no columns exposed.
Execute a GET request with url : https://localhost:5001/api/Book/. It would return all the rows in the books table with all the fields. However since no fields were exposed, the user was not authorized to see any of them, and hence the behavior is incorrect.
ayush3797
changed the title
Handling READ operation with no fields referenced in url
Handling authN for READ operation with no fields referenced in url
Nov 7, 2022
ayush3797
changed the title
Handling authN for READ operation with no fields referenced in url
Handling authZ for READ operation with no fields referenced in url
Nov 7, 2022
While the link to the separate issue is good, it would be beneficial to give brief summary here to reduce the need cross reference across issue/PR what is done here.
I don't follow this, can you describe behavior before/after this change and list some sample requests?
Adding additional during column authorization check for READ operation : When OperationMetaData.AllowedExposedColumns.Count() ==0 => The user is not authorized to access any field in the entity for this operation. We fail such a request.
It would be helpful to provide context, especially for other reviewers about why the removed code block was redundant/what that code block was:
While the link to the separate issue is good, it would be beneficial to give brief summary here to reduce the need cross reference across issue/PR what is done here.
I don't follow this, can you describe behavior before/after this change and list some sample requests?
Adding additional during column authorization check for READ operation : When OperationMetaData.AllowedExposedColumns.Count() ==0 => The user is not authorized to access any field in the entity for this operation. We fail such a request.
It would be helpful to provide context, especially for other reviewers about why the removed code block was redundant/what that code block was:
Removed redundant code block.
Addressed your concerns in the PR description. Please have a look.
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
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.
Why make this change?
Fixes #487.
Context:
This fix takes care of one special case where let's say we have a entity
Bookin which theREADoperation has no column exposed i.e.include = [], or more generally when no field is exposed for READ operation on the entity.In such a case, when the DAB engine receives a READ request where the url does not contain any key and there are no other clauses like order by/select/filter etc. (eg. the url is
https://localhost:5001/api/Book/), all the authorization checks would pass. This is the only case when we would hit the code block in question in this issue here. This however is an invalid case, where the user is not authorized to access any field for the READ operation on the entity and should be failed at the authorization stage itself. The changes in the PR do exactly that.What is this change?
What the code block used to do?
In case when the
Columns.Count== 0 (whereColumnsis the list of columns which the query selects), this code block used to add all the fields present in the Entity to theColumnslist, which should not be done because if the Columns.Count ==0 at that stage, the user is not authorised to access any field in the entity for the READ operation.We should fail such a request in the authorization stage itself.
READoperation : WhenOperationMetaData.AllowedExposedColumns.Count()==0 => The user is not authorized to access any field in the entity for this operation. We thus fail the request.Example Request to see the issue:
Bookto have no columns exposed.https://localhost:5001/api/Book/. It would return all the rows in the books table with all the fields. However since no fields were exposed, the user was not authorized to see any of them, and hence the behavior is incorrect.