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

Policy queries #790

Merged
merged 39 commits into from
Jun 7, 2024
Merged

Policy queries #790

merged 39 commits into from
Jun 7, 2024

Conversation

bplatz
Copy link
Contributor

@bplatz bplatz commented May 30, 2024

New policy-query engine replaces old policy features.

Tests with examples in test/fluree.db.policy.*

Currently, this deprecates the latest f:equals policy, but that could get added back as an interim feature if needed (at the expense of extra query/parsing when policy-wrapping a db).

Key features:

  • Policies are described with queries, anything you can do with query logic can be applied to a policy
  • Policies can be dynamically supplied by the app as plain JSON-LD, they don't need to be stored in the db. If you want to continue to use the db to manage policies, policy groups, and identities you should use the new API fluree/wrap-identity-policy instead of the main fluree/wrap-policy API.
  • Policy query values/variables can be supplied when calling fluree/wrap-policy. These can be any variables used in your policy queries, and allow variables coming from an external system (e.g. identity provider, app) to be used as part of policy criteria
  • fluree/wrap-policy set of APIs (listed below) allow a flag, default-allow? which if true, will allow any data not covered by policy to be allowed. Prior Fluree versions always had all data not covered by policy to be denied - now there is an option.

Policy APIs

  • fluree/wrap-policy - the main API, where you supply the db, policies in JSON-LD, default-allow? flag, and values/variable map. How you assemble your policies is together up to you/your app. Policy queries use the special ?$this variable to evaluate if the user can see the flake/value. If the policy query returns any results, they can see it, if it returns no results they cannot see it.
  • fluree/wrap-identity-policy - most similar to prior Fluree versions, where instead of supplying policies, you supply an identity. We query the DB for the provided identity, and look for the f:policyClass property, which should contain a list of classes. We then query the DB for all policies matching those class(es) to find the full set of policies - and with those in hand, call the standard fluree/wrap-policy but also inject the special values variable ?$identity which is available to your policy queries in addition to the standard ?$this variable.
  • fluree/credential-query - Use instead of fluree/query if your query is wrapped in a verifiable credential. If so, we'll verify the credential, extract the identity and call fluree/wrap-identity-policy to policy-enforce the db. NOTE: fluree/query no longer accepts verifiable credential queries, use this API instead.
  • fluree/credential-history - Like fluree/credential-query, use this for history queries that are wrapped in a verifiable credential. NOTE: fluree/history no longer accepts verifiable credential queries, use this API instead.

bplatz added 30 commits May 29, 2024 14:53
# Conflicts:
#	src/clj/fluree/db/query/fql.cljc
# Conflicts:
#	src/clj/fluree/db/db/json_ld.cljc
…y.query

# Conflicts:
#	src/clj/fluree/db/api/query.cljc
#	src/clj/fluree/db/json_ld/policy.cljc
#	src/clj/fluree/db/query/json_ld/response.cljc
@bplatz bplatz requested a review from a team May 30, 2024 21:11
# Conflicts:
#	src/clj/fluree/db/db/json_ld.cljc
src/clj/fluree/db/json_ld/policy/enforce.cljc Show resolved Hide resolved
src/clj/fluree/db/json_ld/policy/rules.cljc Outdated Show resolved Hide resolved
src/clj/fluree/db/json_ld/policy/enforce.cljc Outdated Show resolved Hide resolved
src/clj/fluree/db/json_ld/policy/query.cljc Outdated Show resolved Hide resolved
src/clj/fluree/db/json_ld/policy/query.cljc Outdated Show resolved Hide resolved
src/clj/fluree/db/json_ld/policy/rules.cljc Show resolved Hide resolved
src/clj/fluree/db/reasoner/owl_datalog.cljc Outdated Show resolved Hide resolved
src/clj/fluree/db/reasoner/owl_datalog.cljc Outdated Show resolved Hide resolved
src/clj/fluree/db/reasoner/owl_datalog.cljc Outdated Show resolved Hide resolved
@bplatz bplatz requested a review from zonotope June 6, 2024 14:52
Copy link
Contributor

@zonotope zonotope left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍁

@bplatz bplatz merged commit f942330 into main Jun 7, 2024
3 checks passed
@bplatz bplatz deleted the feature/policy-query2 branch June 7, 2024 10:48
zonotope added a commit that referenced this pull request Jun 16, 2024
This reverts commit f942330, reversing
changes made to 8f1f988.
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