2021-11-22 15:23:59 +01:00
|
|
|
{
|
|
|
|
"ownerApp" : "Orchestrator",
|
2021-11-22 15:31:55 +01:00
|
|
|
"name" : "create_workspace_client",
|
2021-11-22 15:23:59 +01:00
|
|
|
"createBy" : "Marco Lettere",
|
|
|
|
"description": "Create a WorkSpace Client and hook it up to optional list ov contexts. Check or create the settings on Shub.",
|
|
|
|
"version" : 1,
|
|
|
|
"ownerEmail" : "marco.lettere@nubisware.com",
|
|
|
|
"inputParameters" : ["client_id", "client_secret", "description", "context_list"],
|
|
|
|
"tasks" : [
|
|
|
|
{
|
|
|
|
"name": "LAMBDA_TASK",
|
|
|
|
"taskReferenceName": "init",
|
|
|
|
"type": "LAMBDA",
|
|
|
|
"inputParameters": {
|
|
|
|
"root_vo": "{{ root_vo }}",
|
|
|
|
"keycloak": "{{ keycloak }}/{{ keycloak_realm }}",
|
|
|
|
"keycloak_admin" : "{{ keycloak_admin }}/{{ keycloak_realm }}",
|
2021-11-22 17:10:19 +01:00
|
|
|
"storagehub" : "{{ storagehub }}",
|
2021-11-22 15:23:59 +01:00
|
|
|
"id" : "${workflow.input.client_id}",
|
|
|
|
"secret" : "${workflow.input.client_secret}",
|
|
|
|
"description" : "${workflow.input.description}",
|
2021-11-22 16:06:14 +01:00
|
|
|
"scriptExpression": "function e(v){ return (v == null || (v.trim && v.trim() === ''))}; if(e($.id)) throw('Client ID must not be empty'); return { encoded_root_vo : encodeURI($.root_vo), client : { clientId : $.id, description : ($.description ? $.description : $.id), secret : ($.secret ? $.secret : Java.type('java.util.UUID').randomUUID().toString()), rootUrl : '', enabled : true, serviceAccountsEnabled : true, standardFlowEnabled : true, authorizationServicesEnabled : false, publicClient : false, fullScopeAllowed : true, protocol : 'openid-connect'} }"
|
2021-11-22 15:23:59 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"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" : "{{ keycloak_auth }}",
|
|
|
|
"grant_type" : "client_credentials"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "fork_join",
|
|
|
|
"taskReferenceName" : "fork1",
|
|
|
|
"type" : "FORK_JOIN",
|
2021-11-22 15:29:28 +01:00
|
|
|
"forkTasks" : [
|
2021-11-22 15:23:59 +01:00
|
|
|
[
|
|
|
|
{
|
|
|
|
"name" : "pyrest",
|
|
|
|
"taskReferenceName" : "create_client",
|
|
|
|
"type" : "SIMPLE",
|
|
|
|
"inputParameters" : {
|
|
|
|
"url" : "${init.input.keycloak_admin}/clients",
|
|
|
|
"body" : "${init.output.result.client}",
|
|
|
|
"method" : "POST",
|
|
|
|
"headers" : {
|
|
|
|
"Authorization" : "Bearer ${authorize.output.body.access_token}",
|
|
|
|
"Content-Type" : "application/json"
|
|
|
|
}
|
2021-11-22 15:29:28 +01:00
|
|
|
}
|
2021-11-22 15:23:59 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "LAMBDA_TASK",
|
|
|
|
"taskReferenceName": "extract_client_id",
|
|
|
|
"type": "LAMBDA",
|
|
|
|
"inputParameters": {
|
|
|
|
"client_location" : "${create_client.output.headers.location}",
|
2021-11-22 15:55:19 +01:00
|
|
|
"scriptExpression": "var client_id = $.client_location.split('/').pop(); return {'client_resource_id' : client_id}"
|
2021-11-22 15:23:59 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "pyrest",
|
|
|
|
"taskReferenceName" : "get_service_account_user",
|
|
|
|
"type" : "SIMPLE",
|
|
|
|
"inputParameters" : {
|
2021-11-22 15:55:19 +01:00
|
|
|
"url" : "${init.input.keycloak_admin}/clients/${extract_client_id.output.result.client_resource_id}/service-account-user",
|
2021-11-22 15:23:59 +01:00
|
|
|
"method" : "GET",
|
|
|
|
"headers" : {
|
|
|
|
"Authorization" : "Bearer ${authorize.output.body.access_token}",
|
|
|
|
"Accept" : "application/json"
|
|
|
|
}
|
|
|
|
}
|
2021-11-22 15:30:41 +01:00
|
|
|
}
|
2021-11-22 15:23:59 +01:00
|
|
|
],
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"name" : "pyrest",
|
|
|
|
"taskReferenceName" : "get_rootvo",
|
|
|
|
"type" : "SIMPLE",
|
|
|
|
"inputParameters" : {
|
|
|
|
"url" : "${init.input.keycloak_admin}/clients?clientId=${init.output.result.encoded_root_vo}",
|
|
|
|
"method" : "GET",
|
|
|
|
"headers" : {
|
|
|
|
"Authorization" : "Bearer ${authorize.output.body.access_token}",
|
|
|
|
"Accept" : "application/json"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "pyrest",
|
2021-11-22 15:55:19 +01:00
|
|
|
"taskReferenceName" : "get_rootvo_member_role",
|
2021-11-22 15:23:59 +01:00
|
|
|
"type" : "SIMPLE",
|
|
|
|
"inputParameters" : {
|
2021-11-22 15:55:19 +01:00
|
|
|
"url" : "${init.input.keycloak_admin}/clients/${get_rootvo.output.body[0].id}/roles/Member",
|
2021-11-22 15:23:59 +01:00
|
|
|
"method" : "GET",
|
|
|
|
"expect" : [200, 404],
|
|
|
|
"headers" : {
|
|
|
|
"Authorization" : "Bearer ${authorize.output.body.access_token}",
|
|
|
|
"Accept" : "application/json"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
]
|
2021-11-22 15:29:28 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "join",
|
|
|
|
"taskReferenceName": "join1",
|
|
|
|
"type": "JOIN",
|
|
|
|
"joinOn": [
|
|
|
|
"get_service_account_user",
|
2021-11-22 15:58:05 +01:00
|
|
|
"get_rootvo_member_role"
|
2021-11-22 15:29:28 +01:00
|
|
|
]
|
2021-11-22 15:55:19 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "jq_1",
|
|
|
|
"taskReferenceName": "to_array",
|
|
|
|
"type": "JSON_JQ_TRANSFORM",
|
|
|
|
"inputParameters": {
|
|
|
|
"role": "${get_rootvo_member_role.output.body}",
|
|
|
|
"queryExpression" : ".role"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "pyrest",
|
|
|
|
"type" : "SIMPLE",
|
|
|
|
"taskReferenceName": "assign_member_role",
|
|
|
|
"inputParameters" : {
|
2021-11-22 16:20:21 +01:00
|
|
|
"url" : "${init.input.keycloak_admin}/users/${get_service_account_user.output.body.id}/role-mappings/clients/${get_rootvo_member_role.output.body.containerId}",
|
2021-11-22 15:55:19 +01:00
|
|
|
"method" :"POST",
|
|
|
|
"headers" : {
|
|
|
|
"Authorization" : "Bearer ${authorize.output.body.access_token}",
|
|
|
|
"Content-Type" : "application/json",
|
|
|
|
"Accept":"application/json"
|
|
|
|
},
|
|
|
|
"body" : "${to_array.output.resultList}"
|
|
|
|
}
|
2021-11-22 17:10:19 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "pyrest",
|
|
|
|
"taskReferenceName" : "authorize_with_uma_rpt",
|
|
|
|
"type" : "SIMPLE",
|
|
|
|
"inputParameters" : {
|
|
|
|
"url" : "{{ keycloak }}/{{ keycloak_realm }}/protocol/openid-connect/token",
|
|
|
|
"method" : "POST",
|
|
|
|
"headers" : {
|
2021-11-22 17:14:44 +01:00
|
|
|
"Accept" : "application/json"
|
2021-11-22 17:10:19 +01:00
|
|
|
},
|
|
|
|
"body" : {
|
|
|
|
"audience" : "${init.input.root_vo}",
|
|
|
|
"grant_type" : "urn:ietf:params:oauth:grant-type:uma-ticket",
|
|
|
|
"client_id" : "${workflow.input.client_id}",
|
2021-11-22 17:17:56 +01:00
|
|
|
"client_secret" : "${init.output.result.client.secret}"
|
2021-11-22 17:10:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "pyrest",
|
|
|
|
"taskReferenceName" : "check_workspace",
|
|
|
|
"type" : "SIMPLE",
|
|
|
|
"inputParameters" : {
|
|
|
|
"url" : "${init.input.storagehub}/workspace",
|
|
|
|
"method" : "GET",
|
2021-11-22 17:35:29 +01:00
|
|
|
"expect" : [200, 406],
|
2021-11-22 17:10:19 +01:00
|
|
|
"headers" : {
|
|
|
|
"Accept" : "application/json",
|
|
|
|
"Authorization" : "Bearer ${authorize_with_uma_rpt.output.body.access_token}"
|
|
|
|
}
|
|
|
|
}
|
2021-11-22 17:35:29 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "decision",
|
|
|
|
"taskReferenceName": "check_workspace_existance",
|
|
|
|
"inputParameters": {
|
|
|
|
"status": "${check_workspace.output.status}"
|
|
|
|
},
|
|
|
|
"type": "DECISION",
|
|
|
|
"caseExpression": "($.status === 406 ? 'create' : 'exists')",
|
|
|
|
"decisionCases": {
|
|
|
|
"create": [
|
2021-11-22 17:49:32 +01:00
|
|
|
{
|
|
|
|
"name" : "pyrest",
|
|
|
|
"taskReferenceName" : "upgrade_orchestrator_token_to_uma",
|
|
|
|
"type" : "SIMPLE",
|
|
|
|
"inputParameters" : {
|
|
|
|
"url" : "{{ keycloak }}/{{ keycloak_realm }}/protocol/openid-connect/token",
|
|
|
|
"method" : "POST",
|
|
|
|
"headers" : {
|
|
|
|
"Accept" : "application/json",
|
|
|
|
"Authorization" : "Bearer ${authorize.output.body.access_token}"
|
|
|
|
},
|
|
|
|
"body" : {
|
|
|
|
"audience" : "${init.input.root_vo}",
|
|
|
|
"grant_type" : "urn:ietf:params:oauth:grant-type:uma-ticket"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2021-11-22 17:35:29 +01:00
|
|
|
{
|
|
|
|
"name" : "pyrest",
|
|
|
|
"taskReferenceName" : "create_jcr_account",
|
|
|
|
"type" : "SIMPLE",
|
|
|
|
"inputParameters" : {
|
|
|
|
"url" : "${init.input.storagehub}/workspace/users",
|
|
|
|
"method" : "POST",
|
|
|
|
"headers" : {
|
2021-11-22 17:49:32 +01:00
|
|
|
"Authorization" : "Bearer ${upgrade_orchestrator_token_to_uma.output.body.access_token}"
|
2021-11-22 17:35:29 +01:00
|
|
|
},
|
|
|
|
"body" : {
|
|
|
|
"user" : "${get_service_account_user.output.body.username}",
|
|
|
|
"password" : "r3u4h-ewrqwli!_m"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
2021-11-23 16:53:20 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "LAMBDA_TASK",
|
|
|
|
"taskReferenceName": "build_tasks_to_add_ws_client_to_all_contexts",
|
|
|
|
"type": "LAMBDA",
|
|
|
|
"inputParameters": {
|
|
|
|
"context_list" : "${workflow.input.context_list}",
|
|
|
|
"client_id" : "${workflow.input.client_id}",
|
|
|
|
"scriptExpression": "inputs={},tasks=[];for(var i=0;i<$.context_list.length;i++)c=$.context_list[i],tasks.push({name:'sub_workflow_task',type:'SUB_WORKFLOW',taskReferenceName:'add_workspace_client_to_context_'+i, subWorkflowParam:{ name:'add_workspace_client_to_context'}}),inputs['add_workspace_client_to_context_'+i]={client_id : $.client_id, context: c};return {tasks:Java.to(tasks,'java.util.Map[]'),inputs:inputs};"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "fork_dynamic",
|
|
|
|
"type" : "FORK_JOIN_DYNAMIC",
|
|
|
|
"taskReferenceName" : "parallel_build_tasks_to_add_ws_client_to_all_contexts",
|
|
|
|
"inputParameters" : {
|
|
|
|
"tasks" : "${build_tasks_to_add_ws_client_to_all_contexts.output.result.tasks}",
|
|
|
|
"inputs" : "${build_tasks_to_add_ws_client_to_all_contexts.output.result.inputs}"
|
|
|
|
},
|
|
|
|
"dynamicForkTasksParam": "tasks",
|
|
|
|
"dynamicForkTasksInputParamName": "inputs"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "join",
|
|
|
|
"type" : "JOIN",
|
|
|
|
"taskReferenceName" : "join_build_tasks_to_add_ws_client_to_all_contexts"
|
2021-11-22 17:36:31 +01:00
|
|
|
}
|
2021-11-22 15:29:28 +01:00
|
|
|
]
|
2021-11-22 15:23:59 +01:00
|
|
|
}
|
|
|
|
|