platform icon indicating copy to clipboard operation
platform copied to clipboard

Policy: a shared library used throughout the platform for FQN construction, de-construction, and groupings

Open jakedoublev opened this issue 1 year ago • 3 comments

Background

There is a need to look up attributes (namespaces, definitions, values) by FQNs, and therefore a need to build, store, validate, and tear them down. https://github.com/opentdf/platform/issues/95 added the functionality to store FQNs in the database for lookup FQN -> Policy Attribute Objects, but there are needs in Access PDP, test functions, and the policy services to dynamically build FQNs going from Policy Attribute Objects -> FQNs. This should be common functionality

We should also expose this functionality on the SDK for use in PEPs without a separate import.

Acceptance Criteria

  1. A shared suite of functions is built and consumed throughout to build and tear apart FQNs
  2. Unit tests thoroughly cover them
  3. Existing helper funcs and fmt.Sprintf calls are replaced by the shared functions
  4. The policy GetAttributesByValueFQNs request (consumed by Auth service requests) successfully populates FQNs for all policy objects in response without doing joins with the FQNs table, deferring to composite keys and foreign keys to preserve relational integrity

jakedoublev avatar Apr 04 '24 19:04 jakedoublev

Unfortunately, for the fqn table we're constructing this in SQL, but it seems that there should be two functions that live together. One for Go FQN construction and one for SQL. Should at least reduce the scavenger hunt. main/service/policy/db/attribute_fqn.go#L42

jrschumacher avatar Apr 04 '24 22:04 jrschumacher

I believe there is a requirement for FQN to be a URI; at least for Attributes. If true, this issue will limit the scope of future changes.

ttschampel avatar Apr 04 '24 23:04 ttschampel

Reopening with additional context that we should move validation like what was introduced here into a platform policy lib so that we can share it throughout the platform services and downstream PEPs.

jakedoublev avatar Jul 11 '24 23:07 jakedoublev

This has not been completed for attribute FQNs

jakedoublev avatar May 05 '25 16:05 jakedoublev