-
Notifications
You must be signed in to change notification settings - Fork 354
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
feature: Add ACL check when getting Datastore keys [DHIS2-15959] #15595
Conversation
Codecov Report
@@ Coverage Diff @@
## master #15595 +/- ##
=========================================
Coverage 66.24% 66.25%
- Complexity 31263 31265 +2
=========================================
Files 3485 3485
Lines 129790 129798 +8
Branches 15146 15146
=========================================
+ Hits 85975 85992 +17
+ Misses 36731 36724 -7
+ Partials 7084 7082 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 5 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
Kudos, SonarCloud Quality Gate passed! |
Summary
Add ACL (
r-------
) sharing check forUser
getting namespace keys fromDataStore
3 endpoints impacted:
GET
/api/dataStore/{namespace}/keys
GET
/api/dataStore/{namespace}
GET
/api/dataStore/{namespace}?fields={field}
(with query params)Change
hql
which includes these checks in the following order:User
issuperUser
Sharing
jsonb
owner
is null or matchesUser
Sharing
jsonb
public
is null or has metadata read accessr-------
Sharing
jsonb
users
containsUser
IDSharing
jsonb
userGroups
containsUser
userGroup
IDNotes
The default public access for
DatastoreEntry
has been keptrw------
This work should have no adverse affect on existing implementations.
The Datastore docs already have the relevant information about default public access & sharing.
Testing
Automated
/api/dataStore/{namespace}
endpoint/api/dataStore/{namespace}/keys
and/api/dataStore/{namespace}
with query params endpointsManual
Any logged in
User
should be able to see all keys from a namespace using any of these endpoints:GET
/api/dataStore/{namespace}/keys
GET
/api/dataStore/{namespace}
GET
/api/dataStore/{namespace}?fields={field}
(with query params)A normal (non superuser) User with no explicit access should still be able to retrieve namespace keys for a namespace it has access to.
A normal User with explicit sharing access should be able to retrieve namespace keys, when the public access is removed.
To add an entry to a new namespace:
POST
/api/dataStore/{myNamespace}/{myKey}
with sample bodyTo get the ID of a
DataEntry
use:GET
/api/dataStore/{namespace}/{key}/metaData
To remove public access of a
DataEntry
:POST
/api/sharing?type=dataStore&id={dataStoreEntryId}
with bodyTo share access of a
DataEntry
with anotherUser
& remove public access:POST
/api/sharing?type=dataStore&id={dataStoreEntryId}
with bodyTo share access with a
UserGroup
& remove public access use: