updated group_created workflow with the addition of KC group, parenting and member role addition from client
This commit is contained in:
parent
ebc33cc20b
commit
f8d1a33a74
|
@ -3,11 +3,11 @@
|
|||
"name" : "group_created",
|
||||
"createBy" : "Marco Lettere",
|
||||
"description": "Handle workflow related to Portal event group_created",
|
||||
"version" : 1,
|
||||
"version" : 2,
|
||||
"ownerEmail" : "marco.lettere@nubisware.com",
|
||||
"inputParameters" : ["user", "group"],
|
||||
"tasks" : [
|
||||
{
|
||||
{
|
||||
"name": "LAMBDA_TASK",
|
||||
"taskReferenceName": "init",
|
||||
"type": "LAMBDA",
|
||||
|
@ -15,7 +15,7 @@
|
|||
"keycloak": "https://accounts.dev.d4science.org/auth/realms/d4science",
|
||||
"keycloak_admin" : "https://accounts.dev.d4science.org/auth/admin/realms/d4science",
|
||||
"clientId" : "${workflow.input.group}",
|
||||
"scriptExpression": "return { 'name' : $.clientId.split('%2F').join('/').split('%2f').join('/')}"
|
||||
"scriptExpression": "var tree = $.clientId.split('%2F'); return { 'tree' : tree, 'child': tree[tree.length-1], 'append' : tree.slice(0,-1).join('/'), 'name' : tree.join('/')}"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -93,7 +93,94 @@
|
|||
"Content-Type" : "application/json"
|
||||
}
|
||||
}
|
||||
}],
|
||||
},
|
||||
{
|
||||
"name" : "pyrest",
|
||||
"taskReferenceName" : "get_back_role_member",
|
||||
"type" : "SIMPLE",
|
||||
"inputParameters" : {
|
||||
"url" : "${create_role_member.output.headers.location}",
|
||||
"method" : "GET",
|
||||
"headers" : {
|
||||
"Authorization" : "Bearer ${authorize.output.body.access_token}",
|
||||
"Accept" : "application/json"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name" : "pyrest",
|
||||
"taskReferenceName" : "create_kc_group",
|
||||
"type" : "SIMPLE",
|
||||
"inputParameters" : {
|
||||
"url" : "${init.input.keycloak_admin}/groups",
|
||||
"body" : {
|
||||
"name" : "${init.output.result.child}"
|
||||
},
|
||||
"method" : "POST",
|
||||
"headers" : {
|
||||
"Authorization" : "Bearer ${authorize.output.body.access_token}",
|
||||
"Content-Type" : "application/json"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name" : "pyrest",
|
||||
"taskReferenceName" : "list_kc_groups",
|
||||
"type" : "SIMPLE",
|
||||
"inputParameters" : {
|
||||
"url" : "${init.input.keycloak_admin}/groups",
|
||||
"method" : "GET",
|
||||
"headers" : {
|
||||
"Authorization" : "Bearer ${authorize.output.body.access_token}",
|
||||
"Accept" : "application/json"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "LAMBDA_TASK",
|
||||
"taskReferenceName": "prepare",
|
||||
"type": "LAMBDA",
|
||||
"inputParameters": {
|
||||
"append" : "${init.output.result.append}",
|
||||
"location" : "${create_kc_group.output.headers.location}",
|
||||
"client_location" : "${create_client.output.headers.location}",
|
||||
"groups" : "${list_kc_groups.output.body}",
|
||||
"scriptExpression": "var newid=$.location.split('/').pop(); var client_id = $.client_location.split('/').pop(); function recurse(inp){for(var i=0;i<inp.length;i++){if(inp[i]['path'] === $.append) return{'group' : inp[i], 'newid' : newid, 'client_id' : client_id}; else{var subr = recurse(inp[i].subGroups); if(subr != null) return {'group' : subr, 'newid' : newid, 'client_id' : client_id};}} return null}; return recurse($.groups)"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name" : "pyrest",
|
||||
"taskReferenceName" : "move_new_kc_group_to_parent",
|
||||
"type" : "SIMPLE",
|
||||
"inputParameters" : {
|
||||
"url" : "${init.input.keycloak_admin}/groups/${prepare.output.result.group.id}/children",
|
||||
"method" : "POST",
|
||||
"body" : {
|
||||
"id" : "${prepare.output.result.newid}"
|
||||
},
|
||||
"headers" : {
|
||||
"Authorization" : "Bearer ${authorize.output.body.access_token}",
|
||||
"Accept" : "application/json",
|
||||
"Content-Type" : "application/json"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name" : "pyrest",
|
||||
"taskReferenceName" : "assign_client_member_role_to_kc_group",
|
||||
"type" : "SIMPLE",
|
||||
"inputParameters" : {
|
||||
"url" : "${init.input.keycloak_admin}/groups/${prepare.output.result.newid}/role-mappings/clients/${prepare.output.result.client_id}",
|
||||
"method" : "POST",
|
||||
"body" : ["${get_back_role_member.output.body}"],
|
||||
"headers" : {
|
||||
"Authorization" : "Bearer ${authorize.output.body.access_token}",
|
||||
"Accept" : "application/json",
|
||||
"Content-Type" : "application/json"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
[{
|
||||
"name" : "pyrest",
|
||||
"taskReferenceName" : "create_role_accountingmanager",
|
||||
|
|
Loading…
Reference in New Issue