#168: Added prototype of Oauth2 handler with example app

This commit is contained in:
frikky
2021-08-19 00:58:01 +02:00
parent 56185e53e2
commit 53b02e7c46
8 changed files with 235 additions and 19 deletions
+3 -1
View File
@@ -1529,6 +1529,8 @@ class AppBase:
#print(globals())
print("Running liquid with data of length %d" % len(template))
run = Liquid(template, {'mode': 'python'})
# Can't handle self yet (?)
ret = run.render(**globals())
return ret
#try:
@@ -2059,7 +2061,7 @@ class AppBase:
#json_replacement = tmpitem.replace(actualitem[index][0], replacement, 1)
#print("AFTER POST replacement: %s" % json_replacement)
#json_replacement = replacement
json_replacement = replacement
try:
json_replacement = json.loads(replacement)
except json.decoder.JSONDecodeError as e:
+1 -1
View File
@@ -2,7 +2,7 @@ module shuffle
go 1.13
//replace github.com/frikky/shuffle-shared => ../../../../git/shuffle-shared
replace github.com/frikky/shuffle-shared => ../../../../git/shuffle-shared
//replace github.com/frikky/kin-openapi => ../../../../git/kin-openapi
+30 -11
View File
@@ -1552,7 +1552,6 @@ func handleExecution(id string, workflow shuffle.Workflow, request *http.Request
}
workflowExecution.ExecutionVariables = workflow.ExecutionVariables
if len(workflowExecution.Start) == 0 && len(workflowExecution.Workflow.Start) > 0 {
workflowExecution.Start = workflowExecution.Workflow.Start
}
@@ -1621,20 +1620,40 @@ func handleExecution(id string, workflow shuffle.Workflow, request *http.Request
return shuffle.WorkflowExecution{}, fmt.Sprintf("Auth ID %s doesn't exist", action.AuthenticationId), errors.New(fmt.Sprintf("Auth ID %s doesn't exist", action.AuthenticationId))
}
// Rebuild params with the right data. This is to prevent issues on the frontend
newParams := []shuffle.WorkflowAppActionParameter{}
for _, param := range action.Parameters {
if strings.ToLower(curAuth.Type) == "oauth2" {
log.Printf("\n\nShould replace auth parameters!!!\n\n")
for _, authparam := range curAuth.Fields {
if param.Name == authparam.Key {
param.Value = authparam.Value
//log.Printf("Name: %s - value: %s", param.Name, param.Value)
//log.Printf("Name: %s - value: %s\n", param.Name, param.Value)
break
}
for _, param := range curAuth.Fields {
newParams = append(newParams, shuffle.WorkflowAppActionParameter{
Name: param.Key,
Value: param.Value,
})
}
newParams = append(newParams, param)
for _, param := range action.Parameters {
log.Printf("Param: %#v", param)
if param.Configuration {
continue
}
newParams = append(newParams, param)
}
} else {
// Rebuild params with the right data. This is to prevent issues on the frontend
for _, param := range action.Parameters {
for _, authparam := range curAuth.Fields {
if param.Name == authparam.Key {
param.Value = authparam.Value
//log.Printf("Name: %s - value: %s", param.Name, param.Value)
//log.Printf("Name: %s - value: %s\n", param.Name, param.Value)
break
}
}
newParams = append(newParams, param)
}
}
action.Parameters = newParams