Lots of fixes towards making Oauth2 smooth

This commit is contained in:
frikky
2021-08-27 16:02:59 +02:00
parent faa555e26f
commit f213451f9b
6 changed files with 54 additions and 30 deletions
+2 -2
View File
@@ -2,7 +2,7 @@ module shuffle
go 1.13 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 //replace github.com/frikky/kin-openapi => ../../../../git/kin-openapi
@@ -22,7 +22,7 @@ require (
github.com/docker/go-units v0.4.0 // indirect github.com/docker/go-units v0.4.0 // indirect
github.com/elastic/go-elasticsearch/v7 v7.13.1 // indirect github.com/elastic/go-elasticsearch/v7 v7.13.1 // indirect
github.com/frikky/kin-openapi v0.40.0 github.com/frikky/kin-openapi v0.40.0
github.com/frikky/shuffle-shared v0.0.84 github.com/frikky/shuffle-shared v0.0.87
github.com/fsouza/go-dockerclient v1.7.2 github.com/fsouza/go-dockerclient v1.7.2
github.com/ghodss/yaml v1.0.0 github.com/ghodss/yaml v1.0.0
github.com/go-git/go-billy/v5 v5.0.0 github.com/go-git/go-billy/v5 v5.0.0
+1 -1
View File
@@ -15,7 +15,7 @@ const alertStyle = {
justifyContent: 'space-between', justifyContent: 'space-between',
alignItems: 'center', alignItems: 'center',
boxShadow: '0px 2px 2px 2px rgba(0, 0, 0, 0.03)', boxShadow: '0px 2px 2px 2px rgba(0, 0, 0, 0.03)',
width: 400, width: 300,
boxSizing: 'border-box', boxSizing: 'border-box',
zIndex: 100001, zIndex: 100001,
overflow: "hidden", overflow: "hidden",
+20 -15
View File
@@ -57,27 +57,32 @@ const AuthenticationOauth2 = (props) => {
try { try {
var newwin = window.open(url, "", "width=400,height=200") var newwin = window.open(url, "", "width=400,height=200")
console.log(newwin) //console.log(newwin)
setTimeout(() => {
console.log(newwin) var open = true
console.log("CLOSED", newwin.closed) const timer = setInterval(() => {
}, 1000) if (newwin.closed) {
clearInterval(timer);
//alert('"Secure Payment" window closed!');
setTimeout(() => {
console.log(newwin)
console.log("CLOSED", newwin.closed)
if (newwin.closed) {
getAppAuthentication(true, true) getAppAuthentication(true, true)
setTimeout(() => { setTimeout(() => {
console.log("APPAUTH: ", appAuthentication) console.log("APPAUTH: ", appAuthentication)
//{selectedAction.authentication.map(data => {
setAuthenticationModalOpen(false) setAuthenticationModalOpen(false)
saveWorkflow(workflow)
}, 1500) }, 1500)
} }
}, 10000) }, 1000);
//do {
// setTimeout(() => {
// console.log(newwin)
// console.log("CLOSED", newwin.closed)
// if (newwin.closed) {
// open = false
// }
// }, 1000)
//}
//while(open === true)
} catch (e) { } catch (e) {
alert.error("Failed authentication - probably bad credentials. Try again") alert.error("Failed authentication - probably bad credentials. Try again")
setButtonClicked(false) setButtonClicked(false)
+1 -1
View File
@@ -1397,7 +1397,7 @@ const ParsedAction = (props) => {
<Tooltip color="primary" title={"Add authentication option"} placement="top"> <Tooltip color="primary" title={"Add authentication option"} placement="top">
<span> <span>
<Button color="primary" style={{}} fullWidth variant="contained" onClick={() => { <Button color="primary" style={{}} fullWidth variant="contained" onClick={() => {
console.log(authenticationType) //console.log(authenticationType)
setAuthenticationModalOpen(true) setAuthenticationModalOpen(true)
}}> }}>
+2 -2
View File
@@ -156,7 +156,7 @@ const Admin = (props) => {
setTimeout(() => { setTimeout(() => {
getAppAuthentication() getAppAuthentication()
}, 1000) }, 1000)
alert.success("Successfully deleted authentication!") //alert.success("Successfully deleted authentication!")
} }
}), }),
) )
@@ -188,7 +188,7 @@ const Admin = (props) => {
setTimeout(() => { setTimeout(() => {
getSchedules() getSchedules()
}, 1500) }, 1500)
alert.success("Successfully stopped schedule!") //alert.success("Successfully stopped schedule!")
} }
}), }),
) )
+28 -9
View File
@@ -1204,6 +1204,18 @@ const AngularWorkflow = (props) => {
if (item.edited > latest) { if (item.edited > latest) {
latest = item.edited latest = item.edited
selectedAction.selectedAuthentication = item selectedAction.selectedAuthentication = item
for (var key in workflow.actions) {
console.log(workflow.actions[key].app_name)
if (workflow.actions[key].app_name == selectedApp.name) {
console.log("Setting auth at: ", workflow.actions[key], item.id)
workflow.actions[key].selectedAuthentication = item
workflow.actions[key].authentication_id = item.id
//if (workflow.actions[key].selectedAuthentication === undefined || workflow.actions[key].selectedAuthentication === null || workflow.actions[key].selectedAuthentication.length === 0) {
// console.log("Setting inner auth: ", workflow.actions[key])
//}
}
}
} }
} }
} }
@@ -1221,8 +1233,11 @@ const AngularWorkflow = (props) => {
} }
setSelectedAction(selectedAction) setSelectedAction(selectedAction)
setWorkflow(workflow)
saveWorkflow(workflow)
//for (var key in
alert.info("Updated authentication for app?") alert.info("Added and updated authentication!")
} else { } else {
alert.info("No authentication to update") alert.info("No authentication to update")
} }
@@ -2006,8 +2021,8 @@ const AngularWorkflow = (props) => {
setSelectedAction(curaction) setSelectedAction(curaction)
//return //return
} else { } else {
console.log("AUTHENTICATION: ", curapp.authentication) //console.log("AUTHENTICATION: ", curapp.authentication)
console.log(curapp.authentication) //console.log(curapp.authentication)
setAuthenticationType(curapp.authentication.type === "oauth2" && curapp.authentication.redirect_uri !== undefined && curapp.authentication.redirect_uri !== null ? setAuthenticationType(curapp.authentication.type === "oauth2" && curapp.authentication.redirect_uri !== undefined && curapp.authentication.redirect_uri !== null ?
{ {
"type": "oauth2", "type": "oauth2",
@@ -2022,7 +2037,7 @@ const AngularWorkflow = (props) => {
) )
const requiresAuth = curapp.authentication.required //&& ((curapp.authentication.parameters !== undefined && curapp.authentication.parameters !== null) || (curapp.authentication.type === "oauth2" && curapp.authentication.redirect_uri !== undefined && curapp.authentication.redirect_uri !== null)) const requiresAuth = curapp.authentication.required //&& ((curapp.authentication.parameters !== undefined && curapp.authentication.parameters !== null) || (curapp.authentication.type === "oauth2" && curapp.authentication.redirect_uri !== undefined && curapp.authentication.redirect_uri !== null))
console.log("AUTHCHECK: ", requiresAuth) //console.log("AUTHCHECK: ", requiresAuth)
setRequiresAuthentication(requiresAuth) setRequiresAuthentication(requiresAuth)
if (curapp.authentication.required) { if (curapp.authentication.required) {
//console.log("App requires auth.") //console.log("App requires auth.")
@@ -2541,7 +2556,7 @@ const AngularWorkflow = (props) => {
const node = event.target const node = event.target
const nodedata = event.target.data() const nodedata = event.target.data()
if (nodedata.finished === false || (nodedata.id !== undefined && nodedata.is_valid === undefined)) { if (nodedata.finished === false || (nodedata.id !== undefined && nodedata.is_valid === undefined)) {
console.log("RETURNING (NOT ADDING) NODE ADD FOR: ", nodedata) //console.log("RETURNING (NOT ADDING) NODE ADD FOR: ", nodedata)
return return
} }
@@ -7721,16 +7736,20 @@ const AngularWorkflow = (props) => {
copy = copy.src copy = copy.src
} }
console.log("NEW: ", copy)
console.log("NAVIGATOR: ", navigator)
const clipboard = navigator.clipboard const clipboard = navigator.clipboard
if (clipboard === undefined) { if (clipboard === undefined) {
alert.error("Can only copy over HTTPS (port 3443)") alert.error("Can only copy over HTTPS (port 3443)")
return return
} }
navigator.clipboard.writeText(JSON.stringify(copy)) var stringified = JSON.stringify(copy)
if (stringified.startsWith("\"") && stringified.endsWith("\"")) {
stringified = stringified.substring(1, stringified.length-1)
}
console.log("NEW: ", stringified)
navigator.clipboard.writeText(stringified)
copyText.select() copyText.select()
copyText.setSelectionRange(0, 99999) /* For mobile devices */ copyText.setSelectionRange(0, 99999) /* For mobile devices */