modernize group_add/delete and invitation accepted
This commit is contained in:
parent
e0a5c8beac
commit
b1e27b9891
|
@ -2,11 +2,11 @@
|
|||
workflows:
|
||||
# - create-user-add-to-vre
|
||||
# - group_deleted
|
||||
# - user-group_created
|
||||
- user-group-role_created
|
||||
- user-group_created
|
||||
# - user-group-role_created
|
||||
# - group_created
|
||||
# - invitation-accepted
|
||||
# - user-group_deleted
|
||||
- invitation-accepted
|
||||
- user-group_deleted
|
||||
# - user-group-role_deleted
|
||||
# - delete-user-account
|
||||
# - role_deleted
|
||||
|
|
|
@ -8,13 +8,14 @@
|
|||
"inputParameters" : ["user", "first-name", "last-name", "email", "password"],
|
||||
"tasks" : [
|
||||
{
|
||||
"name": "LAMBDA_TASK",
|
||||
"name": "INLINE_TASK",
|
||||
"taskReferenceName": "init",
|
||||
"type": "LAMBDA",
|
||||
"type": "INLINE",
|
||||
"inputParameters": {
|
||||
"keycloak": "{{ keycloak }}/{{ keycloak_realm }}",
|
||||
"keycloak_admin" : "{{ keycloak_admin }}/{{ keycloak_realm }}",
|
||||
"scriptExpression": "1"
|
||||
"evaluatorType" : "javascript",
|
||||
"expression": "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -8,15 +8,16 @@
|
|||
"inputParameters" : ["user", "group"],
|
||||
"tasks" : [
|
||||
{
|
||||
"name": "LAMBDA_TASK",
|
||||
"name": "INLINE_TASK",
|
||||
"taskReferenceName": "init",
|
||||
"type": "LAMBDA",
|
||||
"type": "INLINE",
|
||||
"inputParameters": {
|
||||
"keycloak": "{{ keycloak }}/{{ keycloak_realm }}",
|
||||
"keycloak_admin" : "{{ keycloak_admin }}/{{ keycloak_realm }}",
|
||||
"user" : "${workflow.input.user}",
|
||||
"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,14 +51,15 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"name": "LAMBDA_TASK",
|
||||
"name": "INLINE_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[]')}"
|
||||
"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",
|
||||
|
@ -65,8 +67,9 @@
|
|||
"inputParameters": {
|
||||
"user": "${select_user.output.result[0]}"
|
||||
},
|
||||
"type": "DECISION",
|
||||
"caseExpression": "($.user == null ? 'true' : 'false')",
|
||||
"type": "SWITCH",
|
||||
"evaluatorType" : "javascript",
|
||||
"expression": "($.user == null ? 'true' : 'false')",
|
||||
"decisionCases": {
|
||||
"true": [
|
||||
{
|
||||
|
@ -93,9 +96,9 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"name": "LAMBDA_TASK",
|
||||
"name": "INLINE_TASK",
|
||||
"taskReferenceName": "extract_group",
|
||||
"type": "LAMBDA",
|
||||
"type": "INLINE",
|
||||
"inputParameters": {
|
||||
"tree" : "${init.output.result.tree}",
|
||||
"groups" : "${look_up_groups.output.body}",
|
||||
|
@ -105,11 +108,12 @@
|
|||
{
|
||||
"name" : "check_group_existance",
|
||||
"taskReferenceName" : "check_group_existance",
|
||||
"type" : "DECISION",
|
||||
"type" : "SWITCH",
|
||||
"evaluatorType" : "javascript",
|
||||
"inputParameters" :{
|
||||
"group" : "${extract_group.output.result.group}"
|
||||
},
|
||||
"caseExpression": "(($.group != null) ? 'assign' : 'skip')",
|
||||
"expression": "(($.group != null) ? 'assign' : 'skip')",
|
||||
"decisionCases" : {
|
||||
"assign" : [
|
||||
{
|
||||
|
|
|
@ -8,15 +8,16 @@
|
|||
"inputParameters" : ["user", "group"],
|
||||
"tasks" : [
|
||||
{
|
||||
"name": "LAMBDA_TASK",
|
||||
"name": "INLINE_TASK",
|
||||
"taskReferenceName": "init",
|
||||
"type": "LAMBDA",
|
||||
"type": "INLINE",
|
||||
"inputParameters": {
|
||||
"keycloak": "{{ keycloak }}/{{ keycloak_realm }}",
|
||||
"keycloak_admin" : "{{ keycloak_admin }}/{{ keycloak_realm }}",
|
||||
"group" : "${workflow.input.group}",
|
||||
"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])}"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -50,22 +51,24 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"name": "LAMBDA_TASK",
|
||||
"name": "INLINE_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[]')}"
|
||||
"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",
|
||||
"taskReferenceName": "check_user_existance",
|
||||
"inputParameters": {
|
||||
"user": "${select_user.output.result[0]}"
|
||||
"user": "${select_user.output.result}"
|
||||
},
|
||||
"type": "DECISION",
|
||||
"type": "SWITCH",
|
||||
"evaluatorType" : "javascript",
|
||||
"caseExpression": "($.user == null ? 'true' : 'false')",
|
||||
"decisionCases": {
|
||||
"true": [
|
||||
|
@ -93,23 +96,25 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"name": "LAMBDA_TASK",
|
||||
"name": "INLINE_TASK",
|
||||
"taskReferenceName": "extract_group",
|
||||
"type": "LAMBDA",
|
||||
"type": "INLINE",
|
||||
"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)}"
|
||||
"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",
|
||||
"taskReferenceName" : "check_group_existance",
|
||||
"type" : "DECISION",
|
||||
"type" : "SWITCH",
|
||||
"inputParameters" :{
|
||||
"group" : "${extract_group.output.result.group}"
|
||||
},
|
||||
"caseExpression": "(($.group != null) ? 'delete' : 'skip')",
|
||||
"evaluatorType" : "javascript",
|
||||
"expression": "(($.group != null) ? 'delete' : 'skip')",
|
||||
"decisionCases" : {
|
||||
"skip" : [
|
||||
{
|
||||
|
@ -128,7 +133,7 @@
|
|||
"taskReferenceName" : "delete_user_from_group",
|
||||
"type" : "SIMPLE",
|
||||
"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",
|
||||
"headers" : {
|
||||
"Authorization" : "Bearer ${authorize.output.body.access_token}"
|
||||
|
@ -166,7 +171,7 @@
|
|||
{
|
||||
"name" : "check_role_existance",
|
||||
"taskReferenceName" : "check_role_existance",
|
||||
"type" : "DECISION",
|
||||
"type" : "SWITCH",
|
||||
"inputParameters" :{
|
||||
"previous_outcome" : "${get_client_roles.output.status}"
|
||||
},
|
||||
|
@ -178,7 +183,7 @@
|
|||
"taskReferenceName" : "remove_all_roles_from_user",
|
||||
"type" : "SIMPLE",
|
||||
"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,
|
||||
"method" : "DELETE",
|
||||
"body" : "${get_client_roles.body}",
|
||||
|
|
Loading…
Reference in New Issue