#26: Fixed frontend app authentication issues
This commit is contained in:
+87
-48
@@ -398,8 +398,6 @@ func makePythoncode(swagger *openapi3.Swagger, name, url, method string, paramet
|
|||||||
verifyAddin,
|
verifyAddin,
|
||||||
)
|
)
|
||||||
|
|
||||||
//log.Println(data)
|
|
||||||
//log.Println(functionname)
|
|
||||||
return functionname, data
|
return functionname, data
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -459,76 +457,105 @@ func generateYaml(swagger *openapi3.Swagger, newmd5 string) (*openapi3.Swagger,
|
|||||||
//log.Printf("%#v", securitySchemes)
|
//log.Printf("%#v", securitySchemes)
|
||||||
|
|
||||||
api.Authentication = Authentication{
|
api.Authentication = Authentication{
|
||||||
Required: true,
|
Required: true,
|
||||||
Parameters: []AuthenticationParams{
|
Parameters: []AuthenticationParams{},
|
||||||
AuthenticationParams{
|
|
||||||
Multiline: false,
|
|
||||||
Required: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used for python code generation lol
|
// Used for python code generation lol
|
||||||
// Not sure how this should work with oauth
|
// Not sure how this should work with oauth
|
||||||
if securitySchemes["BearerAuth"] != nil {
|
if securitySchemes["BearerAuth"] != nil {
|
||||||
api.Authentication.Parameters[0].Value = "BearerAuth"
|
api.Authentication.Parameters = append(api.Authentication.Parameters, AuthenticationParams{
|
||||||
api.Authentication.Parameters[0].Description = securitySchemes["BearerAuth"].Value.Description
|
Name: "apikey",
|
||||||
api.Authentication.Parameters[0].Name = securitySchemes["BearerAuth"].Value.Name
|
Value: "",
|
||||||
api.Authentication.Parameters[0].In = securitySchemes["BearerAuth"].Value.In
|
Example: "******",
|
||||||
api.Authentication.Parameters[0].Schema.Type = securitySchemes["BearerAuth"].Value.Scheme
|
Description: securitySchemes["BearerAuth"].Value.Description,
|
||||||
api.Authentication.Parameters[0].Scheme = securitySchemes["BearerAuth"].Value.Scheme
|
In: securitySchemes["BearerAuth"].Value.In,
|
||||||
|
Scheme: securitySchemes["BearerAuth"].Value.Scheme,
|
||||||
|
Schema: SchemaDefinition{
|
||||||
|
Type: securitySchemes["BearerAuth"].Value.Scheme,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
//log.Printf("HANDLE BEARER AUTH")
|
//log.Printf("HANDLE BEARER AUTH")
|
||||||
extraParameters = append(extraParameters, WorkflowAppActionParameter{
|
extraParameters = append(extraParameters, WorkflowAppActionParameter{
|
||||||
Name: "apikey",
|
Name: "apikey",
|
||||||
Description: "The apikey to use",
|
Description: "The apikey to use",
|
||||||
Multiline: false,
|
Multiline: false,
|
||||||
Required: true,
|
Required: true,
|
||||||
Example: "The API key to use. Space = skip",
|
Example: "The API key to use. Space = skip",
|
||||||
|
Configuration: true,
|
||||||
Schema: SchemaDefinition{
|
Schema: SchemaDefinition{
|
||||||
Type: "string",
|
Type: "string",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
} else if securitySchemes["ApiKeyAuth"] != nil {
|
} else if securitySchemes["ApiKeyAuth"] != nil {
|
||||||
api.Authentication.Parameters[0].Value = "ApiKeyAuth"
|
api.Authentication.Parameters = append(api.Authentication.Parameters, AuthenticationParams{
|
||||||
api.Authentication.Parameters[0].Description = securitySchemes["ApiKeyAuth"].Value.Description
|
Name: "apikey",
|
||||||
api.Authentication.Parameters[0].Name = securitySchemes["ApiKeyAuth"].Value.Name
|
Value: "",
|
||||||
api.Authentication.Parameters[0].In = securitySchemes["ApiKeyAuth"].Value.In
|
Example: "******",
|
||||||
api.Authentication.Parameters[0].Schema.Type = securitySchemes["ApiKeyAuth"].Value.Scheme
|
Description: securitySchemes["ApiKeyAuth"].Value.Description,
|
||||||
api.Authentication.Parameters[0].Scheme = securitySchemes["ApiKeyAuth"].Value.Scheme
|
In: securitySchemes["ApiKeyAuth"].Value.In,
|
||||||
|
Scheme: securitySchemes["ApiKeyAuth"].Value.Scheme,
|
||||||
|
Schema: SchemaDefinition{
|
||||||
|
Type: securitySchemes["ApiKeyAuth"].Value.Scheme,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
//log.Printf("HANDLE APIKEY AUTH")
|
//log.Printf("HANDLE APIKEY AUTH")
|
||||||
extraParameters = append(extraParameters, WorkflowAppActionParameter{
|
extraParameters = append(extraParameters, WorkflowAppActionParameter{
|
||||||
Name: "apikey",
|
Name: "apikey",
|
||||||
Description: "The apikey to use",
|
Description: "The apikey to use",
|
||||||
Multiline: false,
|
Multiline: false,
|
||||||
Required: true,
|
Required: true,
|
||||||
Example: "**********",
|
Example: "**********",
|
||||||
|
Configuration: true,
|
||||||
Schema: SchemaDefinition{
|
Schema: SchemaDefinition{
|
||||||
Type: "string",
|
Type: "string",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
} else if securitySchemes["BasicAuth"] != nil {
|
} else if securitySchemes["BasicAuth"] != nil {
|
||||||
api.Authentication.Parameters[0].Value = "BasicAuth"
|
api.Authentication.Parameters = append(api.Authentication.Parameters, AuthenticationParams{
|
||||||
api.Authentication.Parameters[0].Description = securitySchemes["BasicAuth"].Value.Description
|
|
||||||
api.Authentication.Parameters[0].Name = securitySchemes["BasicAuth"].Value.Name
|
|
||||||
api.Authentication.Parameters[0].In = securitySchemes["BasicAuth"].Value.In
|
|
||||||
api.Authentication.Parameters[0].Schema.Type = securitySchemes["BasicAuth"].Value.Scheme
|
|
||||||
api.Authentication.Parameters[0].Scheme = securitySchemes["BasicAuth"].Value.Scheme
|
|
||||||
extraParameters = append(extraParameters, WorkflowAppActionParameter{
|
|
||||||
Name: "username",
|
Name: "username",
|
||||||
Description: "The username to use",
|
Value: "",
|
||||||
Multiline: false,
|
Example: "username",
|
||||||
Required: true,
|
Description: securitySchemes["BasicAuth"].Value.Description,
|
||||||
Example: "The username to use",
|
In: securitySchemes["BasicAuth"].Value.In,
|
||||||
|
Scheme: securitySchemes["BasicAuth"].Value.Scheme,
|
||||||
|
Schema: SchemaDefinition{
|
||||||
|
Type: securitySchemes["BasicAuth"].Value.Scheme,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
api.Authentication.Parameters = append(api.Authentication.Parameters, AuthenticationParams{
|
||||||
|
Name: "password",
|
||||||
|
Value: "",
|
||||||
|
Example: "*****",
|
||||||
|
Description: securitySchemes["BasicAuth"].Value.Description,
|
||||||
|
In: securitySchemes["BasicAuth"].Value.In,
|
||||||
|
Scheme: securitySchemes["BasicAuth"].Value.Scheme,
|
||||||
|
Schema: SchemaDefinition{
|
||||||
|
Type: securitySchemes["BasicAuth"].Value.Scheme,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
extraParameters = append(extraParameters, WorkflowAppActionParameter{
|
||||||
|
Name: "username",
|
||||||
|
Description: "The username to use",
|
||||||
|
Multiline: false,
|
||||||
|
Required: true,
|
||||||
|
Example: "The username to use",
|
||||||
|
Configuration: true,
|
||||||
Schema: SchemaDefinition{
|
Schema: SchemaDefinition{
|
||||||
Type: "string",
|
Type: "string",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
extraParameters = append(extraParameters, WorkflowAppActionParameter{
|
extraParameters = append(extraParameters, WorkflowAppActionParameter{
|
||||||
Name: "password",
|
Name: "password",
|
||||||
Description: "The password to use",
|
Description: "The password to use",
|
||||||
Multiline: false,
|
Multiline: false,
|
||||||
Required: true,
|
Required: true,
|
||||||
Example: "***********",
|
Example: "***********",
|
||||||
|
Configuration: true,
|
||||||
Schema: SchemaDefinition{
|
Schema: SchemaDefinition{
|
||||||
Type: "string",
|
Type: "string",
|
||||||
},
|
},
|
||||||
@@ -538,11 +565,23 @@ func generateYaml(swagger *openapi3.Swagger, newmd5 string) (*openapi3.Swagger,
|
|||||||
|
|
||||||
// Adds a link parameter if it's not already defined
|
// Adds a link parameter if it's not already defined
|
||||||
if len(api.Link) == 0 {
|
if len(api.Link) == 0 {
|
||||||
extraParameters = append(extraParameters, WorkflowAppActionParameter{
|
api.Authentication.Parameters = append(api.Authentication.Parameters, AuthenticationParams{
|
||||||
Name: "url",
|
Name: "url",
|
||||||
Description: "The URL of the app",
|
Description: "The URL of the app",
|
||||||
Multiline: false,
|
Multiline: false,
|
||||||
Required: true,
|
Required: true,
|
||||||
|
Example: "https://shuffler.io",
|
||||||
|
Schema: SchemaDefinition{
|
||||||
|
Type: "string",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
extraParameters = append(extraParameters, WorkflowAppActionParameter{
|
||||||
|
Name: "url",
|
||||||
|
Description: "The URL of the app",
|
||||||
|
Multiline: false,
|
||||||
|
Required: true,
|
||||||
|
Configuration: true,
|
||||||
Schema: SchemaDefinition{
|
Schema: SchemaDefinition{
|
||||||
Type: "string",
|
Type: "string",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -5954,7 +5954,7 @@ func verifySwagger(resp http.ResponseWriter, request *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Successfully uploaded ZIPFILE for %s", identifier)
|
log.Printf("Successfully stitched ZIPFILE for %s", identifier)
|
||||||
|
|
||||||
// 4. Upload as cloud function - this apikey is specifically for cloud functions rofl
|
// 4. Upload as cloud function - this apikey is specifically for cloud functions rofl
|
||||||
//environmentVariables := map[string]string{
|
//environmentVariables := map[string]string{
|
||||||
|
|||||||
@@ -3445,7 +3445,8 @@ func addAppAuthentication(resp http.ResponseWriter, request *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(appAuth.App.ID) != 36 {
|
// Super basic check
|
||||||
|
if len(appAuth.App.ID) != 36 && len(appAuth.App.ID) != 32 {
|
||||||
log.Printf("Bad ID for app: %s", appAuth.App.ID)
|
log.Printf("Bad ID for app: %s", appAuth.App.ID)
|
||||||
resp.WriteHeader(409)
|
resp.WriteHeader(409)
|
||||||
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "App has to be defined"}`)))
|
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "App has to be defined"}`)))
|
||||||
@@ -3530,7 +3531,7 @@ func getAppAuthentication(resp http.ResponseWriter, request *http.Request) {
|
|||||||
for _, auth := range allAuths {
|
for _, auth := range allAuths {
|
||||||
newAuthField := auth
|
newAuthField := auth
|
||||||
for index, _ := range auth.Fields {
|
for index, _ := range auth.Fields {
|
||||||
newAuthField.Fields[index].Value = ""
|
newAuthField.Fields[index].Value = "auth placeholder (replaced during execution)"
|
||||||
}
|
}
|
||||||
|
|
||||||
newAuth = append(newAuth, newAuthField)
|
newAuth = append(newAuth, newAuthField)
|
||||||
|
|||||||
@@ -1016,11 +1016,13 @@ const Admin = (props) => {
|
|||||||
<Tab label="Environments"/>
|
<Tab label="Environments"/>
|
||||||
<Tab label="Schedules"/>
|
<Tab label="Schedules"/>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
<div style={{marginBottom: 10}}/>
|
<Divider style={{marginTop: 0, marginBottom: 10, backgroundColor: "rgb(91, 96, 100)"}} />
|
||||||
{authenticationView}
|
<div style={{padding: 15}}>
|
||||||
{usersView}
|
{authenticationView}
|
||||||
{environmentView}
|
{usersView}
|
||||||
{schedulesView}
|
{environmentView}
|
||||||
|
{schedulesView}
|
||||||
|
</div>
|
||||||
</Paper>
|
</Paper>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ const AngularWorkflow = (props) => {
|
|||||||
alert.error("Failed to set app auth: "+responseJson.reason)
|
alert.error("Failed to set app auth: "+responseJson.reason)
|
||||||
} else {
|
} else {
|
||||||
setAuthenticationModalOpen(false)
|
setAuthenticationModalOpen(false)
|
||||||
alert.success("Successfully saved workflow")
|
alert.success("Successfully saved new app auth")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
@@ -915,35 +915,39 @@ const AngularWorkflow = (props) => {
|
|||||||
setSelectedActionName(curaction.name)
|
setSelectedActionName(curaction.name)
|
||||||
setRequiresAuthentication(curapp.authentication.required)
|
setRequiresAuthentication(curapp.authentication.required)
|
||||||
|
|
||||||
// Setup auth here :)
|
if (curapp.authentication.required) {
|
||||||
const authenticationOptions = []
|
// Setup auth here :)
|
||||||
var findAuthId = ""
|
const authenticationOptions = []
|
||||||
if (curaction.authentication_id !== null && curaction.authentication_id !== undefined && curaction.authentication_id.length > 0) {
|
var findAuthId = ""
|
||||||
findAuthId = curaction.authentication_id
|
if (curaction.authentication_id !== null && curaction.authentication_id !== undefined && curaction.authentication_id.length > 0) {
|
||||||
}
|
findAuthId = curaction.authentication_id
|
||||||
|
}
|
||||||
|
|
||||||
for (var key in appAuthentication) {
|
var tmpAuth = JSON.parse(JSON.stringify(appAuthentication))
|
||||||
var item = appAuthentication[key]
|
for (var key in tmpAuth) {
|
||||||
|
var item = tmpAuth[key]
|
||||||
|
|
||||||
const newfields = {}
|
const newfields = {}
|
||||||
for (var filterkey in item.fields) {
|
for (var filterkey in item.fields) {
|
||||||
if (item.fields[filterkey] !== undefined) {
|
console.log(item.fields)
|
||||||
newfields[item.fields[filterkey].key] = item.fields[filterkey].value
|
newfields[item.fields[filterkey].key] = item.fields[filterkey].value
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
item.fields = newfields
|
item.fields = newfields
|
||||||
if (item.app.name === curapp.name) {
|
if (item.app.name === curapp.name) {
|
||||||
authenticationOptions.push(item)
|
authenticationOptions.push(item)
|
||||||
if (item.id === findAuthId) {
|
if (item.id === findAuthId) {
|
||||||
curaction.selectedAuthentication = item
|
console.log("ITEM: ", item)
|
||||||
|
// Missing fields here?
|
||||||
|
curaction.selectedAuthentication = item
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
curaction.authentication = authenticationOptions
|
curaction.authentication = authenticationOptions
|
||||||
if (curaction.selectedAuthentication === null || curaction.selectedAuthentication === undefined || curaction.selectedAuthentication.length === "") {
|
if (curaction.selectedAuthentication === null || curaction.selectedAuthentication === undefined || curaction.selectedAuthentication.length === "") {
|
||||||
curaction.selectedAuthentication = {}
|
curaction.selectedAuthentication = {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setSelectedApp(curapp)
|
setSelectedApp(curapp)
|
||||||
@@ -2585,15 +2589,13 @@ const AngularWorkflow = (props) => {
|
|||||||
data.variant = "STATIC_VALUE"
|
data.variant = "STATIC_VALUE"
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!selectedAction.auth_not_required && selectedAction.selectedAuthentication !== undefined && selectedAction.selectedAuthentication.fields !== undefined) {
|
if (!selectedAction.auth_not_required && selectedAction.selectedAuthentication !== undefined && selectedAction.selectedAuthentication.fields !== undefined && selectedAction.selectedAuthentication.fields[data.name] !== undefined) {
|
||||||
if (selectedAction.selectedAuthentication.fields[data.name] !== undefined) {
|
// This sets the placeholder in the frontend. (Replaced in backend)
|
||||||
// FIXME - this should be skipped in the frontend
|
selectedActionParameters[count].value = selectedAction.selectedAuthentication.fields[data.name]
|
||||||
//selectedActionParameters[count].value = selectedAction.selectedAuthentication.fields[data.name]
|
selectedAction.parameters[count].value = selectedAction.selectedAuthentication.fields[data.name]
|
||||||
//selectedAction.parameters[count].value = selectedAction.selectedAuthentication.fields[data.name]
|
setSelectedAction(selectedAction)
|
||||||
//setSelectedAction(selectedAction)
|
|
||||||
|
|
||||||
return null
|
return null
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var staticcolor = "inherit"
|
var staticcolor = "inherit"
|
||||||
@@ -3063,6 +3065,7 @@ const AngularWorkflow = (props) => {
|
|||||||
Authentication
|
Authentication
|
||||||
<div style={{display: "flex"}}>
|
<div style={{display: "flex"}}>
|
||||||
<Select
|
<Select
|
||||||
|
labelId="select-app-auth"
|
||||||
value={selectedAction.selectedAuthentication}
|
value={selectedAction.selectedAuthentication}
|
||||||
SelectDisplayProps={{
|
SelectDisplayProps={{
|
||||||
style: {
|
style: {
|
||||||
@@ -5464,6 +5467,7 @@ const AngularWorkflow = (props) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("FIELDS: ", newFields)
|
||||||
newAuthOption.fields = newFields
|
newAuthOption.fields = newFields
|
||||||
setNewAppAuth(newAuthOption)
|
setNewAppAuth(newAuthOption)
|
||||||
}
|
}
|
||||||
@@ -5472,10 +5476,10 @@ const AngularWorkflow = (props) => {
|
|||||||
<div>
|
<div>
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
<a href="https://shuffler.io/docs/apps#authentication" style={{textDecoration: "none", color: "#f85a3e"}}>What is this?</a>
|
<a href="https://shuffler.io/docs/apps#authentication" style={{textDecoration: "none", color: "#f85a3e"}}>What is this?</a>
|
||||||
These are required fields for authenticating with {selectedApp.name}
|
- These are required fields for authenticating with {selectedApp.name}
|
||||||
<div style={{marginTop: 15}}/>
|
<div style={{marginTop: 15}}/>
|
||||||
{selectedApp.link.length > 0 ? <EndpointData /> : null}
|
{selectedApp.link.length > 0 ? <EndpointData /> : null}
|
||||||
Label (to remember it)
|
<b>Label (to remember it)</b>
|
||||||
<TextField
|
<TextField
|
||||||
style={{backgroundColor: inputColor}}
|
style={{backgroundColor: inputColor}}
|
||||||
InputProps={{
|
InputProps={{
|
||||||
@@ -5494,12 +5498,13 @@ const AngularWorkflow = (props) => {
|
|||||||
authenticationOption.label = event.target.value
|
authenticationOption.label = event.target.value
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Divider style={{marginTop: 15, marginBottom: 15}}/>
|
<Divider style={{marginTop: 15, marginBottom: 15, backgroundColor: "rgb(91, 96, 100)"}}/>
|
||||||
<div style={{}}/>
|
<div style={{}}/>
|
||||||
{selectedApp.authentication.parameters.map((data, index) => {
|
{selectedApp.authentication.parameters.map((data, index) => {
|
||||||
return (
|
return (
|
||||||
<div key={index} style={{marginTop: 10}}>
|
<div key={index} style={{marginTop: 10}}>
|
||||||
{data.name}
|
<LockOpenIcon style={{marginRight: 10}}/>
|
||||||
|
<b>{data.name}</b>
|
||||||
<TextField
|
<TextField
|
||||||
style={{backgroundColor: inputColor}}
|
style={{backgroundColor: inputColor}}
|
||||||
InputProps={{
|
InputProps={{
|
||||||
|
|||||||
Reference in New Issue
Block a user