Fixed oauth2 loading problems
This commit is contained in:
@@ -471,8 +471,6 @@ const AuthenticationOauth2 = (props) => {
|
||||
url = `${authenticationType.redirect_uri}?client_id=${client_id}&redirect_uri=${redirectUri}&response_type=code&prompt=admin_consent&scope=${resources}&state=${state}&access_type=offline`;
|
||||
}
|
||||
|
||||
console.log("URL: ", url)
|
||||
|
||||
// Force new consent
|
||||
//const url = `${authenticationType.redirect_uri}?client_id=${client_id}&redirect_uri=${redirectUri}&response_type=code&scope=${resources}&prompt=consent&state=${state}&access_type=offline`;
|
||||
|
||||
@@ -525,9 +523,8 @@ const AuthenticationOauth2 = (props) => {
|
||||
//}
|
||||
//while(open === true)
|
||||
} catch (e) {
|
||||
toast(
|
||||
"Failed authentication - probably bad credentials. Try again"
|
||||
);
|
||||
toast("Failed authentication - probably bad credentials. Try again")
|
||||
|
||||
setButtonClicked(false);
|
||||
}
|
||||
|
||||
@@ -807,6 +804,7 @@ const AuthenticationOauth2 = (props) => {
|
||||
|
||||
const defaultValue = data.name === "url" && authenticationType.token_uri !== undefined && authenticationType.token_uri !== null && authenticationType.token_uri.length > 0 && (authenticationType.authorizationUrl === undefined || authenticationType.authorizationUrl === null || authenticationType.authorizationUrl.length === 0) && authenticationType.type === "oauth2-app" ? authenticationType.token_uri : data.value === undefined || data.value === null ? "" : data.value
|
||||
|
||||
|
||||
const fieldname = data.name === "url" && authenticationType.grant_type !== undefined && authenticationType.grant_type !== null && authenticationType.grant_type.length > 0 && authenticationType.type === "oauth2-app" ? "Token URL" : data.name
|
||||
|
||||
return (
|
||||
@@ -1034,6 +1032,10 @@ const AuthenticationOauth2 = (props) => {
|
||||
variant="contained"
|
||||
fullWidth
|
||||
onClick={() => {
|
||||
toast.info("Starting authentication process", {
|
||||
"autoClose": 1500,
|
||||
})
|
||||
|
||||
handleOauth2Request(clientId, clientSecret, oauthUrl, selectedScopes);
|
||||
}}
|
||||
color="primary"
|
||||
|
||||
@@ -1080,16 +1080,19 @@ const AngularWorkflow = (defaultprops) => {
|
||||
})
|
||||
.then((responseJson) => {
|
||||
if (!responseJson.success) {
|
||||
toast("Error: " + responseJson.reason);
|
||||
// Remove the timeout. Has to be clicked
|
||||
toast.error("Error: " + responseJson.reason, {
|
||||
"autoClose": false,
|
||||
})
|
||||
|
||||
} else {
|
||||
if (refresh === true) {
|
||||
getAppAuthentication(true, true, true);
|
||||
getAppAuthentication(true, true, true)
|
||||
} else {
|
||||
getAppAuthentication(true, false);
|
||||
getAppAuthentication(true, false)
|
||||
}
|
||||
|
||||
setAuthenticationModalOpen(false);
|
||||
|
||||
setAuthenticationModalOpen(false)
|
||||
// Needs a refresh with the new authentication..
|
||||
//toast("Successfully saved new app auth")
|
||||
}
|
||||
@@ -7203,73 +7206,47 @@ const AngularWorkflow = (defaultprops) => {
|
||||
toast("Error: name can't be empty");
|
||||
return;
|
||||
}
|
||||
|
||||
var mappedStartnode = "";
|
||||
const alledges = cy.edges().jsons();
|
||||
|
||||
var mappedStartnode = ""
|
||||
const alledges = cy.edges().jsons()
|
||||
if (alledges !== undefined && alledges !== null && alledges.length > 0) {
|
||||
for (let edgekey in alledges) {
|
||||
const tmp = alledges[edgekey];
|
||||
console.log("TMP: ", tmp, tmp.data.source);
|
||||
if (tmp.data.source === trigger.id) {
|
||||
mappedStartnode = tmp.data.target;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (let edgekey in alledges) {
|
||||
const tmp = alledges[edgekey]
|
||||
console.log("TMP: ", tmp, tmp.data.source)
|
||||
if (tmp.data.source === trigger.id) {
|
||||
mappedStartnode = tmp.data.target
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
const data = usecase;
|
||||
if (data.type === "create") toast("Creating pipeline");
|
||||
else toast("stopping pipeline");
|
||||
const url = `${globalUrl}/api/v1/triggers/pipeline`;
|
||||
|
||||
toast("Creating pipeline")
|
||||
const data = usecase
|
||||
const url = `${globalUrl}/api/v1/triggers/pipeline`
|
||||
fetch(url, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
credentials: "include",
|
||||
})
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
credentials: "include",
|
||||
}
|
||||
)
|
||||
.then((response) => {
|
||||
if (response.status !== 200) {
|
||||
console.log("Status not 200 for stream results :O!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return response.json();
|
||||
})
|
||||
.then((responseJson) => {
|
||||
if (!responseJson.success) {
|
||||
toast("Failed to set pipeline: " + responseJson.reason);
|
||||
} else {
|
||||
if (data.type === "create") toast("Pipeline will be created!");
|
||||
else toast("Pipeline will be stopped!");
|
||||
if (!workflow.triggers[triggerindex].parameters) {
|
||||
workflow.triggers[triggerindex].parameters = [];
|
||||
}
|
||||
|
||||
if (workflow.triggers[triggerindex].parameters.length > 0) {
|
||||
workflow.triggers[triggerindex].parameters[0].name = data.name;
|
||||
workflow.triggers[triggerindex].parameters[0].value = data.command;
|
||||
|
||||
trigger.parameters[0].name = data.name;
|
||||
trigger.parameters[0].value = data.command;
|
||||
if (data.type === "stop") {
|
||||
trigger.status = "stopped";
|
||||
workflow.triggers[triggerindex].status = "stopped";
|
||||
} else {
|
||||
trigger.status = "running";
|
||||
workflow.triggers[triggerindex].status = "running";
|
||||
}
|
||||
} else {
|
||||
const newParameter = {
|
||||
name: data.name,
|
||||
value: data.command,
|
||||
};
|
||||
trigger.parameters.push(newParameter);
|
||||
if (data.type === "stop") trigger.status = "stopped";
|
||||
else trigger.status = "running";
|
||||
workflow.triggers[triggerindex] = trigger;
|
||||
}
|
||||
|
||||
toast("Successfully created pipeline");
|
||||
workflow.triggers[triggerindex].status = "running";
|
||||
trigger.status = "running";
|
||||
setSelectedTrigger(trigger);
|
||||
setWorkflow(workflow);
|
||||
console.log("Should set the status to running and save");
|
||||
@@ -7278,9 +7255,9 @@ const AngularWorkflow = (defaultprops) => {
|
||||
})
|
||||
.catch((error) => {
|
||||
//toast(error.toString());
|
||||
console.log("Get pipeline error: ", error.toString());
|
||||
console.log("Get schedule error: ", error.toString());
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
const submitSchedule = (trigger, triggerindex) => {
|
||||
if (trigger.name.length <= 0) {
|
||||
@@ -13679,6 +13656,7 @@ const AngularWorkflow = (defaultprops) => {
|
||||
if (data.Name.toLowerCase() === "cloud") {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<MenuItem
|
||||
key={data.id}
|
||||
@@ -13726,115 +13704,75 @@ const AngularWorkflow = (defaultprops) => {
|
||||
Run HTTP Request
|
||||
</div>
|
||||
*/}
|
||||
<div
|
||||
style={{
|
||||
border: "1px solid rgba(255,255,255,0.3)",
|
||||
borderRadius: theme.palette.borderRadius,
|
||||
padding: 10,
|
||||
cursor: selectedTrigger.status == "running" ? "not-allowed" : "pointer",
|
||||
background:
|
||||
selectedTrigger.status == "running"
|
||||
? "rgba(255, 255, 255, 0.1)"
|
||||
: "transparent",
|
||||
opacity: selectedTrigger.status == "running" ? 0.5 : 1,
|
||||
color:
|
||||
selectedTrigger.status == "running"
|
||||
? "rgba(255, 255, 255, 0.5)"
|
||||
: "inherit",
|
||||
marginTop: 5,
|
||||
}}
|
||||
onClick={() => {
|
||||
if (selectedTrigger.status == "running") {
|
||||
return; // Do nothing if cursor is "not-allowed"
|
||||
}
|
||||
const pipelineConfig = {
|
||||
name: selectedTrigger.label,
|
||||
type: "create",
|
||||
command: "load tcp://0.0.0.0:514 | read syslog | export",
|
||||
environment: selectedTrigger.environment,
|
||||
workflow_id: workflow.id,
|
||||
trigger_id: selectedTrigger.id,
|
||||
};
|
||||
|
||||
submitPipeline(selectedTrigger, selectedTriggerIndex, pipelineConfig);
|
||||
}}
|
||||
>
|
||||
Start Syslog listener
|
||||
</div>
|
||||
<div
|
||||
style={{
|
||||
border: "1px solid rgba(255,255,255,0.3)",
|
||||
borderRadius: theme.palette.borderRadius,
|
||||
padding: 10,
|
||||
cursor: "pointer",
|
||||
marginTop: 5,
|
||||
|
||||
<div
|
||||
style={{
|
||||
border: "1px solid rgba(255,255,255,0.3)",
|
||||
borderRadius: theme.palette.borderRadius,
|
||||
padding: 10,
|
||||
cursor: selectedTrigger.status == "running" ? "not-allowed" : "pointer",
|
||||
background:
|
||||
selectedTrigger.status == "running"
|
||||
? "rgba(255, 255, 255, 0.1)"
|
||||
: "transparent",
|
||||
opacity: selectedTrigger.status == "running" ? 0.5 : 1,
|
||||
color:
|
||||
selectedTrigger.status == "running"
|
||||
? "rgba(255, 255, 255, 0.5)"
|
||||
: "inherit",
|
||||
marginTop: 5,
|
||||
}}
|
||||
onClick={() => {
|
||||
if (selectedTrigger.status == "running") {
|
||||
return;
|
||||
}
|
||||
const pipelineConfig = {
|
||||
name: selectedTrigger.label,
|
||||
type: "create",
|
||||
command:
|
||||
"export --live | sigma /path/to/rules | to http://192.168.86.44:5002/api/v1/hooks/webhook_665ace5f-f27b-496a-a365-6e07eb61078c write lines",
|
||||
environment: selectedTrigger.environment,
|
||||
workflow_id: workflow.id,
|
||||
trigger_id: selectedTrigger.id,
|
||||
};
|
||||
}}
|
||||
onClick={() => {
|
||||
const pipelineConfig = {
|
||||
"name": selectedTrigger.label,
|
||||
"type": "create",
|
||||
"command": "load tcp://0.0.0.0:514 | read syslog | export",
|
||||
"environment": selectedTrigger.environment,
|
||||
}
|
||||
|
||||
submitPipeline(selectedTrigger, selectedTriggerIndex, pipelineConfig);
|
||||
}}
|
||||
>
|
||||
Run Sigma Rulesearch
|
||||
</div>
|
||||
submitPipeline(selectedTrigger, selectedTriggerIndex, pipelineConfig)
|
||||
}}
|
||||
>
|
||||
Start Syslog listener
|
||||
</div>
|
||||
|
||||
<div
|
||||
style={{
|
||||
border: "1px solid rgba(255,255,255,0.3)",
|
||||
borderRadius: theme.palette.borderRadius,
|
||||
padding: 10,
|
||||
cursor: selectedTrigger.status == "running" ? "not-allowed" : "pointer",
|
||||
background:
|
||||
selectedTrigger.status == "running"
|
||||
? "rgba(255, 255, 255, 0.1)"
|
||||
: "transparent",
|
||||
opacity: selectedTrigger.status == "running" ? 0.5 : 1,
|
||||
color:
|
||||
selectedTrigger.status == "running"
|
||||
? "rgba(255, 255, 255, 0.5)"
|
||||
: "inherit",
|
||||
marginTop: 5,
|
||||
}}
|
||||
onClick={() => {
|
||||
if (selectedTrigger.status == "running") {
|
||||
return;
|
||||
}
|
||||
const pipelineConfig = {
|
||||
name: selectedTrigger.label,
|
||||
type: "create",
|
||||
command:
|
||||
"from kafka://1.2.3.4 --topic foo | to http://api.com X-Token:Secret",
|
||||
environment: selectedTrigger.environment,
|
||||
workflow_id: workflow.id,
|
||||
trigger_id: selectedTrigger.id,
|
||||
};
|
||||
<div
|
||||
style={{
|
||||
border: "1px solid rgba(255,255,255,0.3)",
|
||||
borderRadius: theme.palette.borderRadius,
|
||||
padding: 10,
|
||||
cursor: "pointer",
|
||||
marginTop: 5,
|
||||
|
||||
submitPipeline(selectedTrigger, selectedTriggerIndex, pipelineConfig);
|
||||
}}
|
||||
>
|
||||
Follow Kafka Queue
|
||||
</div>
|
||||
}}
|
||||
onClick={() => {
|
||||
const pipelineConfig = {
|
||||
"name": selectedTrigger.label,
|
||||
"type": "create",
|
||||
"command": "export --live | sigma /path/to/rules | to http://192.168.86.44:5002/api/v1/hooks/webhook_665ace5f-f27b-496a-a365-6e07eb61078c write lines",
|
||||
"environment": selectedTrigger.environment,
|
||||
}
|
||||
|
||||
submitPipeline(selectedTrigger, selectedTriggerIndex, pipelineConfig)
|
||||
}}
|
||||
>
|
||||
Run Sigma Rulesearch
|
||||
</div>
|
||||
|
||||
<div
|
||||
style={{
|
||||
border: "1px solid rgba(255,255,255,0.3)",
|
||||
borderRadius: theme.palette.borderRadius,
|
||||
padding: 10,
|
||||
cursor: "pointer",
|
||||
marginTop: 5,
|
||||
|
||||
}}
|
||||
onClick={() => {
|
||||
const pipelineConfig = {
|
||||
"name": selectedTrigger.label,
|
||||
"type": "create",
|
||||
"command": "from kafka://1.2.3.4 --topic foo | to http://api.com X-Token:Secret",
|
||||
"environment": selectedTrigger.environment,
|
||||
}
|
||||
|
||||
submitPipeline(selectedTrigger, selectedTriggerIndex, pipelineConfig)
|
||||
}}
|
||||
>
|
||||
Follow Kafka Queue
|
||||
</div>
|
||||
|
||||
<div
|
||||
style={{
|
||||
@@ -13848,26 +13786,18 @@ const AngularWorkflow = (defaultprops) => {
|
||||
variant="contained"
|
||||
disabled={selectedTrigger.status === "running"}
|
||||
onClick={() => {
|
||||
toast("Select anyone of the parameters to start")
|
||||
toast("Should start. But it doesn't")
|
||||
}}
|
||||
color="primary"
|
||||
>
|
||||
Start
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
style={{ flex: "1" }}
|
||||
variant="contained"
|
||||
disabled={selectedTrigger.status !== "running"}
|
||||
onClick={() => {
|
||||
const pipelineConfig = {
|
||||
name: selectedTrigger.label,
|
||||
type: "stop",
|
||||
environment: selectedTrigger.environment,
|
||||
workflow_id: workflow.id,
|
||||
trigger_id: selectedTrigger.id,
|
||||
};
|
||||
submitPipeline(selectedTrigger, selectedTriggerIndex, pipelineConfig);
|
||||
toast("Should stop triggert")
|
||||
}}
|
||||
color="primary"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user