Skip to content
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

Support for allocation owner permissions on their tree (CADC-13241) #222

Merged
merged 3 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cadc-test-vos/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ sourceCompatibility = 1.8

group = 'org.opencadc'

version = '2.1.6'
version = '2.1.7'

description = 'OpenCADC VOSpace test library'
def git_url = 'https://github.com/opencadc/vos'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1010,9 +1010,26 @@ public void testPermissions() throws Exception {
201, putAction.getResponseCode());
Assert.assertNull("expected PUT throwable == null", putAction.getThrowable());

log.debug("Delete node " + childURL);
// test owner of root directory fails to read and delete due to a lack of explicit permission
getAction = new HttpGet(childURL, true);
Subject.doAs(authSubject, new RunnableAction(getAction));
Assert.assertEquals(403, getAction.getResponseCode());
HttpDelete deleteAction = new HttpDelete(childURL, true);
Subject.doAs(groupMember, new RunnableAction(deleteAction));
Subject.doAs(authSubject, new RunnableAction(deleteAction));
Assert.assertEquals(403, getAction.getResponseCode());

// Allocation owners have read and write access over their tree allocation.
// Make root node an allocation node by adding the quota properties and test that the owner of
// that node (authSubject) in their new role can now perform the above actions.
testNode.getProperties().add(new NodeProperty(VOS.PROPERTY_URI_QUOTA));
post(nodeURL, nodeURI, testNode);

getAction = new HttpGet(childURL, true);
Subject.doAs(authSubject, new RunnableAction(getAction));
Assert.assertEquals(200, getAction.getResponseCode());
log.debug("Delete node " + childURL);
deleteAction = new HttpDelete(childURL, true);
Subject.doAs(authSubject, new RunnableAction(deleteAction));
log.debug("DELETE responseCode: " + deleteAction.getResponseCode());
Assert.assertEquals("expected PUT response code = 200",
200, deleteAction.getResponseCode());
Expand Down
2 changes: 1 addition & 1 deletion cadc-vos-server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ sourceCompatibility = 1.8

group = 'org.opencadc'

version = '2.0.9'
version = '2.0.10'

description = 'OpenCADC VOSpace server'
def git_url = 'https://github.com/opencadc/vos'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ public boolean hasSingleNodeReadPermission(Node node, Subject subject) {
return true; // OK
}

if (isAllocationOwner(node, subject)) {
log.debug("Allocation owner granted read permission.");
return true; // OK
}

checkDelegation(node, subject);

if (log.isDebugEnabled()) {
Expand Down Expand Up @@ -228,6 +233,11 @@ public boolean hasSingleNodeWritePermission(Node node, Subject subject) {
return true; // OK
}

if (isAllocationOwner(node, subject)) {
log.debug("Allocation owner granted write permission");
return true; // OK
}

checkDelegation(node, subject);

if (log.isDebugEnabled()) {
Expand Down Expand Up @@ -339,6 +349,25 @@ private boolean isOwner(Node node, Subject subject) {
return false;
}

/**
* Check if the specified subject is the owner of the allocation a node belongsto. Allocation owner
* is identified as the owner of the first node in the path that has an associated quota attribute set.
* @param node
* @param subject
* @return
*/
private boolean isAllocationOwner(Node node, Subject subject) {

Node parent = node.parent;
while (parent != null) {
if (parent.getProperty(VOS.PROPERTY_URI_QUOTA) != null) {
return isOwner(parent, subject);
}
parent = parent.parent;
}
return false;
}

/**
* check for delegation cookie and, if present, does an authorization
* against it.
Expand Down
2 changes: 1 addition & 1 deletion cavern/src/test/resources/cadc-registry.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# configure RegistryClient bootstrap
## BUG / HACK: this gets pulled into the intTest target so needs a legit value
ca.nrc.cadc.reg.client.RegistryClient.baseURL = https://haproxy.cadc.dao.nrc.ca/reg/
ca.nrc.cadc.reg.client.RegistryClient.baseURL = https://localhost.cadc.dao.nrc.ca/reg/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ugh. this test setup was a hack and this solution is no better or worse than before. I will try to fix the test setup separately.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry. That is my local change but it "leaks" from time to time. I've fixed it and then then I broke it again right after...


# local authority map
# <base standardID> = <authority>
Expand Down
Loading