{ "ownerApp" : "Orchestrator", "name" : "group_created", "createBy" : "Marco Lettere", "description": "Handle workflow related to Portal event group_created", "version" : 1, "ownerEmail" : "marco.lettere@nubisware.com", "inputParameters" : ["user", "group"], "tasks" : [ { "name": "LAMBDA_TASK", "taskReferenceName": "init", "type": "LAMBDA", "inputParameters": { "keycloak": "{{ keycloak }}", "keycloak_admin" : "{{ keycloak_admin }}", "clientId" : "${workflow.input.group}", "scriptExpression": "var tree = $.clientId.split('%2F'); return { 'tree' : tree, 'child': tree[tree.length-1], 'append' : tree.slice(0,-1).join('/'), 'name' : tree.join('/')}" } }, { "name" : "pyrest", "taskReferenceName" : "authorize", "type" : "SIMPLE", "inputParameters" : { "url" : "${init.input.keycloak}/protocol/openid-connect/token", "method" : "POST", "headers" : { "Accept" : "application/json" }, "body" : { "client_id" : "orchestrator", "client_secret" : "c93501bd-abeb-4228-bc28-afac38877338", "grant_type" : "client_credentials" } } }, { "name" : "pyrest", "taskReferenceName" : "lookup_user", "type" : "SIMPLE", "inputParameters" : { "url" : "${init.input.keycloak_admin}/users?username=${workflow.input.user}", "method" : "GET", "headers" : { "Authorization" : "Bearer ${authorize.output.body.access_token}", "Accept" : "application/json" } } }, { "name" : "pyrest", "taskReferenceName" : "create_client", "type" : "SIMPLE", "inputParameters" : { "url" : "${init.input.keycloak_admin}/clients", "body" : { "clientId": "${init.input.clientId}", "name": "${init.output.result.name}", "description": "Client representation for ${init.output.result.name} context", "rootUrl": "http://localhost${init.output.result.name}", "enabled": true, "serviceAccountsEnabled": true, "standardFlowEnabled": true, "authorizationServicesEnabled": true, "publicClient": false, "protocol": "openid-connect" }, "method" : "POST", "headers" : { "Authorization" : "Bearer ${authorize.output.body.access_token}", "Content-Type" : "application/json" } } }, { "name" : "fork_join", "taskReferenceName" : "fork_role_creation", "type" : "FORK_JOIN", "forkTasks" : [ [{ "name" : "pyrest", "taskReferenceName" : "create_role_member", "type" : "SIMPLE", "inputParameters" : { "url" : "${create_client.output.headers.location}/roles", "body" : { "clientRole" : true, "name" : "Member", "description" : "Simple membership for ${init.output.result.name}" }, "method" : "POST", "headers" : { "Authorization" : "Bearer ${authorize.output.body.access_token}", "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