Skip to content

Add acl support for IDP components - #968

Merged
jvherweg merged 3 commits into
versions/2.0.0from
feat/registration-permission
Oct 7, 2021
Merged

jvherweg merged 3 commits into
versions/2.0.0from
feat/registration-permission

Conversation

@jvherweg

Copy link
Copy Markdown
Member

Draft of potential solution for #924.

This solution works, but still requires integration tests, config cleanup, config documentation and nice commits. But I first wanted to ask for opinions on this before I put in the effort of doing all that.

This is the best solution I can see to have full acl support for the IDP components (specifically registration). We don't really need this though, we could also just have a simpler component where you hardcode a list of WebIDs in the config in a custom IDP permission reader.

How this works:

  • The auth component of the LDP handler has been extracted to a separate handler. The LDP handler no longer exists and is now just a combination of an HTTP parsing handler and an authorization handler.
  • The IDP handler now also has an authorization component. To make sure everything still works, the default http config now adds a permission reader that allows everything.
  • When using the config that restricts the IDP, the standard permission reader (acl) is used.
  • When restricting the IDP a new initializer was added to write a root acl to /idp/. This is required since we can't guarantee there is an acl at /. This is done by generalizing RootInitializer to ContainerInitializer.
  • When restricting the IDP, a new HTTP handler is added in the config that redirects all requests to ^/idp/.*\.acl$ to the LDP handler. This routing is added before the IDP routing. This way acl requests use the normal LDP behaviour, even though their identifier starts with /idp/ (which would otherwise be redirected to the IDP handler).

The main "issue" that I see with this solution is that it requires a bit of complex configuration, and the user will have to make sure their /idp/.acl is configured correctly so nobody else can break the IDP component. But I see this as a specific power user feature so that second part seems less of an issue.

Mainly want to know if this should be finished or if we want to look into a simpler solution.

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

The auth component of the LDP handler has been extracted to a separate handler. The LDP handler no longer exists and is now just a combination of an HTTP parsing handler and an authorization handler.

Woah! That was a big one, but the code makes a lot of sense.

This is also a consequence of Operation being used outside of an LDP context, as we've discussed in another issue.

Great work, great reuse between systems.

Minor nit: I'm not sure about the need for OperationHandler input. (I do like the parameter rename from input to operation in the individual handlers' code though.) Is that needed? Seems like operation handlers should only handle operations, and those operations thus should contain everything.

Comment thread config/http/handler/default.json Resolved
Comment thread config/http/handler/restrict-idp.json Resolved
Comment thread config/restrict-idp.json Resolved
Comment thread src/ldp/operations/OperationHandler.ts Resolved
Comment thread src/server/ParsingHttpHandler.ts Outdated
private readonly errorHandler: ErrorHandler;
private readonly responseWriter: ResponseWriter;
private readonly operationMetadataCollector: OperationMetadataCollector;
private readonly source: OperationHttpHandler;

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.

Maybe rename?

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.

To what? I just the name source here to be similar to how we chain resource stores together (where we also use the source parameter for the nested entry).

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.

operationHandler, I think.

@jvherweg

jvherweg commented Oct 5, 2021

Copy link
Copy Markdown
Member Author

Minor nit: I'm not sure about the need for OperationHandler input. (I do like the parameter rename from input to operation in the individual handlers' code though.) Is that needed? Seems like operation handlers should only handle operations, and those operations thus should contain everything.

The AuthorizingHttpHandler does the authorization step, and then passes the operation to the next OperationHttpHandler in the chain. To have the same behaviour as we currently do for LDP, the next step would be the OperationHandler. To be able to do this, we need to make sure that an OperationHandler takes the same input (or a subset) as an OperationHttpHandler. This is why the signature of the handle function is changed from Operation to { operation: Operation }. Otherwise we would need an LDP handler that simply converts the input { operation: Operation, request: HttpRequest, response: HttpResponse } to Operation.

@jvherweg jvherweg added this to the v2.0.0 milestone Oct 5, 2021
@RubenVerborgh

Copy link
Copy Markdown
Member

To be able to do this, we need to make sure that an OperationHandler takes the same input (or a subset) as an OperationHttpHandler.

Understood; that's a good argument indeed.

Comment thread src/server/ParsingHttpHandler.ts Resolved
Comment thread src/server/ParsingHttpHandler.ts Resolved
This allows easier reuse of certain reoccurring behaviours,
such as authorization.
The AuthenticatedLdpHandler is no longer required
since it is a combination of parsing and authorization.
This did require a small change to the OperationHandler interface.
The initializer can now be used for any container.
The initializer also does not handle the repeat check anymore,
this is now configured with a ConditionalHandler.
@jvherweg
jvherweg force-pushed the feat/registration-permission branch from 84600f7 to 86ab493 Compare October 7, 2021 08:14
@jvherweg
jvherweg marked this pull request as ready for review October 7, 2021 08:14
@jvherweg

jvherweg commented Oct 7, 2021

Copy link
Copy Markdown
Member Author

PR should be finished now. Changes that happened:

  • An initializer for the /.well-known/ container since that is also required for IDP.
  • A new config option (so that's 2 new ones in 2.0) to activate authorization on the IDP. It's made in such a way that it's (mostly?) independent of the actual authorization scheme being used. It just reuses the auth scheme that was chosen with another import.
  • Documentation about the above option warning that the default acl resources there should be updated.

@jvherweg
jvherweg requested a review from RubenVerborgh October 7, 2021 08:21

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

🎉

Let's not forget to update RELEASE_NOTES.md

Comment thread config/identity/README.md Resolved
Comment thread config/identity/access/restricted.json Resolved
Comment thread config/identity/access/restricted.json Resolved
Comment thread config/ldp/authorization/allow-all.json Outdated
"allow": true
},
{
"comment": "No auth resources are required if everything is allowed.",

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.

I didn't fully understand that sentence in isolation.

Configuration has been updated so the IDP requests
also pass through an Authorization component.
A new config option was added to choose
which authorization scheme to use for the IDP.
@jvherweg
jvherweg force-pushed the feat/registration-permission branch from 86ab493 to e651908 Compare October 7, 2021 13:34
@jvherweg
jvherweg merged commit 13c4904 into versions/2.0.0 Oct 7, 2021
@jvherweg
jvherweg deleted the feat/registration-permission branch October 7, 2021 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants