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 builder interface #79

Merged
merged 10 commits into from
Feb 1, 2024
Merged

Policy builder interface #79

merged 10 commits into from
Feb 1, 2024

Conversation

samteb
Copy link

@samteb samteb commented Jan 31, 2024

No description provided.

@@ -0,0 +1,434 @@
import { AccountId, Action, Address, Alg, AssetId, Hex } from '@narval/authz-shared'
Copy link
Collaborator

Choose a reason for hiding this comment

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

I liked the result of a policy. I feel it's easier to read and understand without much context than the existing policy builder types on the Armory API.

As a general feed, I would suggest being less verbose on some namings, like for example drop the smurf naming convention. I left comments about this down below.

import { Intents } from '@narval/transaction-request-intent'
import { AccountType } from './domain.type'

enum PolicyRuleType {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
enum PolicyRuleType {
enum Then {

FORBID = 'forbid'
}

enum PolicyCriteriaType {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
enum PolicyCriteriaType {
enum Criterion {


type Wildcard = '*'

type NarvalEntityTypes = 'Narval::User' | 'Narval::UserRole' | 'Narval::UserGroup'
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would definitely call just it EntityType and remove the Narval:: prefix. IMO, they're "reserved" words of the system, and people can't use them. If users want to extend the system, they can come with a prefix of choice.

Suggested change
type NarvalEntityTypes = 'Narval::User' | 'Narval::UserRole' | 'Narval::UserGroup'
type NarvalEntityTypes = 'User' | 'UserRole' | 'UserGroup'

args: AccumulationCondition
}

type PolicyCriteriaArgs =
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
type PolicyCriteriaArgs =
type PolicyCriterion =

}

const examplePermitPolicy: PolicyCriteriaBuilder = {
type: PolicyRuleType.PERMIT,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
type: PolicyRuleType.PERMIT,
then: Then.PERMIT,

const examplePermitPolicy: PolicyCriteriaBuilder = {
type: PolicyRuleType.PERMIT,
name: 'examplePermitPolicy',
criteria: [
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
criteria: [
when: [

]
}
]
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are we supporting OR operator? I know OPA does support it.

If yes, we don't have to implement it today but we need a plan.

criteria: PolicyCriteriaType.APPROVALS,
args: [
{
approvalCount: 2,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
approvalCount: 2,
required: 2,

{
approvalCount: 2,
countPrincipal: false,
approvalEntityType: 'Narval::User',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
approvalEntityType: 'Narval::User',
entity: 'User',

approvalCount: 2,
countPrincipal: false,
approvalEntityType: 'Narval::User',
entityIds: ['[email protected]', '[email protected]']
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change

samuel added 2 commits February 1, 2024 20:34
@samteb samteb merged commit a88624a into main Feb 1, 2024
2 checks passed
@samteb samteb deleted the policy-builder-interface branch February 1, 2024 19:48
mattschoch pushed a commit that referenced this pull request Jun 19, 2024
wcalderipe pushed a commit that referenced this pull request Feb 5, 2025
* syncing wallets and accounts. Addresses takes ages

* add a passthrough to query with no pagination limit

* sync from wallets to known-dests

* Moved composed externalId in a util, fixed queries

* naming and filter correctly for fireblocks

* throw a correct error for anchorage knownDestination failed sync

* removed unused test suite

* add external classification to fireblocks's wallets

* re-deleted unused test file
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