diff --git a/frontend/src/components/Oauth2Auth.jsx b/frontend/src/components/Oauth2Auth.jsx index 8b9d58e6..6e775652 100755 --- a/frontend/src/components/Oauth2Auth.jsx +++ b/frontend/src/components/Oauth2Auth.jsx @@ -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" diff --git a/frontend/src/views/AngularWorkflow.jsx b/frontend/src/views/AngularWorkflow.jsx index ecaf4e6a..3df13f42 100755 --- a/frontend/src/views/AngularWorkflow.jsx +++ b/frontend/src/views/AngularWorkflow.jsx @@ -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 ( { Run HTTP Request */} -
{ - 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 -
+
{ - 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 -
+ submitPipeline(selectedTrigger, selectedTriggerIndex, pipelineConfig) + }} + > + Start Syslog listener + -
{ - 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, - }; +
- Follow Kafka Queue -
+ }} + 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 +
+ +
{ + 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 +
{ 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 -