103 lines
2.9 KiB
Django/Jinja
103 lines
2.9 KiB
Django/Jinja
{
|
|
"ownerApp" : "Orchestrator",
|
|
"name" : "group_deleted",
|
|
"createBy" : "Marco Lettere",
|
|
"description": "Handle workflow related to Portal event group_created",
|
|
"version" : 1,
|
|
"ownerEmail" : "m.lettere@gmail.com",
|
|
"inputParameters" : ["user", "group"],
|
|
"tasks" : [
|
|
{
|
|
"name": "INLINE_TASK",
|
|
"taskReferenceName": "init",
|
|
"type": "INLINE",
|
|
"inputParameters": {
|
|
"keycloak": "{{ keycloak }}/{{ keycloak_realm }}",
|
|
"keycloak_admin" : "{{ keycloak_admin }}/{{ keycloak_realm }}",
|
|
"group" : "${workflow.input.group}",
|
|
"evaluatorType" : "javascript",
|
|
"expression" : "function f(){return $.group.split('%2F').join('/')} f()"
|
|
}
|
|
},
|
|
{
|
|
"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" : "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" : "delete_client",
|
|
"type" : "SIMPLE",
|
|
"inputParameters" : {
|
|
"url" : "${init.input.keycloak_admin}/clients/${lookup_client.output.body[0].id}",
|
|
"method" : "DELETE",
|
|
"headers" : {
|
|
"Authorization" : "Bearer ${authorize.output.body.access_token}"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"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": "INLINE_TASK",
|
|
"taskReferenceName": "find_group_by_path",
|
|
"type": "INLINE",
|
|
"inputParameters": {
|
|
"evaluatorType" : "javascript",
|
|
"path" : "${init.output.result}",
|
|
"groups" : "${list_kc_groups.output.body}",
|
|
"expression": "function recurse(inp){for(var i=0;i<inp.length;i++){if(inp[i]['path'] === $.path) return inp[i]; else{var subr = recurse(inp[i].subGroups); if(subr != null) return subr;}} return null}; recurse($.groups)"
|
|
}
|
|
},
|
|
{
|
|
"name" : "pyrest",
|
|
"taskReferenceName" : "delete_group",
|
|
"type" : "SIMPLE",
|
|
"inputParameters" : {
|
|
"url" : "${init.input.keycloak_admin}/groups/${find_group_by_path.output.result.id}",
|
|
"method" : "DELETE",
|
|
"headers" : {
|
|
"Authorization" : "Bearer ${authorize.output.body.access_token}"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|