Skip to content

Commit

Permalink
fix: Fixed state resource and state machine validation.
Browse files Browse the repository at this point in the history
  • Loading branch information
jezhiggins committed Mar 21, 2019
1 parent be2aee9 commit d4ca83e
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
"CreateRole": {
"Type": "Task",
"Resource": "module:createRole",
"Parameters": {
"roleId.$": "$.formData.roleId",
"label.$": "$.formData.label",
"description.$": "$.formData.description",
"inherits.$": "$.formData.inherits"
},
"ResultPath": null,
"End": true
}
Expand All @@ -21,4 +27,4 @@
]
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
"Grant": {
"Type": "Task",
"Resource": "module:grantPermission",
"Parameters": {
"roleId.$": "$.formData.roleId",
"stateMachine.$": "$.formData.stateMachineName",
"action.$": "$.formData.action"
},
"ResultPath": null,
"End": true
}
Expand All @@ -21,4 +26,4 @@
]
}
]
}
}
6 changes: 5 additions & 1 deletion lib/components/state-resources/create-role/schema.j2119
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
This document specifies a JSON object called a "PermissionsTree Resource Config".
This document specifies a JSON object called a "New Role".
A New Role MUST have a string field named "roleId".
A New Role MAY have a string field named "label".
A New Role MAY have a string field named "description".
A New Role MAY have a string-array field named "inherits".
6 changes: 3 additions & 3 deletions lib/components/state-resources/grant-permission/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ class GrantPermission {
}

async run (event, context) {
const { roleId, stateMachineName } = event
const { roleId, stateMachine } = event

if (!roleId || !stateMachineName || !event.action) {
if (!roleId || !stateMachine || !event.action) {
return context.sendTaskFailure({
error: 'GrantPermission',
cause: new Error('GrantPermission needs roleId, stateMachineName, and action')
Expand All @@ -17,7 +17,7 @@ class GrantPermission {
const actions = Array.isArray(event.action) ? event.action : [ event.action ]

for (const action of actions) {
await this.rbacAdmin.grantPermission(roleId, 'stateMachine', stateMachineName, action)
await this.rbacAdmin.grantPermission(roleId, 'stateMachine', stateMachine, action)
}

context.sendTaskSuccess()
Expand Down
5 changes: 4 additions & 1 deletion lib/components/state-resources/grant-permission/schema.j2119
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
This document specifies a JSON object called a "PermissionsTree Resource Config".
This document specifies a JSON object called a "Permission Grant".
A Permission Grant MUST have a string field named "roleId".
A Permission Grant MUST have a string field named "stateMachine".
A Permission Grant MUST have a string-array field named "action".
1 change: 0 additions & 1 deletion lib/components/state-resources/list-roles/schema.j2119

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit d4ca83e

Please sign in to comment.