Skip to content

feat: introduce apiExportPolicy resource#401

Draft
OlegErshov wants to merge 10 commits intomainfrom
feat/introduce-apiexport-policy-resource
Draft

feat: introduce apiExportPolicy resource#401
OlegErshov wants to merge 10 commits intomainfrom
feat/introduce-apiexport-policy-resource

Conversation

@OlegErshov
Copy link
Contributor

@OlegErshov OlegErshov commented Mar 10, 2026

On-behalf-of: SAP aleh.yarshou@sap.com

This pr resolves this issue #228

Changes:

  1. Introduce a new APIExportPolicy resource
  2. Introduce a separate cobra command for authorization.platform-mesh.io apiexport.
  3. In implementation was highly used direct client creation, because it's impossible to discover any other logical cluster in which there's no authorization.platform-mesh.io apiBinding and we decided to have authorization.platform-mesh.io apiBinding only in platform-mesh-system workspace

Process function flow:

  1. get provider's cluster ID for tuples creation. For this was used path-aware mcr provider, but direct client creation also might be used.
  2. Remove tuples for deleted expressions from spec
  3. Process expressions one by one in a loop
  4. Parse an expression to get a needed relation (bind, bind_inherited) and workspace path (root:orgs:A) for future client creation
  5. if workspace path is root:orgs:* we need to get cluster ID for every organization workspace, for this we can use allClient and list every accountInfo resource with type=org filter. It's convenient because in accountInfo resource we have all needed information (StoreID, clusterID)
  6. if workspace path is different from root:orgs:*, it means that this is workspace has accountInfo resource. Controller fetches accountInfo resource to get (StoreID, clusterID) information and after creates tuples.

For finalization logic is the same, only tuples are being deleted.

This approach has a downside in extra tuples creation terms.
If somebody creates a resource with these expressions:

:root:orgs:*
:root:orgs:A:*
:root:orgs:A:B
:root:orgs:C

OpenFGA will have a bunch of pointless tuples, because binding permissions were granted for every workspace by this expression :root:orgs:* and the rest of the expressions are redundant. But expressions validation should be addressed on validating webhook level.

On-behalf-of: SAP aleh.yarshou@sap.com
@OlegErshov OlegErshov self-assigned this Mar 10, 2026
On-behalf-of: SAP aleh.yarshou@sap.com
OlegErshov and others added 8 commits March 10, 2026 18:29
On-behalf-of: SAP aleh.yarshou@sap.com
On-behalf-of: SAP aleh.yarshou@sap.com
On-behalf-of: SAP aleh.yarshou@sap.com
On-behalf-of: SAP aleh.yarshou@sap.com
On-behalf-of: SAP aleh.yarshou@sap.com
On-behalf-of: SAP aleh.yarshou@sap.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant