From 05b80d2f55ea1c20fdef64fd95460391dcca2e53 Mon Sep 17 00:00:00 2001 From: Frikky Date: Wed, 20 Mar 2024 03:42:50 +0100 Subject: [PATCH] Fixed oauth2-app mapping --- backend/go-app/go.mod | 2 +- frontend/src/components/Oauth2Auth.jsx | 19 ++++++++------- frontend/src/components/ParsedAction.jsx | 12 --------- frontend/src/views/AngularWorkflow.jsx | 27 +++++++++------------ frontend/src/views/AppCreator.jsx | 10 +++++--- frontend/src/views/SetAuthentication.jsx | 6 ++--- frontend/src/views/UpdateAuthentication.jsx | 2 +- 7 files changed, 33 insertions(+), 45 deletions(-) diff --git a/backend/go-app/go.mod b/backend/go-app/go.mod index d35c542e..520d8919 100644 --- a/backend/go-app/go.mod +++ b/backend/go-app/go.mod @@ -18,7 +18,7 @@ require ( github.com/gorilla/mux v1.8.0 github.com/h2non/filetype v1.1.3 github.com/satori/go.uuid v1.2.0 - github.com/shuffle/shuffle-shared v0.5.93 + github.com/shuffle/shuffle-shared v0.6.0 golang.org/x/crypto v0.16.0 google.golang.org/api v0.125.0 google.golang.org/grpc v1.55.0 diff --git a/frontend/src/components/Oauth2Auth.jsx b/frontend/src/components/Oauth2Auth.jsx index 94b57b2a..8b9d58e6 100755 --- a/frontend/src/components/Oauth2Auth.jsx +++ b/frontend/src/components/Oauth2Auth.jsx @@ -767,7 +767,7 @@ const AuthenticationOauth2 = (props) => { } - + OR @@ -805,18 +805,19 @@ const AuthenticationOauth2 = (props) => { setOauthUrl(data.value); } - 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.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 ? "Token URL" : data.name + 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 ( -
+
{fieldname} {data.schema !== undefined && - data.schema !== null && - data.schema.type === "bool" ? ( + data.schema !== null && + data.schema.type === "bool" ? - ) : ( + : { //const [oauthUrl, setOauthUrl] = React.useState("") }} /> - )} + }
- ); + ) })} { return helperText } - //console.log("AUTH: ", authenticationType) - if (authenticationType !== undefined && authenticationType !== null && authenticationType.type === "oauth2") { - /* - return ( - - You must authenticate before using oauth2 apps. - - ) - */ - } - - //console.log("APP: ", selectedApp) // FIXME: Issue #40 - selectedActionParameters not reset if ( diff --git a/frontend/src/views/AngularWorkflow.jsx b/frontend/src/views/AngularWorkflow.jsx index 4549f8ad..ccf7bee9 100755 --- a/frontend/src/views/AngularWorkflow.jsx +++ b/frontend/src/views/AngularWorkflow.jsx @@ -4049,7 +4049,6 @@ const AngularWorkflow = (defaultprops) => { if (!curapp || curapp === undefined) { console.log("APPS - couldn't find it: ", newapps) - //toast(`App ${curaction.app_name}:${curaction.app_version} not found. Is it activated?`); const tmpapp = { name: curaction.app_name, @@ -4057,20 +4056,16 @@ const AngularWorkflow = (defaultprops) => { app_version: curaction.app_version, id: curaction.app_id, actions: [curaction], - }; + } - setSelectedApp(tmpapp); - setSelectedAction(curaction); + setSelectedApp(tmpapp) + setSelectedAction(curaction) } else { - //if (curapp.id !== curaction.id) { - // curaction.app_id = curapp.id - // //.valueOf() - //} curaction.app_id = curapp.id setAuthenticationType( - curapp.authentication.type === "oauth2" && curapp.authentication.redirect_uri !== undefined && curapp.authentication.redirect_uri !== null ? { - type: "oauth2", + curapp.authentication.type === "oauth2-app" || (curapp.authentication.type === "oauth2" && curapp.authentication.redirect_uri !== undefined && curapp.authentication.redirect_uri !== null) ? { + type: curapp.authentication.type, redirect_uri: curapp.authentication.redirect_uri, refresh_uri: curapp.authentication.refresh_uri, token_uri: curapp.authentication.token_uri, @@ -8117,7 +8112,7 @@ const AngularWorkflow = (defaultprops) => { : `${pixelSize} solid ${yellow}`; if (app.id == highlightedApp) { - console.log("Found correct appid to highlight: ", app.id) + //console.log("Found correct appid to highlight: ", app.id) newAppStyle.border = "3px solid " + green } @@ -18258,13 +18253,13 @@ const AngularWorkflow = (defaultprops) => { style={{ flex: 2, padding: 0, - minHeight: isMobile ? "90%" : 650, - maxHeight: isMobile ? "90%" : 650, + minHeight: isMobile ? "90%" : 700, + maxHeight: isMobile ? "90%" : 700, overflowY: "auto", overflowX: isMobile ? "auto" : "hidden", }} > - {authenticationType.type === "oauth2" ? ( + {authenticationType.type === "oauth2" || authenticationType.type === "oauth2-app" ? { setAuthenticationModalOpen={setAuthenticationModalOpen} isCloud={isCloud} /> - ) : ( + : - )} + }
{ optionset = true } else if (value.scheme === "oauth2") { - setAuthenticationOption("Oauth2"); - setAuthenticationRequired(true); - optionset = true + setAuthenticationOption("Oauth2"); + setAuthenticationRequired(true); + optionset = true } else if (value.type === "oauth2" || key === "Oauth2" || key === "Oauth2c" || (key !== undefined && key !== null && key.toLowerCase().includes("oauth2"))) { //toast("Can't handle Oauth2 auth yet.") @@ -6054,6 +6054,10 @@ const AppCreator = (defaultprops) => { if (e.target.value === "application" && oauth2GrantType === "") { setOauth2GrantType("client_credentials") + } + + if (e.target.value === "delegated") { + setOauth2GrantType("") } }} value={oauth2Type} diff --git a/frontend/src/views/SetAuthentication.jsx b/frontend/src/views/SetAuthentication.jsx index 258056d0..0015deda 100755 --- a/frontend/src/views/SetAuthentication.jsx +++ b/frontend/src/views/SetAuthentication.jsx @@ -305,15 +305,15 @@ const SetAuthentication = (props) => { variant="h4" style={{ marginLeft: "auto", marginRight: "auto", marginTop: 50}} > - Oauth2 setup + Oauth2 setup {!finished ? ( - failed ? - null : + failed ? + null : ) : ( "Done - this window should close within 3 seconds." diff --git a/frontend/src/views/UpdateAuthentication.jsx b/frontend/src/views/UpdateAuthentication.jsx index 054244c3..92b17e80 100644 --- a/frontend/src/views/UpdateAuthentication.jsx +++ b/frontend/src/views/UpdateAuthentication.jsx @@ -141,7 +141,7 @@ const SetAuthentication = (props) => { {app.authentication === undefined || app.authentication === null || app.authentication.length === 0 ? null : - app.authentication.type === "oauth2" ? + app.authentication.type === "oauth2" || app.authentication.type === "oauth2-app" ?