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

Enable reading other entities during policy evaluation #1933

Open
CodingDoug opened this issue Dec 9, 2022 · 0 comments
Open

Enable reading other entities during policy evaluation #1933

CodingDoug opened this issue Dec 9, 2022 · 0 comments
Assignees

Comments

@CodingDoug
Copy link
Contributor

Suppose I have the following business rule to enforce:

Allow only users whose User entity contains the property admin with a true value to write any Employee entity instance (everyone else gets read-only access).

(Ignore for a moment that this could be implemented with a JWT claim. Sometimes JWT claims are not a feasible solution, or something more dynamic is required since JWTs get reused and don’t refresh immediately.)

Or this:

Disallow the creation of an Employee entity instance if its manager property does not refer to another existing Employee instance.

Or this:

Allow no more than n Contact entity instances per user (where a running count is held in a different per-user entity, and n is held in another entity associated with the user’s payment tier)

These examples are enforcing data integrity and permission using existing entity data as a guide. The developer should be able to read any entity instance in the entire project for use in evaluating the policy.

What I am suggesting here is equivalent to Firestore security rules providing syntax to get an existing document. They only allow single document access by ID (no queries) and only up to 10 max per evaluation. These are reasonable limits with performance and scalability in mind.

There could be a special API for this exposed through ReqContext (rather than the existing TS entity API) that makes the read operation synchronous (so that the policy function need not be async).

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

No branches or pull requests

2 participants