Skip to content

Generate allowed permissions per request + more - #962

Merged
jvherweg merged 7 commits into
versions/2.0.0from
feat/permissions
Sep 28, 2021
Merged

jvherweg merged 7 commits into
versions/2.0.0from
feat/permissions

Conversation

@jvherweg

Copy link
Copy Markdown
Member

Closes #953

Description of what was changed:

  1. CredentialsExtractors now return a CredentialSet. This is a map with the keys being "credential types" (current options being AGENT and EVERYONE), and the values being the corresponding Credentials for that type.
  2. These CredentialSets are then used by the new PermissionReaders to generate the allowed permissions per credential type. The output is a PermissionSet, with the same keys as a CredentialSet but the values being a Permissions object indicating what is allowed.
  3. A new Authorizer was created that matches the permissions required for the request with the output of the PermissionReaders
  4. A new PermissionMetadataWriter interface was created to convert permissions to metadata. This is needed for the WAC-Allow header. This is now a new parameter for the GET and HEAD operator handlers.
  5. Permissions object was changed to have more standard CRUD permissions: control was removed and create/delete were added. In practice we don't use those permissions yet though, they just get the values of write. The acl handler still adds a control value to the object so we can write the correct WAC-Allow header.
  6. AuxiliaryStrategy has a new function usesAssociatedAuthorization that indicates if the auxiliary resources should use the authorization of the associated resource or not (true for standard aux resources, false for acl since different fields need to be checked).

I'm not sure yet about the CredentialSet in 1 and thinking of perhaps undoing that and going back to a single Credentials object that we can extend in the future to have more fields (e.g. client so we can support specific access for certain clients). The current solution requires a specific configuration to make sure we have the correct set. On the other hand, the main advantage is that this way we tell the PermissionReaders what keys they need to output for. Otherwise we'll need to do this in a different way.

The AuxiliaryReader is actually never used since the only auxiliary resource we have are acl resources and those do not use the associated authorization.

ldp/permissions config options were changed since the acl.json/no-acl.json split wasn't relevant anymore due to the changes above. This was changed to default.json. Perhaps we can remove it. Only relevant case would be if someone wants to support a new PATCH input type.

Also asking for some naming suggestions:

  • Only realized this when everything was done, but we now have PermissionsExtractor, PermissionReader, Permissions and PermissionSet (notice the s differences). The reader and the set are the new ones. The extractor we might get rid off when moving permission handling to the operator handlers. Any preference on where to go with this? Similarly we have CredentialsExtractor, Credentials and CredentialSet.
  • The new class for adding the WAC-Allow metadata has interface PermissionMetadataWriter and instance WebAclMetadataWriter. But we already have a MetadataWriter interface (that converts metadata to response headers, such as the WacAllowMetadataWriter) which might cause some confusion here. Any other suggestions?

@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.

Excellent work.

My suggestions:

  • Only realized this when everything was done, but we now have PermissionsExtractor, PermissionReader, Permissions and PermissionSet (notice the s differences). The reader and the set are the new ones. The extractor we might get rid off when moving permission handling to the operator handlers. Any preference on where to go with this? Similarly we have CredentialsExtractor, Credentials and CredentialSet.
  • Permissions => Modes

  • PermissionSet => Permissions

  • PermissionsExtractor => keep

  • PermissionReader => PermissionsReader or PermissionsManager (I dislike the term Manager, but it does clear up the confusion "where does it read from? from the request?') or PermissionsStore

  • Credentials => Credential

  • CredentialSet => either keep or Credentials

  • CredentialsExtractor => either keep or CredentialExtractor

  • The new class for adding the WAC-Allow metadata has interface PermissionMetadataWriter and instance WebAclMetadataWriter. But we already have a MetadataWriter interface (that converts metadata to response headers, such as the WacAllowMetadataWriter) which might cause some confusion here. Any other suggestions?
  • PermissionMetadataWriter => PermissionMetadataCollector
  • WebAclMetadataWriter => WebAclMetadataCollector

Comment thread config/ldp/permissions/default.json Resolved
Comment thread src/authentication/CredentialTypes.ts Resolved
Comment thread src/authentication/CredentialTypes.ts Resolved
Comment thread src/authentication/Credentials.ts Resolved
Comment thread src/ldp/auxiliary/AuxiliaryStrategy.ts Resolved
Comment thread src/ldp/auxiliary/AuxiliaryStrategy.ts Resolved
Comment thread src/ldp/operations/Operation.ts Resolved
These readers will determine which permissions
are available for the incoming credentials.
Their results then get combined in a UnionReader
and authorized in a PermissionBasedAuthorizer
This required AuxiliaryStrategy to have a new function
indicating if the auxiliary resource just used its associated resource authorization
or its own.
@jvherweg
jvherweg merged commit 7f8b923 into versions/2.0.0 Sep 28, 2021
@jvherweg
jvherweg deleted the feat/permissions branch September 28, 2021 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver.major Requires a major version bump

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants