Merge pull request #1512 from LalitDeore/sso_2.0.0

sso and billing cards changes
This commit is contained in:
Frikky
2024-10-11 17:13:11 +02:00
committed by GitHub
4 changed files with 566 additions and 449 deletions
+3 -3
View File
@@ -1131,9 +1131,9 @@ func checkAdminLogin(resp http.ResponseWriter, request *http.Request) {
} }
// No childorg setup, only parent org // No childorg setup, only parent org
if len(org.ManagerOrgs) > 0 || len(org.CreatorOrg) > 0 { // if len(org.ManagerOrgs) > 0 || len(org.CreatorOrg) > 0 {
continue // continue
} // }
// Should run calculations // Should run calculations
if len(org.SSOConfig.OpenIdAuthorization) > 0 { if len(org.SSOConfig.OpenIdAuthorization) > 0 {
+24 -11
View File
@@ -298,17 +298,21 @@ const Header = (props) => {
if (response.status !== 200) { if (response.status !== 200) {
console.log("Error in response"); console.log("Error in response");
} else { } else {
localStorage.removeItem("apps") localStorage.removeItem("apps");
localStorage.removeItem("workflows") localStorage.removeItem("workflows");
localStorage.removeItem("userinfo") localStorage.removeItem("userinfo");
} }
return response.json(); return response.json();
}) })
.then(function (responseJson) { .then(function (responseJson) {
console.log("In here?") console.log("In here?");
if (responseJson.success === true) { if (responseJson.success === true) {
if (responseJson.region_url !== undefined && responseJson.region_url !== null && responseJson.region_url.length > 0) { if (
responseJson.region_url !== undefined &&
responseJson.region_url !== null &&
responseJson.region_url.length > 0
) {
console.log("Region Change: ", responseJson.region_url); console.log("Region Change: ", responseJson.region_url);
localStorage.setItem("globalUrl", responseJson.region_url); localStorage.setItem("globalUrl", responseJson.region_url);
//globalUrl = responseJson.region_url //globalUrl = responseJson.region_url
@@ -317,20 +321,29 @@ const Header = (props) => {
if (responseJson["reason"] === "SSO_REDIRECT") { if (responseJson["reason"] === "SSO_REDIRECT") {
toast.info("Redirecting to SSO login page as SSO is required for this organization.") toast.info("Redirecting to SSO login page as SSO is required for this organization.")
setTimeout(() => { setTimeout(() => {
window.location.href = responseJson["url"] toast.info(
return "Redirecting to SSO login page as SSO is required for this organization."
}, 2000) );
window.location.href = responseJson["url"];
return;
}, 2000);
} else { } else {
toast("Successfully changed active organization - refreshing!"); toast("Successfully changed active organization - refreshing!");
setTimeout(() => { setTimeout(() => {
window.location.reload() window.location.reload();
}, 2000); }, 2000);
} }
} else { } else {
if (responseJson.reason !== undefined && responseJson.reason !== null && responseJson.reason.length > 0) { if (
responseJson.reason !== undefined &&
responseJson.reason !== null &&
responseJson.reason.length > 0
) {
toast(responseJson.reason); toast(responseJson.reason);
} else { } else {
toast("Failed changing org. Try again or contact support@shuffler.io if this persists."); toast(
"Failed changing org. Try again or contact support@shuffler.io if this persists."
);
} }
} }
}) })
+125 -21
View File
@@ -320,9 +320,71 @@ const OrgHeaderexpanded = (props) => {
); );
const toggleBetweenRequiredOrOptional = (event) => { const toggleBetweenRequiredOrOptional = (event) => {
if (
ssoEntrypoint === "" &&
openidAuthorization === "" &&
openidToken === ""
) {
if (!SSORequired) {
toast.error(
"Please fill in fields for either OpenID connect or SSO before continuing. "
);
return;
}
} else {
toast.info("Toggled SSO. Remember to save.");
}
setSSORequired(event.target.checked); setSSORequired(event.target.checked);
}; };
const HandleTestSSO = () => {
const url = `${globalUrl}/api/v1/orgs/${selectedOrganization?.id}/change`;
const data = {
org_id: selectedOrganization?.id,
sso_test: true,
};
fetch(url, {
mode: "cors",
credentials: "include",
crossDomain: true,
method: "POST",
body: JSON.stringify(data),
withCredentials: true,
headers: {
"Content-Type": "application/json; charset=utf-8",
},
})
.then((response) => {
if (response.status !== 200) {
toast.error(
"Failed to test sso. Please try again later or contact support@shuffler.io if issue persist."
);
return;
}
return response.json();
})
.then((responjson) => {
if (responjson["reason"] === "SSO_REDIRECT") {
setTimeout(() => {
toast.info(
"Redirecting to SSO login page as SSO is required for this organization."
);
window.location.href = responjson["url"];
return;
}, 2000);
} else {
toast.error(
"No SSO found for this org. Please set up sso for this org."
);
}
})
.catch((err) => {
console.log("error for sso test is: ", err);
});
};
const HandleTestSSO = () => { const HandleTestSSO = () => {
const url = `${globalUrl}/api/v1/orgs/${selectedOrganization?.id}/change`; const url = `${globalUrl}/api/v1/orgs/${selectedOrganization?.id}/change`;
@@ -702,8 +764,22 @@ const OrgHeaderexpanded = (props) => {
SSO Configuration SSO Configuration
</Typography> </Typography>
<div style={{ display: 'flex', flexDirection: 'column', marginLeft: 10, width: '100%', }}> <div
<Typography variant="body2" color="textSecondary" style={{ margin: '5px 0px 5px 10px' }}>Make SAML SSO or OpenID Authentication Required or Optional for Your Organization.</Typography> style={{
display: "flex",
flexDirection: "column",
marginLeft: 10,
width: "100%",
}}
>
<Typography
variant="body2"
color="textSecondary"
style={{ margin: "5px 0px 5px 10px" }}
>
Make SAML SSO or OpenID Authentication Required or Optional for Your
Organization.
</Typography>
<div> <div>
<Switch <Switch
checked={SSORequired} checked={SSORequired}
@@ -712,12 +788,24 @@ const OrgHeaderexpanded = (props) => {
color="primary" color="primary"
title="Make SAML SSO or OpenID Authentication Required or Optional for Your Organization" title="Make SAML SSO or OpenID Authentication Required or Optional for Your Organization"
/> />
{SSORequired ? 'Required' : 'Optional'} {SSORequired ? "Required" : "Optional"}
</div> </div>
</div> </div>
<div style={{ display: 'flex', flexDirection: 'column', marginTop: 20, marginLeft: 10, width: "100%", borderBottom: '1px solid #414347', paddingBottom: 10 }}> <div
<Typography variant="body1" style={{ margin: '5px 0px 5px 10px' }}> style={{
You can test your SSO configuration by clicking the button below. Before testing, ensure you have set Open ID Connect or SAML SSO credentials. display: "flex",
flexDirection: "column",
marginTop: 20,
marginLeft: 10,
width: "100%",
borderBottom: "1px solid #414347",
paddingBottom: 10,
}}
>
<Typography variant="body1" style={{ margin: "5px 0px 5px 10px" }}>
You can test your SSO configuration by clicking the button below.
Before testing, ensure you have set Open ID Connect or SAML SSO
credentials.
</Typography> </Typography>
<Tooltip <Tooltip
title={ title={
@@ -735,7 +823,7 @@ const OrgHeaderexpanded = (props) => {
<Button <Button
variant="outlined" variant="outlined"
color="primary" color="primary"
style={{ width: 100, textTransform: 'none', margin: 10 }} style={{ width: 100, textTransform: "none", margin: 10 }}
disabled={ disabled={
!( !(
ssoEntrypoint.length > 0 || ssoEntrypoint.length > 0 ||
@@ -751,9 +839,12 @@ const OrgHeaderexpanded = (props) => {
</span> </span>
</Tooltip> </Tooltip>
</div> </div>
<div></div>
<Grid item xs={12} style={{}}> <Grid item xs={12} style={{}}>
<Typography variant="h6" style={{ textAlign: "center", }}>OpenID connect</Typography> <Typography variant="h6" style={{ textAlign: "center" }}>
<Grid container style={{ marginTop: 10, }}> OpenID connect
</Typography>
<Grid container style={{ marginTop: 10 }}>
<Grid item xs={6} style={{}}> <Grid item xs={6} style={{}}>
<span> <span>
<Typography>Client ID</Typography> <Typography>Client ID</Typography>
@@ -833,7 +924,7 @@ const OrgHeaderexpanded = (props) => {
</span> </span>
</Grid> </Grid>
</Grid> </Grid>
<Grid container style={{ marginTop: 10, }}> <Grid container style={{ marginTop: 10 }}>
<Grid item xs={6} style={{}}> <Grid item xs={6} style={{}}>
<span> <span>
<Typography>Authorization URL</Typography> <Typography>Authorization URL</Typography>
@@ -855,7 +946,7 @@ const OrgHeaderexpanded = (props) => {
placeholder="The OpenID authorization URL (usually ends with /authorize)" placeholder="The OpenID authorization URL (usually ends with /authorize)"
value={openidAuthorization} value={openidAuthorization}
onChange={(e) => { onChange={(e) => {
setOpenidAuthorization(e.target.value) setOpenidAuthorization(e.target.value);
}} }}
InputProps={{ InputProps={{
classes: { classes: {
@@ -889,7 +980,7 @@ const OrgHeaderexpanded = (props) => {
placeholder="The OpenID token URL (usually ends with /token)" placeholder="The OpenID token URL (usually ends with /token)"
value={openidToken} value={openidToken}
onChange={(e) => { onChange={(e) => {
setOpenidToken(e.target.value) setOpenidToken(e.target.value);
}} }}
InputProps={{ InputProps={{
classes: { classes: {
@@ -906,9 +997,11 @@ const OrgHeaderexpanded = (props) => {
</Grid> </Grid>
{/* } */} {/* } */}
{/*isCloud ? null : */} {/*isCloud ? null : */}
<Grid item xs={12} style={{ marginTop: 50, }}> <Grid item xs={12} style={{ marginTop: 50 }}>
<Typography variant="h6" style={{ textAlign: "center", }}>SAML SSO (v1.1)</Typography> <Typography variant="h6" style={{ textAlign: "center" }}>
<Grid container style={{ marginTop: 20, }}> SAML SSO (v1.1)
</Typography>
<Grid container style={{ marginTop: 20 }}>
<Grid item xs={6} style={{}}> <Grid item xs={6} style={{}}>
<span> <span>
<Typography>SSO Entrypoint (IdP)</Typography> <Typography>SSO Entrypoint (IdP)</Typography>
@@ -983,11 +1076,15 @@ const OrgHeaderexpanded = (props) => {
</span> </span>
</Grid> </Grid>
</Grid> </Grid>
{isCloud ? {isCloud ? (
<Typography variant="body2" style={{ textAlign: "left", }} color="textSecondary"> <Typography
variant="body2"
style={{ textAlign: "left" }}
color="textSecondary"
>
IdP URL for Shuffle: https://shuffler.io/api/v1/login_sso IdP URL for Shuffle: https://shuffler.io/api/v1/login_sso
</Typography> </Typography>
: null} ) : null}
</Grid> </Grid>
{isCloud ? null : ( {isCloud ? null : (
<Grid item xs={6} style={{}}> <Grid item xs={6} style={{}}>
@@ -1126,7 +1223,14 @@ const OrgHeaderexpanded = (props) => {
</Grid> </Grid>
)} )}
<div style={{ margin: "auto", textalign: "center", marginTop: 15, marginBottom: 15, }}> <div
style={{
margin: "auto",
textalign: "center",
marginTop: 15,
marginBottom: 15,
}}
>
{orgSaveButton} {orgSaveButton}
</div> </div>
{/* {/*
@@ -1140,7 +1244,7 @@ const OrgHeaderexpanded = (props) => {
*/} */}
</Grid> </Grid>
</div> </div>
) );
} };
export default OrgHeaderexpanded; export default OrgHeaderexpanded;