Skip to content

Always give the pod owner control access - #938

Merged
jvherweg merged 2 commits into
versions/2.0.0from
feat/ownership
Oct 5, 2021
Merged

jvherweg merged 2 commits into
versions/2.0.0from
feat/ownership

Conversation

@jvherweg

@jvherweg jvherweg commented Aug 31, 2021 •

Copy link
Copy Markdown
Member

Closes #720

Depends on #936

Some issues with this solution, some of them caused by architecture that might have to change:

  1. Several components need things from the AccountStore but use a different key to access it. The login handler uses the email address while this new authorizer uses the WebID. This has been solved by allowing settings to be accessed through the WebID but an ideal solution would be to have a storage that can be queried (a triple store for example). But adding that while using the ResourceStore as backend and keeping it efficient is not going to be easy/possible.
  2. The WAC-Allow headers are not going to be correct (or present event) for request that get handled by this authorizer. That is because a) this authorizer doesn't check the other permissions and b) this authorizer is WebACL-independent. Which means it returns an Authorization object with an empty addMetadata function. We will probably need an extra abstraction layer here somewhere in the future, several of our authorization components are too tightly coupled with the WebACL behaviour. Our internal permissions are probably also too tightly coupled to acl permissions.
  3. Due to the account changes it is now always required to provide a password when creating a pod, even if you're not registering with the IDP. There are ways around it, but at some point in the future we probably want to provide some extra pod options which could be accessed using the same login details.
  4. Also due to the account changes, it is no longer to have multiple accounts linked to the same WebID. There are ways around it if this is really an issue, but I think this is acceptable.
  5. Since the new authorizer needs the AccountStore, it is now impossible to have a config that used the default authorizer without also importing the IDP handler config (see the change to the LDP integration config). I could potentialy add a new authorization config option that excludes this new authorizer for setups that do not want to import the IDP component.

@jvherweg jvherweg added the semver.major Requires a major version bump label Aug 31, 2021
@jvherweg
jvherweg changed the base branch from versions/2.0.0 to refactor/storage August 31, 2021 14:54

@RubenVerborgh RubenVerborgh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

2 and 4 are blockers for me.

But I think there's an even more fundamental problem: the ownership handler should be combined with the WebACL authorizer. So the ownership handler should add Control permissions for the pod owner, rather than only giving those permissions.

Right now, as an owner, I will never get read or write permissions, if I interpret this correctly.

So we either need ownership to be a wrapper, or all authorizers should take an object which they augment. (For instance, ownership could remove the need for "control" to be checked down the line, if it has already checked it.)

@RubenVerborgh

RubenVerborgh commented Sep 7, 2021 •

Copy link
Copy Markdown
Member

So we'll probably also need an integration test for this case.
Perhaps see if owners can remove their own read/write (control??) access, and then restore it.

@RubenVerborgh

RubenVerborgh commented Sep 7, 2021 •

Copy link
Copy Markdown
Member

This might actually make the case for refactoring auth from pass/fail to returning the allowed modes instead. Then we could build a wrapping CombinedAuthenticationHandler (instead of waterfall) that adds allowed permissions together.

Alternatively, can we implement owner access as rule, just like we've implemented groups? (but yeah, it's not WebACL-specific)

Comment thread test/integration/Identity.test.ts Resolved
@jvherweg

jvherweg commented Sep 8, 2021

Copy link
Copy Markdown
Member Author

2 and 4 are blockers for me.

To clarify 2: the headers are only going to be incorrect in the case the authorizer gets used, so specifically a control request done by the owner, all other requests are still going to have correct headers. But not perfect indeed.

4 can probably be resolved by storing an array of settings per WebID instead of a single object as is being done now, and then change the account store interface to return an array as wel instead. Would have to think about how to update preferences then but should be possible, just a bit more hassle perhaps.

But I think there's an even more fundamental problem: the ownership handler should be combined with the WebACL authorizer. So the ownership handler should add Control permissions for the pod owner, rather than only giving those permissions.

Right now, as an owner, I will never get read or write permissions, if I interpret this correctly.

You will because the canHandle call of this new authorizer is going to fail (since the permissions object contains non-control permissions), so the main acl authorizer will catch the request. The only issue would be if you do a request that requires both control and read permissions to your own pod, and the acl file only specifies that you have read permissions. But in practice such a request is (currently) impossible since it's always either one or the other, although that might be different for other authorizers.

So we either need ownership to be a wrapper, or all authorizers should take an object which they augment. (For instance, ownership could remove the need for "control" to be checked down the line, if it has already checked it.)

There might be something there.

So we'll probably also need an integration test for this case.
Perhaps see if owners can remove their own read/write (control??) access, and then restore it.

There is one, I added a comment to indicate where.

This might actually make the case for refactoring auth from pass/fail to returning the allowed modes instead. Then we could build a wrapping CombinedAuthenticationHandler (instead of waterfall) that adds allowed permissions together.

We could do that. One advantage now is that no acl check happens in the case an owner requires control permissions, which removes that backend call, but that's a very specific case so not that relevant. One issue is that for the WAC-Allow headers we need to know both the permissions that are allowed for the current request AND also the permissions required for a public user. We can just return both of course, but that might make our implementation a bit more acl-specific again.

Alternatively, can we implement owner access as rule, just like we've implemented groups? (but yeah, it's not WebACL-specific)

Yea not a fan of this because of reasons mentioned above.

Base automatically changed from refactor/storage to versions/2.0.0 September 8, 2021 08:01
@woutermont woutermont mentioned this pull request Sep 8, 2021
@RubenVerborgh

Copy link
Copy Markdown
Member

The only issue would be if you do a request that requires both control and read permissions to your own pod, and the acl file only specifies that you have read permissions. But in practice such a request is (currently) impossible

Right, I had not computed that indeed. They are currently mutually exclusive, my bad.

This might actually make the case for refactoring auth from pass/fail to returning the allowed modes instead. Then we could build a wrapping CombinedAuthenticationHandler (instead of waterfall) that adds allowed permissions together.

We could do that.

I think actually this is my preference; because it also makes WAC-Allow independent of any specific authorizers.
The other consideration here is solid/web-access-control-spec#97 (comment)

Would you be okay with creating a new issue to refactor authorization to return allowed modes?
And then we rebase this one off it?

@jvherweg

Copy link
Copy Markdown
Member Author

I refactored this PR to be in line with the changes from #953. Going to look into points 2 and 4 mentioned above.

Point 2 (having correct WAC-Allow headers) might already be fixed due to this refactor. The headers on non-acl resources are now going to completely match what is defined in relevant acl resource. The only thing missing is that owners will not see the control value in the header if it's not specified in the acl resource, even though they do have those permissions.

This can be fixed, but that would mean that we would have to do a call to the account store for every incoming request. I specifically made it so this currently only happens for requests targeting acl resources since this is another call to the backend resource store.

@RubenVerborgh

Copy link
Copy Markdown
Member

The only thing missing is that owners will not see the control value in the header if it's not specified in the acl resource, even though they do have those permissions.

This can be fixed, but that would mean that we would have to do a call to the account store for every incoming request. I specifically made it so this currently only happens for requests targeting acl resources since this is another call to the backend resource store.

Sounds good to me. Will review current state now.

@RubenVerborgh RubenVerborgh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great work!

Comment thread src/authorization/AclOwnershipReader.ts Resolved
Comment thread src/authorization/AclOwnershipReader.ts Resolved
Comment thread src/authorization/AclOwnershipReader.ts Resolved
Comment thread src/authorization/AclOwnershipReader.ts Resolved
Comment thread test/integration/Identity.test.ts Resolved
Comment thread src/authorization/AclOwnershipReader.ts Resolved
Comment thread src/authorization/AclOwnershipReader.ts Outdated
}
let settings: AccountSettings;
try {
settings = await this.accountStore.getSettings(credentials.agent.webId);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If too expensive (re: performance above), maybe we can consider a cache.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It might be interesting to have some sort of cache for the key/value storages. Did we already have a discussion about this? Because I feel like we did. We would need events to update the caches then. Might even allow us to use an N3 store for the data and have events contain info which data to add/remove.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah we did indeed. But not a necessity then; we know we can.

Account settings are stored using the WebID as key.
Reason for using the WebID is that this allows faster access to the settings
in authenticated requests.
A consequence of this is that passwords are now always required during registration,
and that there can only be 1 account per WebID.
@jvherweg
jvherweg merged commit 8f5d619 into versions/2.0.0 Oct 5, 2021
@jvherweg
jvherweg deleted the feat/ownership branch October 5, 2021 11:19
@jvherweg jvherweg added this to the v2.0.0 milestone Oct 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⌛ has dependency semver.major Requires a major version bump

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants