Skip to content

Commit

Permalink
add mock data
Browse files Browse the repository at this point in the history
  • Loading branch information
samteb committed Feb 14, 2024
1 parent 59ad9ff commit bd968e2
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions apps/authz/src/opa/template/mockData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,64 @@ export const exampleForbidPolicy: Policy = {
export const policies = {
policies: [examplePermitPolicy, exampleForbidPolicy]
}

const metaPermissions = [
Action.CREATE_ORGANIZATION,
Action.CREATE_USER,
Action.UPDATE_USER,
Action.CREATE_CREDENTIAL,
Action.ASSIGN_USER_GROUP,
Action.ASSIGN_WALLET_GROUP,
Action.ASSIGN_USER_WALLET,
Action.DELETE_USER,
Action.REGISTER_WALLET,
Action.CREATE_ADDRESS_BOOK_ACCOUNT,
Action.EDIT_WALLET,
Action.UNASSIGN_WALLET,
Action.REGISTER_TOKENS,
Action.EDIT_USER_GROUP,
Action.DELETE_USER_GROUP,
Action.CREATE_WALLET_GROUP,
Action.DELETE_WALLET_GROUP
]

export const permitMetaPermission: Policy = {
name: 'permitMetaPermission',
when: [
{
criterion: Criterion.CHECK_ACTION,
args: metaPermissions
},
{
criterion: Criterion.CHECK_PRINCIPAL_ROLE,
args: ['admin']
},
{
criterion: Criterion.CHECK_APPROVALS,
args: [
{
approvalCount: 2,
countPrincipal: false,
approvalEntityType: EntityType.UserRole,
entityIds: ['admin']
}
]
}
],
then: Then.PERMIT
}

export const forbidMetaPermission: Policy = {
name: 'forbidMetaPermission',
when: [
{
criterion: Criterion.CHECK_ACTION,
args: metaPermissions
},
{
criterion: Criterion.CHECK_PRINCIPAL_ROLE,
args: ['admin']
}
],
then: Then.FORBID
}

0 comments on commit bd968e2

Please sign in to comment.