modernize group_add/delete and invitation accepted
This commit is contained in:
parent
e0a5c8beac
commit
b1e27b9891
|
@ -2,11 +2,11 @@
|
||||||
workflows:
|
workflows:
|
||||||
# - create-user-add-to-vre
|
# - create-user-add-to-vre
|
||||||
# - group_deleted
|
# - group_deleted
|
||||||
# - user-group_created
|
- user-group_created
|
||||||
- user-group-role_created
|
# - user-group-role_created
|
||||||
# - group_created
|
# - group_created
|
||||||
# - invitation-accepted
|
- invitation-accepted
|
||||||
# - user-group_deleted
|
- user-group_deleted
|
||||||
# - user-group-role_deleted
|
# - user-group-role_deleted
|
||||||
# - delete-user-account
|
# - delete-user-account
|
||||||
# - role_deleted
|
# - role_deleted
|
||||||
|
|
|
@ -8,13 +8,14 @@
|
||||||
"inputParameters" : ["user", "first-name", "last-name", "email", "password"],
|
"inputParameters" : ["user", "first-name", "last-name", "email", "password"],
|
||||||
"tasks" : [
|
"tasks" : [
|
||||||
{
|
{
|
||||||
"name": "LAMBDA_TASK",
|
"name": "INLINE_TASK",
|
||||||
"taskReferenceName": "init",
|
"taskReferenceName": "init",
|
||||||
"type": "LAMBDA",
|
"type": "INLINE",
|
||||||
"inputParameters": {
|
"inputParameters": {
|
||||||
"keycloak": "{{ keycloak }}/{{ keycloak_realm }}",
|
"keycloak": "{{ keycloak }}/{{ keycloak_realm }}",
|
||||||
"keycloak_admin" : "{{ keycloak_admin }}/{{ keycloak_realm }}",
|
"keycloak_admin" : "{{ keycloak_admin }}/{{ keycloak_realm }}",
|
||||||
"scriptExpression": "1"
|
"evaluatorType" : "javascript",
|
||||||
|
"expression": "1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,15 +8,16 @@
|
||||||
"inputParameters" : ["user", "group"],
|
"inputParameters" : ["user", "group"],
|
||||||
"tasks" : [
|
"tasks" : [
|
||||||
{
|
{
|
||||||
"name": "LAMBDA_TASK",
|
"name": "INLINE_TASK",
|
||||||
"taskReferenceName": "init",
|
"taskReferenceName": "init",
|
||||||
"type": "LAMBDA",
|
"type": "INLINE",
|
||||||
"inputParameters": {
|
"inputParameters": {
|
||||||
"keycloak": "{{ keycloak }}/{{ keycloak_realm }}",
|
"keycloak": "{{ keycloak }}/{{ keycloak_realm }}",
|
||||||
"keycloak_admin" : "{{ keycloak_admin }}/{{ keycloak_realm }}",
|
"keycloak_admin" : "{{ keycloak_admin }}/{{ keycloak_realm }}",
|
||||||
"user" : "${workflow.input.user}",
|
"user" : "${workflow.input.user}",
|
||||||
"group" : "${workflow.input.group}",
|
"group" : "${workflow.input.group}",
|
||||||
"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.startsWith('%2F') ? $.group.split('%2F').slice(1) : [$.group]; return { 'tree' : Java.to(path, 'java.lang.Object[]'), 'name' : path.slice(path.length-1)[0], 'search' : encodeURIComponent(path.slice(path.length-1)[0])}"
|
"evaluatorType" : "javascript",
|
||||||
|
"expression": "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.startsWith('%2F') ? $.group.split('%2F').slice(1) : [$.group]; return { 'tree' : Java.to(path, 'java.lang.Object[]'), 'name' : path.slice(path.length-1)[0], 'search' : encodeURIComponent(path.slice(path.length-1)[0])}"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -50,35 +51,37 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "LAMBDA_TASK",
|
"name": "INLINE_TASK",
|
||||||
"taskReferenceName": "select_user",
|
"taskReferenceName": "select_user",
|
||||||
"inputParameters": {
|
"inputParameters": {
|
||||||
"foundusers": "${lookup_user.output.body}",
|
"foundusers": "${lookup_user.output.body}",
|
||||||
"username": "${workflow.input.user}",
|
"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[]')}"
|
"evaluatorType" : "javascript",
|
||||||
|
"expression": "function f(){for(var i=0; i < $.foundusers.length;i++){if($.foundusers[i]['username'] == $.username) return $.foundusers[i]}} f()"
|
||||||
},
|
},
|
||||||
"type": "LAMBDA"
|
"type": "INLINE"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "check_user_existance",
|
"name": "check_user_existance",
|
||||||
"taskReferenceName": "check_user_existance",
|
"taskReferenceName": "check_user_existance",
|
||||||
"inputParameters": {
|
"inputParameters": {
|
||||||
"user": "${select_user.output.result[0]}"
|
"user": "${select_user.output.result[0]}"
|
||||||
},
|
},
|
||||||
"type": "DECISION",
|
"type": "SWITCH",
|
||||||
"caseExpression": "($.user == null ? 'true' : 'false')",
|
"evaluatorType" : "javascript",
|
||||||
"decisionCases": {
|
"expression": "($.user == null ? 'true' : 'false')",
|
||||||
"true": [
|
"decisionCases": {
|
||||||
{
|
"true": [
|
||||||
"name" : "terminate",
|
{
|
||||||
"taskReferenceName" : "terminate_when_no_user",
|
"name" : "terminate",
|
||||||
"type" : "TERMINATE",
|
"taskReferenceName" : "terminate_when_no_user",
|
||||||
"inputParameters" : {
|
"type" : "TERMINATE",
|
||||||
"terminationStatus" : "COMPLETED"
|
"inputParameters" : {
|
||||||
}
|
"terminationStatus" : "COMPLETED"
|
||||||
}
|
}
|
||||||
]
|
}
|
||||||
}
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name" : "pyrest",
|
"name" : "pyrest",
|
||||||
|
@ -93,9 +96,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "LAMBDA_TASK",
|
"name": "INLINE_TASK",
|
||||||
"taskReferenceName": "extract_group",
|
"taskReferenceName": "extract_group",
|
||||||
"type": "LAMBDA",
|
"type": "INLINE",
|
||||||
"inputParameters": {
|
"inputParameters": {
|
||||||
"tree" : "${init.output.result.tree}",
|
"tree" : "${init.output.result.tree}",
|
||||||
"groups" : "${look_up_groups.output.body}",
|
"groups" : "${look_up_groups.output.body}",
|
||||||
|
@ -105,11 +108,12 @@
|
||||||
{
|
{
|
||||||
"name" : "check_group_existance",
|
"name" : "check_group_existance",
|
||||||
"taskReferenceName" : "check_group_existance",
|
"taskReferenceName" : "check_group_existance",
|
||||||
"type" : "DECISION",
|
"type" : "SWITCH",
|
||||||
|
"evaluatorType" : "javascript",
|
||||||
"inputParameters" :{
|
"inputParameters" :{
|
||||||
"group" : "${extract_group.output.result.group}"
|
"group" : "${extract_group.output.result.group}"
|
||||||
},
|
},
|
||||||
"caseExpression": "(($.group != null) ? 'assign' : 'skip')",
|
"expression": "(($.group != null) ? 'assign' : 'skip')",
|
||||||
"decisionCases" : {
|
"decisionCases" : {
|
||||||
"assign" : [
|
"assign" : [
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,15 +8,16 @@
|
||||||
"inputParameters" : ["user", "group"],
|
"inputParameters" : ["user", "group"],
|
||||||
"tasks" : [
|
"tasks" : [
|
||||||
{
|
{
|
||||||
"name": "LAMBDA_TASK",
|
"name": "INLINE_TASK",
|
||||||
"taskReferenceName": "init",
|
"taskReferenceName": "init",
|
||||||
"type": "LAMBDA",
|
"type": "INLINE",
|
||||||
"inputParameters": {
|
"inputParameters": {
|
||||||
"keycloak": "{{ keycloak }}/{{ keycloak_realm }}",
|
"keycloak": "{{ keycloak }}/{{ keycloak_realm }}",
|
||||||
"keycloak_admin" : "{{ keycloak_admin }}/{{ keycloak_realm }}",
|
"keycloak_admin" : "{{ keycloak_admin }}/{{ keycloak_realm }}",
|
||||||
"group" : "${workflow.input.group}",
|
"group" : "${workflow.input.group}",
|
||||||
"user" : "${workflow.input.user}",
|
"user" : "${workflow.input.user}",
|
||||||
"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.startsWith('%2F') ? $.group.split('%2F').slice(1) : [$.group]; return { 'tree' : Java.to(path, 'java.lang.Object[]'), 'name' : path.slice(path.length-1)[0], search : encodeURIComponent(path.slice(path.length-1)[0])}"
|
"evaluatorType" : "javascript",
|
||||||
|
"expression": "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.startsWith('%2F') ? $.group.split('%2F').slice(1) : [$.group]; return { 'tree' : Java.to(path, 'java.lang.Object[]'), 'name' : path.slice(path.length-1)[0], search : encodeURIComponent(path.slice(path.length-1)[0])}"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -49,23 +50,25 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "LAMBDA_TASK",
|
"name": "INLINE_TASK",
|
||||||
"taskReferenceName": "select_user",
|
"taskReferenceName": "select_user",
|
||||||
"inputParameters": {
|
"inputParameters": {
|
||||||
"foundusers": "${lookup_user.output.body}",
|
"foundusers": "${lookup_user.output.body}",
|
||||||
"username": "${workflow.input.user}",
|
"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[]')}"
|
"evaluatorType" : "javascript",
|
||||||
},
|
"expression": "function f(){for(var i=0; i < $.foundusers.length;i++){if($.foundusers[i]['username'] == $.username) return $.foundusers[i]}} f()"
|
||||||
"type": "LAMBDA"
|
},
|
||||||
},
|
"type": "INLINE"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "check_user_existance",
|
"name": "check_user_existance",
|
||||||
"taskReferenceName": "check_user_existance",
|
"taskReferenceName": "check_user_existance",
|
||||||
"inputParameters": {
|
"inputParameters": {
|
||||||
"user": "${select_user.output.result[0]}"
|
"user": "${select_user.output.result}"
|
||||||
},
|
},
|
||||||
"type": "DECISION",
|
"type": "SWITCH",
|
||||||
|
"evaluatorType" : "javascript",
|
||||||
"caseExpression": "($.user == null ? 'true' : 'false')",
|
"caseExpression": "($.user == null ? 'true' : 'false')",
|
||||||
"decisionCases": {
|
"decisionCases": {
|
||||||
"true": [
|
"true": [
|
||||||
|
@ -93,23 +96,25 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "LAMBDA_TASK",
|
"name": "INLINE_TASK",
|
||||||
"taskReferenceName": "extract_group",
|
"taskReferenceName": "extract_group",
|
||||||
"type": "LAMBDA",
|
"type": "INLINE",
|
||||||
"inputParameters": {
|
"inputParameters": {
|
||||||
"tree" : "${init.output.result.tree}",
|
"tree" : "${init.output.result.tree}",
|
||||||
"groups" : "${look_up_groups.output.body}",
|
"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)}"
|
"evaluatorType" : "javascript",
|
||||||
|
"expression": "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" : "check_group_existance",
|
"name" : "check_group_existance",
|
||||||
"taskReferenceName" : "check_group_existance",
|
"taskReferenceName" : "check_group_existance",
|
||||||
"type" : "DECISION",
|
"type" : "SWITCH",
|
||||||
"inputParameters" :{
|
"inputParameters" :{
|
||||||
"group" : "${extract_group.output.result.group}"
|
"group" : "${extract_group.output.result.group}"
|
||||||
},
|
},
|
||||||
"caseExpression": "(($.group != null) ? 'delete' : 'skip')",
|
"evaluatorType" : "javascript",
|
||||||
|
"expression": "(($.group != null) ? 'delete' : 'skip')",
|
||||||
"decisionCases" : {
|
"decisionCases" : {
|
||||||
"skip" : [
|
"skip" : [
|
||||||
{
|
{
|
||||||
|
@ -128,7 +133,7 @@
|
||||||
"taskReferenceName" : "delete_user_from_group",
|
"taskReferenceName" : "delete_user_from_group",
|
||||||
"type" : "SIMPLE",
|
"type" : "SIMPLE",
|
||||||
"inputParameters" : {
|
"inputParameters" : {
|
||||||
"url" : "${init.input.keycloak_admin}/users/${lookup_user.output.body[0].id}/groups/${extract_group.output.result.group.id}",
|
"url" : "${init.input.keycloak_admin}/users/${select_user.output.return.id}/groups/${extract_group.output.result.group.id}",
|
||||||
"method" : "DELETE",
|
"method" : "DELETE",
|
||||||
"headers" : {
|
"headers" : {
|
||||||
"Authorization" : "Bearer ${authorize.output.body.access_token}"
|
"Authorization" : "Bearer ${authorize.output.body.access_token}"
|
||||||
|
@ -166,7 +171,7 @@
|
||||||
{
|
{
|
||||||
"name" : "check_role_existance",
|
"name" : "check_role_existance",
|
||||||
"taskReferenceName" : "check_role_existance",
|
"taskReferenceName" : "check_role_existance",
|
||||||
"type" : "DECISION",
|
"type" : "SWITCH",
|
||||||
"inputParameters" :{
|
"inputParameters" :{
|
||||||
"previous_outcome" : "${get_client_roles.output.status}"
|
"previous_outcome" : "${get_client_roles.output.status}"
|
||||||
},
|
},
|
||||||
|
@ -178,7 +183,7 @@
|
||||||
"taskReferenceName" : "remove_all_roles_from_user",
|
"taskReferenceName" : "remove_all_roles_from_user",
|
||||||
"type" : "SIMPLE",
|
"type" : "SIMPLE",
|
||||||
"inputParameters" : {
|
"inputParameters" : {
|
||||||
"url" : "${init.input.keycloak_admin}/users/${select_user.output.result[0].id}/role-mappings/clients/${lookup_client.output.body[0].id}",
|
"url" : "${init.input.keycloak_admin}/users/${select_user.output.result.id}/role-mappings/clients/${lookup_client.output.body[0].id}",
|
||||||
"expect" : 204,
|
"expect" : 204,
|
||||||
"method" : "DELETE",
|
"method" : "DELETE",
|
||||||
"body" : "${get_client_roles.body}",
|
"body" : "${get_client_roles.body}",
|
||||||
|
|
Loading…
Reference in New Issue