diff --git a/backend/go-app/main.go b/backend/go-app/main.go index 7d6f8455..72fa2ae8 100644 --- a/backend/go-app/main.go +++ b/backend/go-app/main.go @@ -4888,7 +4888,7 @@ func runInit(ctx context.Context) { cloneOptions.ReferenceName = plumbing.ReferenceName(branch) } - log.Printf("Getting apps from %s", url) + log.Printf("[DEBUG] Getting apps from %s", url) r, err := git.Clone(storer, fs, cloneOptions) @@ -5793,20 +5793,28 @@ func initHandlers() { r.HandleFunc("/api/v1/validate_openapi", shuffle.ValidateSwagger).Methods("POST", "OPTIONS") r.HandleFunc("/api/v1/get_openapi/{key}", getOpenapi).Methods("GET", "OPTIONS") - // NEW for 0.8.0 + // Specific triggers + r.HandleFunc("/api/v1/triggers/outlook/register", handleNewOutlookRegister).Methods("GET", "OPTIONS") + r.HandleFunc("/api/v1/triggers/outlook/getFolders", shuffle.HandleGetOutlookFolders).Methods("GET", "OPTIONS") + r.HandleFunc("/api/v1/triggers/outlook/{key}", handleGetSpecificTrigger).Methods("GET", "OPTIONS") + //r.HandleFunc("/api/v1/triggers/outlook/{key}/callback", handleOutlookCallback).Methods("POST", "OPTIONS") + //r.HandleFunc("/api/v1/stats/{key}", handleGetSpecificStats).Methods("GET", "OPTIONS") + + // EVERYTHING below here is NEW for 0.8.0 (written 25.05.2021) r.HandleFunc("/api/v1/workflows/{key}/publish", makeWorkflowPublic).Methods("POST", "OPTIONS") r.HandleFunc("/api/v1/cloud/setup", handleCloudSetup).Methods("POST", "OPTIONS") r.HandleFunc("/api/v1/orgs", shuffle.HandleGetOrgs).Methods("GET", "OPTIONS") r.HandleFunc("/api/v1/orgs/", shuffle.HandleGetOrgs).Methods("GET", "OPTIONS") r.HandleFunc("/api/v1/orgs/{orgId}", shuffle.HandleGetOrg).Methods("GET", "OPTIONS") r.HandleFunc("/api/v1/orgs/{orgId}", shuffle.HandleEditOrg).Methods("POST", "OPTIONS") + // This is a new API that validates if a key has been seen before. // Not sure what the best course of action is for it. r.HandleFunc("/api/v1/orgs/{orgId}/validate_app_values", shuffle.HandleKeyValueCheck).Methods("POST", "OPTIONS") + r.HandleFunc("/api/v1/orgs/{orgId}/get_cache", shuffle.HandleGetCacheKey).Methods("POST", "OPTIONS") + r.HandleFunc("/api/v1/orgs/{orgId}/set_cache", shuffle.HandleSetCacheKey).Methods("POST", "OPTIONS") - //r.HandleFunc("/api/v1/orgs/{orgId}", handleEditOrg).Methods("POST", "OPTIONS") - - // Docker orborus specific + // Docker orborus specific - downloads an image r.HandleFunc("/api/v1/get_docker_image", getDockerImage).Methods("POST", "OPTIONS") //r.HandleFunc("/api/v1/migrate_database", migrateDatabase).Methods("POST", "OPTIONS") @@ -5821,13 +5829,6 @@ func initHandlers() { r.HandleFunc("/api/v1/files/{fileId}", shuffle.HandleDeleteFile).Methods("DELETE", "OPTIONS") r.HandleFunc("/api/v1/files", shuffle.HandleGetFiles).Methods("GET", "OPTIONS") - // Trigger hmm - r.HandleFunc("/api/v1/triggers/outlook/register", handleNewOutlookRegister).Methods("GET", "OPTIONS") - r.HandleFunc("/api/v1/triggers/outlook/getFolders", shuffle.HandleGetOutlookFolders).Methods("GET", "OPTIONS") - r.HandleFunc("/api/v1/triggers/outlook/{key}", handleGetSpecificTrigger).Methods("GET", "OPTIONS") - //r.HandleFunc("/api/v1/triggers/outlook/{key}/callback", handleOutlookCallback).Methods("POST", "OPTIONS") - //r.HandleFunc("/api/v1/stats/{key}", handleGetSpecificStats).Methods("GET", "OPTIONS") - http.Handle("/", r) } diff --git a/backend/tests/cache.sh b/backend/tests/cache.sh new file mode 100644 index 00000000..401d9ce1 --- /dev/null +++ b/backend/tests/cache.sh @@ -0,0 +1,15 @@ +curl -XPOST http://192.168.3.8:5001/api/v1/orgs/6a6a99f5-6630-4f91-88ff-571c9f030ea0/set_cache -H "Authorization: Bearer e663cf93-7f10-4560-bef0-303f14aad982" -d '{ + "workflow_id": "61825389-a125-43a5-9119-97c401e9934b", + "execution_id": "2c8ca1b7-6658-4742-86a1-105c9467702d", + "org_id": "6a6a99f5-6630-4f91-88ff-571c9f030ea0", + "key": "test", + "value": "THIS IS SOME DATA HELLO" +}' + +curl -XPOST http://192.168.3.8:5001/api/v1/orgs/6a6a99f5-6630-4f91-88ff-571c9f030ea0/get_cache -H "Authorization: Bearer e663cf93-7f10-4560-bef0-303f14aad982" -d '{ + "workflow_id": "61825389-a125-43a5-9119-97c401e9934b", + "execution_id": "2c8ca1b7-6658-4742-86a1-105c9467702d", + "org_id": "6a6a99f5-6630-4f91-88ff-571c9f030ea0", + "key": "test" +}' + diff --git a/frontend/src/views/AppCreator.jsx b/frontend/src/views/AppCreator.jsx index 873ec947..0f0981d0 100644 --- a/frontend/src/views/AppCreator.jsx +++ b/frontend/src/views/AppCreator.jsx @@ -871,16 +871,18 @@ const AppCreator = (props) => { } } + + console.log("SECURITYSCHEMES: ", securitySchemes) if (securitySchemes !== undefined) { // FIXME: Should add Oauth2 (Microsoft) and JWT (Wazuh) //console.log("SECURITY: ", securitySchemes) //if (Object.entries(securitySchemes) > 1 && + var newauth = [] for (const [key, value] of Object.entries(securitySchemes)) { if (value.scheme === "bearer") { setAuthenticationOption("Bearer auth") setAuthenticationRequired(true) - break - } else if (value.type === "apiKey") { + } else if (key === "ApiKeyAuth") { setAuthenticationOption("API key") value.in = value.in.charAt(0).toUpperCase() + value.in.slice(1); @@ -893,17 +895,24 @@ const AppCreator = (props) => { console.log("PARAM NAME: ", value.name) setParameterName(value.name) setAuthenticationRequired(true) - break } else if (value.scheme === "basic") { setAuthenticationOption("Basic auth") setAuthenticationRequired(true) - break } else if (value.scheme === "oauth2") { setAuthenticationOption("Oauth2") setAuthenticationRequired(true) - break + } else { + newauth.push({ + "name": key, + "type": value.in, + "example": "", + }) } } + + if (newauth.length > 0) { + setExtraAuth(newauth) + } } if (newActions.length > increaseAmount-1) { @@ -1445,20 +1454,22 @@ const AppCreator = (props) => { //console.log("Name: ", parameterName) const extraKeys =