-
Notifications
You must be signed in to change notification settings - Fork 51
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: Ability to relate private documents to actors #2907
feat: Ability to relate private documents to actors #2907
Conversation
e4083eb
to
b54963a
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #2907 +/- ##
===========================================
+ Coverage 79.42% 79.70% +0.28%
===========================================
Files 346 348 +2
Lines 26715 27014 +299
===========================================
+ Hits 21217 21530 +313
+ Misses 3964 3957 -7
+ Partials 1534 1527 -7
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 21 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
2ab1edc
to
043d9e6
Compare
tests/integration/acp.go
Outdated
} | ||
|
||
var docID string | ||
if action.DocID == -1 { |
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.
discussion: I understand if people prefer having DocIDIndex
and DocID
to test these edge cases rather than -1
to test empty/invalid DocID input. I don't have any strong preferences here, happy to follow consensus.
Same for other -1
inputs as well uses as well.
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.
it sort of breaks consistency with immutable.Option
, but I see how it simplifies test cases. I also don't have strong preference.
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.
immutable.Option
is for optional fields. This is not an optional field, it's more to test invalid input of that field. Is why I was wondering if others prefer non-index input as well (i.e. DocIDIndex
for normal cases and DocID
for actual invalid testing).
users: | ||
permissions: | ||
read: | ||
expr: owner + reader |
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.
discussion: Since in these tests writer won't get read
permission
, even if a relation is made to make an actor a writer, they won't be able to write because the policy doesn't model ability to read. This behavior we can try manipulate on defradb level to change (however not in this PR), but opening this here to start a discussion.
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.
Good work so far. I'm just not sure why it's still in Draft state.
There are a lot of tests here, but I'm not sure if all them are necessary.
A lot of repetitive code in tests, which makes it hard to read every detail.
cli/acp_relationship_add.go
Outdated
defradb client ... --identity e3b722906ee4e56368f581cd8b18ab0f48af1ea53e635e3f7b8acd076676f6ac | ||
|
||
|
||
Example: Let another actor read my private document: |
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.
praise: thanks for examples
tests/integration/acp.go
Outdated
} | ||
|
||
var docID string | ||
if action.DocID == -1 { |
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.
it sort of breaks consistency with immutable.Option
, but I see how it simplifies test cases. I also don't have strong preference.
tests/integration/acp/relationship/add_doc_actor_test/add_doc_actor_with_delete_test.go
Show resolved
Hide resolved
tests/integration/acp/relationship/add_doc_actor_test/add_doc_actor_with_manager_test.go
Outdated
Show resolved
Hide resolved
tests/integration/acp/relationship/add_doc_actor_test/add_doc_actor_with_manager_test.go
Show resolved
Hide resolved
tests/integration/acp/relationship/add_doc_actor_test/add_doc_actor_with_manager_test.go
Outdated
Show resolved
Hide resolved
tests/integration/acp/relationship/add_doc_actor_test/add_doc_actor_with_manager_test.go
Outdated
Show resolved
Hide resolved
tests/integration/acp/relationship/add_doc_actor_test/add_doc_actor_with_reader_test.go
Show resolved
Hide resolved
043d9e6
to
322d982
Compare
9659075
to
30b7be5
Compare
30b7be5
to
71bc530
Compare
tests/integration/acp/p2p/replicator_with_doc_actor_relationship_test.go
Show resolved
Hide resolved
f3edce2
to
f5efbd0
Compare
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.
Approving assuming tests will be moved as discussed
f5efbd0
to
f9ed0ca
Compare
f9ed0ca
to
7ebd623
Compare
14480ed
to
f227499
Compare
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.
LGTM, thanks Shahzad!
This is because we will add some more acp related stuff to this file.
782e70c
to
a42ca82
Compare
a42ca82
to
5c05eeb
Compare
## Relevant issue(s) Resolves #2906 ## Description Follow-up to #2907, the ability to delete a relationship (in order to revoke access from an identity). ## CLI Demo The following revokes the target actors 'relational' access to the private doc (can't read anymore): ```bash defradb client acp relationship delete \ --collection Users \ --docID bae-ff3ceb1c-b5c0-5e86-a024-dd1b16a4261c \ --relation reader \ --actor did:key:z7r8os2G88XXBNBTLj3kFR5rzUJ4VAesbX7PgsA68ak9B5RYcXF5EZEmjRzzinZndPSSwujXb4XKHG6vmKEFG6ZfsfcQn \ --identity e3b722906ee4e56368f581cd8b18ab0f48af1ea53e635e3f7b8acd076676f6ac ``` Result: ```json { "RecordFound": true // <-------------- Indicates a relationship was found and deleted } ``` ## How has this been tested? CI + Integration Tests + Unit Tests
Relevant issue(s)
Resolves #2762
Description
This PR introduces the ability to make use of the
relation
s defined within a policy to create relationships between an actor and a document within a collection. For users sake, I have made the clients (http, and cli) not consume thepolicyID
andresource
name but instead adocID
andcollection name
, since the collection will have the policy and resource information available we can fetch that and make lives easier for the users.This PR also makes use of the
manages
feature we have had in our policy. The manages essentially defines who can make the relationship manipulation requests.There are a lot of tests in this PR due to a lot of edge cases I wanted to have tested specific to
manger
, and ensuringwrite
andread
permissions don't leak (i.e. are accidently granted).CLI Demo
The following lets the target actor be able to now read the private document:
Result:
Future (out-of-scope of this PR):
delete
andupdate
in Split ACPwrite
perm intodelete
andupdate
#2905can't write if no read permission
in An actor granted a write permission still can't write unless also given read permission #2992How has this been tested?
Specify the platform(s) on which this was tested: