2021-11-23 12:02:15 +01:00
|
|
|
{
|
|
|
|
"ownerApp" : "Orchestrator",
|
2021-11-23 12:24:41 +01:00
|
|
|
"name" : "add_workspace_client_to_context",
|
2021-11-23 12:02:15 +01:00
|
|
|
"createBy" : "Marco Lettere",
|
|
|
|
"description": "A workspace client is made Member of a context and it's workspace folder is linked to context's shared folder",
|
|
|
|
"version" : 1,
|
|
|
|
"ownerEmail" : "marco.lettere@nubisware.com",
|
|
|
|
"inputParameters" : ["client_id", "context"],
|
|
|
|
"tasks" : [
|
|
|
|
{
|
|
|
|
"name": "LAMBDA_TASK",
|
|
|
|
"taskReferenceName": "init",
|
|
|
|
"type": "LAMBDA",
|
|
|
|
"inputParameters": {
|
|
|
|
"root_vo": "{{ root_vo }}",
|
|
|
|
"storagehub" : "{{ storagehub }}",
|
|
|
|
"keycloak": "{{ keycloak }}/{{ keycloak_realm }}",
|
|
|
|
"keycloak_admin" : "{{ keycloak_admin }}/{{ keycloak_realm }}",
|
|
|
|
"id" : "${workflow.input.client_id}",
|
2021-11-23 12:08:47 +01:00
|
|
|
"ctx" : "${workflow.input.context}",
|
2022-01-25 14:16:15 +01:00
|
|
|
"scriptExpression": "function e(v){ return (v == null || (v.trim && v.trim() === ''))}; if(e($.id) || e($.ctx)) throw('Client ID and Context must not be empty'); else return { encoded_root_vo : encodeURI($.root_vo), encoded_context : $.ctx.replaceAll('/', '%2F')}"
|
2021-11-23 12:02:15 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "pyrest",
|
|
|
|
"taskReferenceName" : "authorize",
|
|
|
|
"type" : "SIMPLE",
|
|
|
|
"inputParameters" : {
|
|
|
|
"url" : "{{ keycloak }}/master/protocol/openid-connect/token",
|
|
|
|
"method" : "POST",
|
|
|
|
"headers" : {
|
|
|
|
"Accept" : "application/json"
|
|
|
|
},
|
|
|
|
"body" : {
|
|
|
|
"client_id" : "orchestrator",
|
|
|
|
"client_secret" : "{{ keycloak_auth_master }}",
|
|
|
|
"grant_type" : "client_credentials"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "fork_join",
|
|
|
|
"taskReferenceName" : "fork1",
|
|
|
|
"type" : "FORK_JOIN",
|
|
|
|
"forkTasks" : [
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"name" : "pyrest",
|
|
|
|
"taskReferenceName" : "lookup_client",
|
|
|
|
"type" : "SIMPLE",
|
|
|
|
"inputParameters" : {
|
|
|
|
"url" : "${init.input.keycloak_admin}/clients",
|
|
|
|
"params" : { "clientId" : "${workflow.input.client_id}"},
|
|
|
|
"method" : "GET",
|
|
|
|
"headers" : {
|
|
|
|
"Authorization" : "Bearer ${authorize.output.body.access_token}",
|
|
|
|
"Accept" : "application/json"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "LAMBDA_TASK",
|
|
|
|
"taskReferenceName": "extract_ws_client",
|
|
|
|
"type": "LAMBDA",
|
|
|
|
"inputParameters": {
|
|
|
|
"client" : "${lookup_client.output.body}",
|
|
|
|
"scriptExpression": "function e(v){ return (v.length === 0)}; if(e($.client)) throw('Workspace client not found'); else return { client : $.client[0], id : $.client[0].id}"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "pyrest",
|
|
|
|
"taskReferenceName" : "get_service_account_user",
|
|
|
|
"type" : "SIMPLE",
|
|
|
|
"inputParameters" : {
|
|
|
|
"url" : "${init.input.keycloak_admin}/clients/${extract_ws_client.output.result.id}/service-account-user",
|
|
|
|
"method" : "GET",
|
|
|
|
"headers" : {
|
|
|
|
"Authorization" : "Bearer ${authorize.output.body.access_token}",
|
|
|
|
"Accept" : "application/json"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"name" : "pyrest",
|
|
|
|
"taskReferenceName" : "lookup_context",
|
|
|
|
"type" : "SIMPLE",
|
|
|
|
"inputParameters" : {
|
|
|
|
"url" : "${init.input.keycloak_admin}/clients",
|
2022-01-26 11:38:26 +01:00
|
|
|
"params" : { "clientId" : "${init.output.result.encoded_context}"},
|
2021-11-23 12:02:15 +01:00
|
|
|
"method" : "GET",
|
|
|
|
"headers" : {
|
|
|
|
"Authorization" : "Bearer ${authorize.output.body.access_token}",
|
|
|
|
"Accept" : "application/json"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "LAMBDA_TASK",
|
|
|
|
"taskReferenceName": "extract_context",
|
|
|
|
"type": "LAMBDA",
|
|
|
|
"inputParameters": {
|
2021-11-23 12:32:46 +01:00
|
|
|
"client" : "${lookup_context.output.body}",
|
2021-11-23 12:35:15 +01:00
|
|
|
"scriptExpression": "function e(v){ return (v.length === 0)}; if(e($.client)) throw('Workspace client not found'); else return { client : $.client[0], id: $.client[0].id }"
|
2021-11-23 12:02:15 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "pyrest",
|
|
|
|
"type" : "SIMPLE",
|
|
|
|
"taskReferenceName": "retrieve_member_role",
|
|
|
|
"inputParameters" : {
|
2021-11-23 12:32:46 +01:00
|
|
|
"url" : "${init.input.keycloak_admin}/clients/${extract_context.output.result.id}/roles/Member",
|
2021-11-23 12:02:15 +01:00
|
|
|
"method" :"GET",
|
|
|
|
"headers" : {
|
|
|
|
"Authorization" : "Bearer ${authorize.output.body.access_token}",
|
|
|
|
"Accept" : "application/json"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "jq_1",
|
|
|
|
"taskReferenceName": "roles_to_assign",
|
|
|
|
"type": "JSON_JQ_TRANSFORM",
|
|
|
|
"inputParameters": {
|
|
|
|
"role": "${retrieve_member_role.output.body}",
|
|
|
|
"queryExpression" : ".role"
|
|
|
|
}
|
2021-11-23 12:58:20 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "LAMBDA_TASK",
|
|
|
|
"taskReferenceName": "shubify_context_name",
|
|
|
|
"type": "LAMBDA",
|
|
|
|
"inputParameters": {
|
|
|
|
"context_name" : "${extract_context.output.result.client.name}",
|
2021-11-23 13:04:50 +01:00
|
|
|
"scriptExpression": "var s = $.context_name; return { shubified_context_name : (s[0] === '/' ? s.replace('/', '') : s).split('/').join('-')}"
|
2021-11-23 12:58:20 +01:00
|
|
|
}
|
2021-11-23 12:07:18 +01:00
|
|
|
}
|
2021-11-23 12:02:15 +01:00
|
|
|
]
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "join",
|
|
|
|
"taskReferenceName": "join1",
|
|
|
|
"type": "JOIN",
|
|
|
|
"joinOn": [
|
|
|
|
"get_service_account_user",
|
2021-11-23 13:04:50 +01:00
|
|
|
"shubify_context_name"
|
2021-11-23 12:02:15 +01:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "pyrest",
|
|
|
|
"type" : "SIMPLE",
|
|
|
|
"taskReferenceName": "assign_member_role",
|
|
|
|
"inputParameters" : {
|
|
|
|
"url" : "${init.input.keycloak_admin}/users/${get_service_account_user.output.body.id}/role-mappings/clients/${retrieve_member_role.output.body.containerId}",
|
|
|
|
"method" :"POST",
|
|
|
|
"headers" : {
|
|
|
|
"Authorization" : "Bearer ${authorize.output.body.access_token}",
|
|
|
|
"Content-Type" : "application/json",
|
|
|
|
"Accept":"application/json"
|
|
|
|
},
|
|
|
|
"body" : "${roles_to_assign.output.resultList}"
|
|
|
|
}
|
2021-11-23 13:23:07 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "pyrest",
|
|
|
|
"taskReferenceName" : "authorize_with_uma_rpt",
|
|
|
|
"type" : "SIMPLE",
|
|
|
|
"inputParameters" : {
|
|
|
|
"url" : "{{ keycloak }}/{{ keycloak_realm }}/protocol/openid-connect/token",
|
|
|
|
"method" : "POST",
|
|
|
|
"headers" : {
|
|
|
|
"Accept" : "application/json"
|
|
|
|
},
|
|
|
|
"body" : {
|
|
|
|
"audience" : "${init.input.root_vo}",
|
|
|
|
"grant_type" : "urn:ietf:params:oauth:grant-type:uma-ticket",
|
|
|
|
"client_id" : "orchestrator",
|
2021-11-23 13:29:56 +01:00
|
|
|
"client_secret" : "{{ keycloak_auth }}"
|
2021-11-23 13:23:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "pyrest",
|
|
|
|
"taskReferenceName" : "workspace_to_vre_folder",
|
|
|
|
"type" : "SIMPLE",
|
|
|
|
"inputParameters" : {
|
|
|
|
"url" : "${init.input.storagehub}/workspace/groups/${shubify_context_name.output.result.shubified_context_name}/users",
|
|
|
|
"method" : "PUT",
|
2022-01-26 11:38:26 +01:00
|
|
|
"expect" : [200, 400, 500],
|
2021-11-23 17:16:20 +01:00
|
|
|
"body" :{
|
2021-11-23 13:23:07 +01:00
|
|
|
"userId" : "${get_service_account_user.output.body.username}"
|
|
|
|
},
|
|
|
|
"headers" : {
|
|
|
|
"Authorization" : "Bearer ${authorize_with_uma_rpt.output.body.access_token}"
|
|
|
|
}
|
|
|
|
}
|
2022-01-31 10:32:44 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"name" : "check_vre_folder_outcome",
|
|
|
|
"taskReferenceName" : "check_vre_folder_outcome",
|
|
|
|
"type" : "DECISION",
|
|
|
|
"inputParameters" :{
|
|
|
|
"previous_outcome" : "${workspace_to_vre_folder.output.status}"
|
|
|
|
},
|
|
|
|
"caseValueParam" : "previous_outcome",
|
|
|
|
"decisionCases" : {
|
|
|
|
"200" : [
|
|
|
|
{
|
|
|
|
"name" : "pyrest",
|
|
|
|
"taskReferenceName" : "make_admin",
|
|
|
|
"type" : "SIMPLE",
|
|
|
|
"inputParameters" : {
|
|
|
|
"url" : "${init.input.storagehub}/workspace/groups/${shubify_context_name.output.result.shubified_context_name}/admins",
|
|
|
|
"method" : "PUT",
|
|
|
|
"expect" : [200, 400, 500],
|
|
|
|
"body" :{
|
|
|
|
"userId" : "${get_service_account_user.output.body.username}"
|
|
|
|
},
|
|
|
|
"headers" : {
|
|
|
|
"Authorization" : "Bearer ${authorize_with_uma_rpt.output.body.access_token}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
2021-11-23 12:02:15 +01:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|