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

populate Share -> Grants and Links to the inclusion request #2740

Open
kpsherva opened this issue Jul 10, 2024 · 1 comment
Open

populate Share -> Grants and Links to the inclusion request #2740

kpsherva opened this issue Jul 10, 2024 · 1 comment
Labels
bug Something isn't working stale No activity for more than 60 days.

Comments

@kpsherva
Copy link
Contributor

Use case:

User who receives the access by Access Grant or Secret Link should be able to access also the associated inclusion request of the record:

Screenshot 2024-07-10 at 14 39 34

User who has the edit rights for the draft can see this, and use the link.
Screenshot 2024-07-10 at 14 39 41

Implementation

AccessGrant("edit") and SecretLink("edit")
should be added to permissions in

class RDMRequestsPermissionPolicy:

- can_read = RequestPermissionPolicy.can_read + [guest_token]
+ can_read = RequestPermissionPolicy.can_read + [guest_token, SecretLinks("edit")]
    can_update = RequestPermissionPolicy.can_update + [guest_token]
    can_action_submit = RequestPermissionPolicy.can_action_submit + [guest_token]
    can_action_cancel = RequestPermissionPolicy.can_action_cancel + [guest_token]
    can_create_comment = can_read
    can_update_comment = RequestPermissionPolicy.can_update_comment + [guest_token]
    can_delete_comment = RequestPermissionPolicy.can_delete_comment + [guest_token]

The generators should be made aware of request: https://github.com/inveniosoftware/invenio-rdm-records/blob/master/invenio_rdm_records/services/generators.py#L281

Normally the request reaches the generator as record= kwarg, but in case of the requests it is passed down a little bit differently:
https://github.com/inveniosoftware/invenio-requests/blob/master/invenio_requests/services/requests/service.py#L141 (as request, not record)

in the end, the generator should be able to read the access from record.parent.access, therefore we need to have the record resolved from the request topic somewhere, and there are 3 options:

  1. Request service should pass it down resolved, when checking permissions
  2. We could create another Generator with resolves the record from request["topic"]
  3. We could improve the existing generator to be aware of the request topic (not preferable, it becomes quite record type specific.

Permissions for requests

We need to make the permissions for requests a bit "tighter" to also take into account the type of request

we have currently:

    # Read/update/delete action deals with requests in **multiple states**, and
    # thus must take the request status into account.
    can_read = [
        Status(["created"], [Creator()]),
        Status(
            ["submitted", "deleted", "cancelled", "expired", "accepted", "declined"],
            [Creator(), Receiver()],
        ),
        SystemProcess(),
    ]

But we only want the community-submission to have SecretLink and AccessGrant access added. We don't want other request types to be accessed in this way.

Views

we need also change the record view to be protected by @secret_link_or_login_required() instead of @login_required decorator, otherwise it will ask for login even if user access it by Secret link

Users

User accessing by Secret link will trigger server error, since we are not correctly resolving the UserEntity for anonymous user resolver.
Two solutions for this:

  • dedicated request endpoint without user dashboard (still there will problem with commenting by anonymous)
  • improve the resolver for users to handle anonymous as well

Links

it becomes impossible to use /me/request/<UUID> as the link for View request (see 2nd screenshot) since the request can be now accessed by SecretLink holders, who will not have a dashboard

@kpsherva kpsherva added the bug Something isn't working label Jul 10, 2024
Copy link
Contributor

github-actions bot commented Sep 9, 2024

This issue was automatically marked as stale.

@github-actions github-actions bot added the stale No activity for more than 60 days. label Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale No activity for more than 60 days.
Projects
None yet
Development

No branches or pull requests

1 participant