2

I know you can enable Web services for content in Drupal8. You also need to set permissions to make a GET request to content.

But I was wondering if it's possible to set for each node if it can be accessed by GET request or NOT. How can I do this? Because now they can access all nodes ... .

1

1 Answer 1

1

You need to implement a route subscriber and an access handler. Assuming that that should be able to see the nodes via HTML but not via json. If they shouldn't be able to see via HTML either, swap out the node access controller by implementing an alter hook to modify the entity type info. If they should be able to see HTML, go the route subscriber path and alter the rest resource routes to add a new access requirement. Then implement your logic in an the access handler.

1
  • "swap out the node access controller". No. Use a hook and/or use the node grants system. But there really isn't a reason to swap out the whole access control handler.
    – Berdir
    Oct 20, 2014 at 20:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.