rewriting to manage also gateways
This commit is contained in:
parent
2b85ac6e7c
commit
079eaaf63c
|
@ -2,7 +2,7 @@
|
|||
workflows:
|
||||
# - create-user-add-to-vre
|
||||
# - group_deleted
|
||||
# - user-group_created
|
||||
- user-group_created
|
||||
# - user-group-role_created
|
||||
# - group_created
|
||||
# - invitation-accepted
|
||||
|
@ -16,10 +16,10 @@ workflows:
|
|||
# - create_system_service
|
||||
# - delete_system_service
|
||||
# - add_all_system_services_to_vre
|
||||
- create_workspace_client
|
||||
- add_workspace_client_to_context
|
||||
- enable_workspace_clients_for_context
|
||||
- add_workspace_client_to_contexts
|
||||
# - create_workspace_client
|
||||
# - add_workspace_client_to_context
|
||||
# - enable_workspace_clients_for_context
|
||||
# - add_workspace_client_to_contexts
|
||||
keycloak_host: "https://accounts.dev.d4science.org/auth"
|
||||
keycloak: "{{ keycloak_host }}/realms"
|
||||
keycloak_realm: "d4science"
|
||||
|
|
|
@ -14,8 +14,9 @@
|
|||
"inputParameters": {
|
||||
"keycloak": "{{ keycloak }}/{{ keycloak_realm }}",
|
||||
"keycloak_admin" : "{{ keycloak_admin }}/{{ keycloak_realm }}",
|
||||
"user" : "${workflow.input.user}",
|
||||
"group" : "${workflow.input.group}",
|
||||
"scriptExpression": "var path = $.group.split('%2F').slice(1); return { 'tree' : Java.to(path, 'java.lang.Object[]'), 'name' : path.slice(path.length-1)[0]}"
|
||||
"scriptExpression": "function e(v){ return (v == null || (v.trim && v.trim() === ''))}; if(e($.user) || e($.group)) throw('User and Group must not be empty'); var path = $.group.split('%2F').slice(1); return { 'tree' : Java.to(path, 'java.lang.Object[]'), 'name' : path.slice(path.length-1)[0]}"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -49,85 +50,47 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"name": "LAMBDA_TASK",
|
||||
"taskReferenceName": "select_user",
|
||||
"inputParameters": {
|
||||
"foundusers": "${lookup_user.output.body}",
|
||||
"username": "${workflow.input.user}",
|
||||
"scriptExpression": "for(var i=0; i < $.foundusers.length;i++){if($.foundusers[i]['username'] == $.username) return Java.to([$.foundusers[i]], 'java.lang.Object[]')}"
|
||||
},
|
||||
"type": "LAMBDA"
|
||||
},
|
||||
"name": "LAMBDA_TASK",
|
||||
"taskReferenceName": "select_user",
|
||||
"inputParameters": {
|
||||
"foundusers": "${lookup_user.output.body}",
|
||||
"username": "${workflow.input.user}",
|
||||
"scriptExpression": "for(var i=0; i < $.foundusers.length;i++){if($.foundusers[i]['username'] == $.username) return Java.to([$.foundusers[i]], 'java.lang.Object[]')}"
|
||||
},
|
||||
"type": "LAMBDA"
|
||||
},
|
||||
{
|
||||
"name" : "pyrest",
|
||||
"taskReferenceName" : "lookup_client",
|
||||
"type" : "SIMPLE",
|
||||
"inputParameters" : {
|
||||
"url" : "${init.input.keycloak_admin}/clients",
|
||||
"params" : { "clientId" : "${workflow.input.group}"},
|
||||
"method" : "GET",
|
||||
"headers" : {
|
||||
"Authorization" : "Bearer ${authorize.output.body.access_token}",
|
||||
"Accept" : "application/json"
|
||||
}
|
||||
"name" : "pyrest",
|
||||
"taskReferenceName" : "look_up_groups",
|
||||
"type" : "SIMPLE",
|
||||
"inputParameters" : {
|
||||
"url" : "${init.input.keycloak_admin}/groups?search=${init.output.result.name}",
|
||||
"headers" : {
|
||||
"Authorization" : "Bearer ${authorize.output.body.access_token}",
|
||||
"Accept" : "application/json"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "LAMBDA_TASK",
|
||||
"taskReferenceName": "extract_group",
|
||||
"type": "LAMBDA",
|
||||
"inputParameters": {
|
||||
"tree" : "${init.output.result.tree}",
|
||||
"groups" : "${look_up_groups.output.body}",
|
||||
"scriptExpression": "function selectByPath(groups, path, level) { for (var i=0; i < groups.length; i++) {if (groups[i].name === path[level]) {if (level === path.length - 1) return groups[i];return selectByPath(groups[i].subGroups, path, level+1)}} return null; } return { 'group' : selectByPath($.groups, $.tree, 0)}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name" : "pyrest",
|
||||
"taskReferenceName" : "get_client_roles",
|
||||
"type" : "SIMPLE",
|
||||
"inputParameters" : {
|
||||
"url" : "${init.input.keycloak_admin}/clients/${lookup_client.output.body[0].id}/roles",
|
||||
"expect" : [200, 404],
|
||||
"method" : "GET",
|
||||
"headers" : {
|
||||
"Authorization" : "Bearer ${authorize.output.body.access_token}",
|
||||
"Accept" : "application/json"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name" : "check_role_existance",
|
||||
"taskReferenceName" : "check_role_existance",
|
||||
"name" : "check_group_existance",
|
||||
"taskReferenceName" : "check_group_existance",
|
||||
"type" : "DECISION",
|
||||
"inputParameters" :{
|
||||
"previous_outcome" : "${get_client_roles.output.status}"
|
||||
"group" : "${extract_group.output.group}"
|
||||
},
|
||||
"caseValueParam" : "previous_outcome",
|
||||
"caseExpression": "(($.group != null) ? 'assign' : 'skip')",
|
||||
"decisionCases" : {
|
||||
"200" : [
|
||||
{
|
||||
"name": "LAMBDA_TASK",
|
||||
"taskReferenceName": "select_role",
|
||||
"type": "LAMBDA",
|
||||
"inputParameters": {
|
||||
"role": "${workflow.input.role}",
|
||||
"roles" : "${get_client_roles.output.body}",
|
||||
"scriptExpression": "for(var i=0; i < $.roles.length;i++){if($.roles[i]['name'] == 'Member') return Java.to([$.roles[i]], 'java.lang.Object[]')}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name" : "pyrest",
|
||||
"taskReferenceName" : "look_up_groups",
|
||||
"type" : "SIMPLE",
|
||||
"inputParameters" : {
|
||||
"url" : "${init.input.keycloak_admin}/groups?search=${init.output.result.name}",
|
||||
"headers" : {
|
||||
"Authorization" : "Bearer ${authorize.output.body.access_token}",
|
||||
"Accept" : "application/json"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "LAMBDA_TASK",
|
||||
"taskReferenceName": "extract_group",
|
||||
"type": "LAMBDA",
|
||||
"inputParameters": {
|
||||
"tree" : "${init.output.result.tree}",
|
||||
"groups" : "${look_up_groups.output.body}",
|
||||
"scriptExpression": "function selectByPath(groups, path, level) { for (var i=0; i < groups.length; i++) {if (groups[i].name === path[level]) {if (level === path.length - 1) return groups[i];return selectByPath(groups[i].subGroups, path, level+1)}} return null; } return { 'group' : selectByPath($.groups, $.tree, 0)}"
|
||||
}
|
||||
},
|
||||
"assign" : [
|
||||
{
|
||||
"name" : "pyrest",
|
||||
"taskReferenceName" : "assign_user_to_group",
|
||||
|
|
Loading…
Reference in New Issue