Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This feature adds an Access Control Layer on the SDK.
There is an abstract
AccessController
that needs an implementation in the proper context; for which I created one for WordPress on the plugin. It has a check on aCapability
which is also an interface.The
Capability
needs to declare whether its mutative (editing, moving, etc) or destructive (deleting). Every Capability is its own class type which defines its own contexts. To aid in the process there is an abstractDataViewCapability
which requires aDataView
as its context.In the future extra Capabilities can be added without introducing immediate breaking changes to the
Capability
orAccessController
interface. Adding aCapability
class does require allAccessController
instances to do a specific check.This PR also introduces an
AccessControlManager
which defaults to aReadOnlyAccessController
. This will automatically allow any read capabilities, but reject any mutative and destructive ones.The manager is a singleton which manages the current
AccessController
. Meaning the WordPress plugin, for example, will register a specificWordPressAccessController
with the SDK. The manager keeps track of any set controllers, and canreset()
to the previous one(s).Anywhere in the code we need to check for capabilities, we need to call
AccessControllManager::current()
which will return the latest setAccessController
. Then we can check the capability there with its context.