[PM-35785] Add strongly typed policy data - alternative implementation - #1239
[PM-35785] Add strongly typed policy data - alternative implementation#1239eliykat wants to merge 13 commits into
Conversation
🔍 SDK Breaking Change DetectionSDK Version:
Breaking change detection uses the build of the SDK from this branch, including any incompatibities pre-existing on or merged into this branch. Check the workflow logs to confirm. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1239 +/- ##
==========================================
- Coverage 85.10% 84.90% -0.21%
==========================================
Files 476 477 +1
Lines 65928 65520 -408
==========================================
- Hits 56109 55630 -479
- Misses 9819 9890 +71 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| use bitwarden_send::SendType; | ||
| use bitwarden_vault::UriMatchType; |
There was a problem hiding this comment.
Unclear whether our feature crate can import other feature crates like this. Their crate will almost certainly depend on this crate (to enforce policies in their domain), so it would be a circular dep. Not sure how this could be avoided.
This also causes the uniffi issues.
|
Closed in favour of #1364. |
🎟️ Tracking
📔 Objective
An alternative approach to #1219 based on @quexten 's feedback.
The approach in
main, extended in the previous PR, is to have a registry struct where policy rules can be registered and dynamically looked up at runtime. This was intended to allow other teams to write their own rules and register them in our engine. However, this dynamic runtime behavior was complex and used generics which don't travel over the FFI boundary (an unsolved problem for that approach).This PR takes a step back and tries to reimplement this behavior in a more simple and idiomatic way. It has breaking changes and is missing tests, so it is NOT intended for merge as-is. It demonstrates the end state as if it replaced the current implementation entirely.
Notes:
EnrichedPolicyTypeenum, which also represents eachPolicyType, but carries its own strongly-typed data. This is effectively the "registry", as it has internal match lookups for:PolicyType+ json blob to the enriched typePolicyDefinitionenforcement rulesPolicytrait is nowPolicyDefinition, because it's metadata that 'defines' how a policy works (open to other naming, naming is hard etc.)policy_definitions.rscontains both the per-policy data structs and thePolicyDefinitiontrait implementations. I think it's nice that we can use the data struct to also implement the trait - it keeps per-policy configuration together. (It's this file that could be split up and distributed among other feature teams.)Remaining challenges:
filter(policies, contexts, PolicyType.MasterPassword), they will expect back allMasterPassword-type policies with corresponding data; not policies containing enums of unknown values that they then have to filter/match on. I'm not sure how to reconcile this. It may be a type cast that native code has to do.Todos:
PolicyView.🚨 Breaking Changes