-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into feature/forward-creat…
…e-user-request
- Loading branch information
Showing
17 changed files
with
413 additions
and
274 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
import { Injectable } from '@nestjs/common' | ||
import { Policy, SetPolicyRulesRequest } from '../../shared/types/policy.type' | ||
import { OpaService } from '../opa/opa.service' | ||
import { AdminRepository } from '../persistence/repository/admin.repository' | ||
|
||
@Injectable() | ||
export class AdminService { | ||
constructor(private adminRepository: AdminRepository, private opaService: OpaService) {} | ||
constructor(private opaService: OpaService) {} | ||
|
||
async setPolicyRules(payload: SetPolicyRulesRequest): Promise<{ policies: Policy[]; fileId: string }> { | ||
const fileId = this.opaService.generateRegoFile(payload.request.data) | ||
async setPolicyRules(payload: SetPolicyRulesRequest): Promise<{ fileId: string; policies: Policy[] }> { | ||
const { fileId, policies } = this.opaService.buildPoliciesWasm(payload.request.data) | ||
|
||
return { policies: payload.request.data, fileId } | ||
return { fileId, policies } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package main | ||
|
||
metaPermissions = { | ||
"CREATE_ORGANIZATION", | ||
"CREATE_USER", | ||
"UPDATE_USER", | ||
"CREATE_CREDENTIAL", | ||
"ASSIGN_USER_GROUP", | ||
"ASSIGN_WALLET_GROUP", | ||
"ASSIGN_USER_WALLET", | ||
"DELETE_USER", | ||
"REGISTER_WALLET", | ||
"CREATE_ADDRESS_BOOK_ACCOUNT", | ||
"EDIT_WALLET", | ||
"UNASSIGN_WALLET", | ||
"REGISTER_TOKENS", | ||
"EDIT_USER_GROUP", | ||
"DELETE_USER_GROUP", | ||
"CREATE_WALLET_GROUP", | ||
"DELETE_WALLET_GROUP", | ||
} | ||
|
||
permit[{"policyId": "permit-meta-permissions", "policyName": "Permit admin user role for meta permissions"}] = reason { | ||
checkAction(metaPermissions) | ||
checkPrincipalRole({"admin"}) | ||
approvals = checkApprovals([{ | ||
"approvalCount": 2, | ||
"countPrincipal": false, | ||
"approvalEntityType": "Narval::UserRole", | ||
"entityIds": ["root", "admin"], | ||
}]) | ||
reason = { | ||
"type": "permit", | ||
"policyId": "permit-meta-permissions", | ||
"policyName": "Permit admin user role for meta permissions", | ||
"approvalsSatisfied": approvals.approvalsSatisfied, | ||
"approvalsMissing": approvals.approvalsMissing, | ||
} | ||
} | ||
|
||
forbid[{"policyId": "forbid-meta-permissions", "policyName": "Forbid member user role for meta permissions"}] = reason { | ||
checkAction(metaPermissions) | ||
checkPrincipalRole({"member"}) | ||
reason = { | ||
"type": "forbid", | ||
"policyId": "forbid-meta-permissions", | ||
"policyName": "Forbid member user role for meta permissions", | ||
"approvalsSatisfied": [], | ||
"approvalsMissing": [], | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,26 @@ | ||
package main | ||
|
||
permit[{"policyId": "examplePermitPolicy" }] = reason { | ||
checkResourceIntegrity | ||
checkNonceExists | ||
checkAction({"signTransaction"}) | ||
checkPrincipalId({"matt@narval.xyz"}) | ||
checkWalletId({"eip155:eoa:0x90d03a8971a2faa19a9d7ffdcbca28fe826a289b"}) | ||
checkIntentType({"transferNative"}) | ||
checkIntentToken({"eip155:137/slip44:966"}) | ||
checkIntentAmount({"currency":"*","operator":"lte","value":"1000000000000000000"}) | ||
approvals = checkApprovals([{"approvalCount":2,"countPrincipal":false,"approvalEntityType":"Narval::User","entityIds":["aa@narval.xyz","bb@narval.xyz"]}, {"approvalCount":1,"countPrincipal":false,"approvalEntityType":"Narval::UserRole","entityIds":["admin"]}]) | ||
reason = {"type": "permit", "policyId": "examplePermitPolicy", "approvalsSatisfied": approvals.approvalsSatisfied, "approvalsMissing": approvals.approvalsMissing} | ||
} | ||
|
||
forbid[{"policyId": "exampleForbidPolicy" }] = reason { | ||
checkResourceIntegrity | ||
checkNonceExists | ||
checkAction({"signTransaction"}) | ||
checkPrincipalId({"matt@narval.xyz"}) | ||
checkWalletId({"eip155:eoa:0x90d03a8971a2faa19a9d7ffdcbca28fe826a289b"}) | ||
checkIntentType({"transferNative"}) | ||
checkIntentToken({"eip155:137/slip44:966"}) | ||
checkSpendingLimit({"limit":"1000000000000000000","timeWindow":{"type":"rolling","value":43200},"filters":{"tokens":["eip155:137/slip44:966"],"users":["matt@narval.xyz"]}}) | ||
reason = {"type":"forbid","policyId":"exampleForbidPolicy","approvalsSatisfied":[],"approvalsMissing":[]} | ||
} | ||
permit[{"policyId": "examplePermitPolicy"}] = reason { | ||
checkResourceIntegrity | ||
checkNonceExists | ||
checkAction({"signTransaction"}) | ||
checkPrincipalId({"matt@narval.xyz"}) | ||
checkWalletId({"eip155:eoa:0x90d03a8971a2faa19a9d7ffdcbca28fe826a289b"}) | ||
checkIntentType({"transferNative"}) | ||
checkIntentToken({"eip155:137/slip44:966"}) | ||
checkIntentAmount({"currency": "*", "operator": "lte", "value": "1000000000000000000"}) | ||
approvals = checkApprovals([{"approvalCount": 2, "countPrincipal": false, "approvalEntityType": "Narval::User", "entityIds": ["aa@narval.xyz", "bb@narval.xyz"]}, {"approvalCount": 1, "countPrincipal": false, "approvalEntityType": "Narval::UserRole", "entityIds": ["admin"]}]) | ||
reason = {"type": "permit", "policyId": "examplePermitPolicy", "approvalsSatisfied": approvals.approvalsSatisfied, "approvalsMissing": approvals.approvalsMissing} | ||
} | ||
|
||
forbid[{"policyId": "exampleForbidPolicy"}] = reason { | ||
checkResourceIntegrity | ||
checkNonceExists | ||
checkAction({"signTransaction"}) | ||
checkPrincipalId({"matt@narval.xyz"}) | ||
checkWalletId({"eip155:eoa:0x90d03a8971a2faa19a9d7ffdcbca28fe826a289b"}) | ||
checkIntentType({"transferNative"}) | ||
checkIntentToken({"eip155:137/slip44:966"}) | ||
checkSpendingLimit({"limit": "1000000000000000000", "timeWindow": {"type": "rolling", "value": 43200}, "filters": {"tokens": ["eip155:137/slip44:966"], "users": ["matt@narval.xyz"]}}) | ||
reason = {"type": "forbid", "policyId": "exampleForbidPolicy", "approvalsSatisfied": [], "approvalsMissing": []} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.