Fixed Oauth2 app auth problems

This commit is contained in:
Frikky
2023-11-15 13:32:24 +01:00
parent 9e1195caf2
commit 06593a2ef3
3 changed files with 49 additions and 58 deletions
@@ -56,13 +56,13 @@ const AuthenticationData = (props) => {
if (!responseJson.success) { if (!responseJson.success) {
toast("Failed to set app auth: " + responseJson.reason); toast("Failed to set app auth: " + responseJson.reason);
} else { } else {
if (getAppAuthentication !== undefined) { if (getAppAuthentication !== undefined) {
getAppAuthentication() getAppAuthentication()
} }
if (setAuthenticationModalOpen !== undefined) { if (setAuthenticationModalOpen !== undefined) {
setAuthenticationModalOpen(false) setAuthenticationModalOpen(false)
} }
// Needs a refresh with the new authentication.. // Needs a refresh with the new authentication..
//toast("Successfully saved new app auth") //toast("Successfully saved new app auth")
+39 -50
View File
@@ -125,7 +125,7 @@ const AuthenticationOauth2 = (props) => {
const allscopes = authenticationType.scope !== undefined ? authenticationType.scope : []; const allscopes = authenticationType.scope !== undefined ? authenticationType.scope : [];
const [selectedScopes, setSelectedScopes] = React.useState(allscopes.length <= 3 ? allscopes : []) const [selectedScopes, setSelectedScopes] = React.useState(allscopes.length > 0 && allscopes.length <= 3 ? [allscopes[0]] : [])
const [manuallyConfigure, setManuallyConfigure] = React.useState( const [manuallyConfigure, setManuallyConfigure] = React.useState(
defaultConfigSet ? false : true defaultConfigSet ? false : true
); );
@@ -301,58 +301,47 @@ const AuthenticationOauth2 = (props) => {
if ((authenticationType.redirect_uri === undefined || authenticationType.redirect_uri === null || authenticationType.redirect_uri.length === 0) && (authenticationType.token_uri !== undefined && authenticationType.token_uri !== null && authenticationType.token_uri.length > 0)) { if ((authenticationType.redirect_uri === undefined || authenticationType.redirect_uri === null || authenticationType.redirect_uri.length === 0) && (authenticationType.token_uri !== undefined && authenticationType.token_uri !== null && authenticationType.token_uri.length > 0)) {
console.log("No redirect URI found, and token URI found. Assuming client credentials flow and saving directly in the database") console.log("No redirect URI found, and token URI found. Assuming client credentials flow and saving directly in the database")
// Find app.configuration=true fields in the app.paramters // Find app.configuration=true fields in the app.paramters
var parsedFields = [{ var parsedFields = [{
"key": "client_id", "key": "client_id",
"value": client_id, "value": client_id,
}, },
{ {
"key": "client_secret", "key": "client_secret",
"value": client_secret, "value": client_secret,
}, },
{ {
"key": "scope", "key": "scope",
"value": scopes.join(","), "value": scopes.join(","),
}, },
{ {
"key": "token_uri", "key": "token_uri",
"value": authenticationType.token_uri, "value": authenticationType.token_uri,
}] }]
// Not necessary yet to do something like this due to not showing the fields anyway const appAuthData = {
/* "label": "OAuth2 for " + selectedApp.name,
if (selectedApp.parameters !== undefined && selectedApp.parameters !== null && selectedApp.parameters.length > 0) { "app": {
"id": selectedApp.id,
for (var i = 0; i < selectedApp.parameters.length; i++) { "name": selectedApp.name,
if (selectedApp.parameters[i].configuration !== true) { "version": selectedApp.version,
continue "large_image": selectedApp.large_image,
}
console.log("Found configuration field: ", selectedApp.parameters[i].key, " with example: ", selectedApp.parameters[i].example)
parsedFields.push({
"key": selectedApp.parameters[i].key,
"value": selectedApp.parameters[i].example,
})
}
}
*/
const appAuthData = {
"label": "OAuth2 for " + selectedApp.name,
"app": {
"id": selectedApp.id,
"name": selectedApp.name,
"version": selectedApp.version,
"large_image": selectedApp.large_image,
}, },
"fields": parsedFields, "fields": parsedFields,
"type": "oauth2-app", "type": "oauth2-app",
"reference_workflow": workflowId, "reference_workflow": workflowId,
} }
setNewAppAuth(appAuthData)
return setNewAppAuth(appAuthData)
// Wait 1 second, then get app auth with update
//
if (getAppAuthentication !== undefined) {
setTimeout(() => {
getAppAuthentication(true, true, true);
}, 1000)
}
return
} }
@@ -463,9 +452,9 @@ const AuthenticationOauth2 = (props) => {
//alert('"Secure Payment" window closed!'); //alert('"Secure Payment" window closed!');
// //
if (getAppAuthentication !== undefined) { if (getAppAuthentication !== undefined) {
getAppAuthentication(true, true, true); getAppAuthentication(true, true, true);
} }
} else { } else {
console.log("Not closed") console.log("Not closed")
} }
+4 -2
View File
@@ -1713,7 +1713,9 @@ const AngularWorkflow = (defaultprops) => {
}) })
.then((responseJson) => { .then((responseJson) => {
if (!responseJson.success) { if (!responseJson.success) {
toast("Failed to start: " + responseJson.reason); //toast("Failed to start: " + responseJson.reason);
toast(responseJson.reason);
//toast.error(responseJson.reason);
setExecutionRunning(false); setExecutionRunning(false);
setExecutionRequestStarted(false); setExecutionRequestStarted(false);
stop(); stop();
@@ -16490,7 +16492,7 @@ const AngularWorkflow = (defaultprops) => {
var newAuthOption = JSON.parse(JSON.stringify(authenticationOption)); var newAuthOption = JSON.parse(JSON.stringify(authenticationOption));
var newFields = []; var newFields = [];
console.log("Fields: ", newAuthOption.fields) console.log("Fields: ", newAuthOption.fields)
for (let authkey in newAuthOption.fields) { for (let authkey in newAuthOption.fields) {
const value = newAuthOption.fields[authkey]; const value = newAuthOption.fields[authkey];
newFields.push({ newFields.push({