Skip to content

Commit

Permalink
Merge pull request #75 from KelvinTegelaar/dev
Browse files Browse the repository at this point in the history
[pull] dev from KelvinTegelaar:dev
  • Loading branch information
pull[bot] authored Feb 7, 2025
2 parents c283b9a + 183ce29 commit 4453e8e
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 12 deletions.
36 changes: 31 additions & 5 deletions src/components/CippIntegrations/CippApiClientManagement.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ const CippApiClientManagement = () => {
Action: "ResetSecret",
ClientId: "ClientId",
},
hideBulk: true,
},
{
label: "Copy API Scope",
Expand All @@ -127,6 +128,7 @@ const CippApiClientManagement = () => {
var scope = `api://${row.ClientId}/.default`;
navigator.clipboard.writeText(scope);
},
hideBulk: true,
},
{
label: "Delete Client",
Expand All @@ -146,6 +148,7 @@ const CippApiClientManagement = () => {
},
],
relatedQueryKeys: ["ApiClients"],
multiPost: false,
},
];

Expand Down Expand Up @@ -190,7 +193,12 @@ const CippApiClientManagement = () => {
</SvgIcon>
<ListItemText>Add Existing Client</ListItemText>
</MenuItem>
<MenuItem onClick={() => azureConfig.refetch()}>
<MenuItem
onClick={() => {
azureConfig.refetch();
handleMenuClose();
}}
>
<SvgIcon fontSize="small" sx={{ minWidth: "30px" }}>
<Sync />
</SvgIcon>
Expand All @@ -206,7 +214,10 @@ const CippApiClientManagement = () => {
</>
}
propertyItems={[
{ label: "API Auth Enabled", value: azureConfig.data?.Results?.Enabled },
{
label: "Microsoft Authentication Enabled",
value: azureConfig.data?.Results?.Enabled,
},
{
label: "API Url",
value: azureConfig.data?.Results?.ApiUrl ? (
Expand All @@ -226,12 +237,20 @@ const CippApiClientManagement = () => {
"Not Available"
),
},
{
label: "Tenant ID",
value: azureConfig.data?.Results?.TenantID ? (
<CippCopyToClipBoard type="chip" text={azureConfig.data?.Results?.TenantID} />
) : (
"Not Available"
),
},
]}
layout="dual"
showDivider={false}
isFetching={azureConfig.isFetching}
/>
{azureConfig.isSuccess && Array.isArray(azureConfig.data?.Results?.ClientIDs) && (
{azureConfig.isSuccess && azureConfig.data?.Results?.ClientIDs && (
<>
{!isEqual(
apiClients.data?.pages?.[0]?.Results?.filter((c) => c.Enabled)
Expand All @@ -248,8 +267,15 @@ const CippApiClientManagement = () => {
)}
</>
)}
{}
<Box>
{azureConfig.isSuccess && azureConfig.data?.Results?.Enabled === false && (
<Box sx={{ px: 3 }}>
<Alert severity="warning">
Microsoft Authentication is disabled. Configure API Clients and click Actions &gt;
Save Azure Configuration.
</Alert>
</Box>
)}
<Box sx={{ px: 3 }}>
<CippApiResults apiObject={postCall} />
</Box>
<CippDataTable
Expand Down
42 changes: 35 additions & 7 deletions src/pages/tenant/tools/geoiplookup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Grid, Stack } from "@mui/system";
import { Layout as DashboardLayout } from "/src/layouts/index.js";
import { useForm, useWatch } from "react-hook-form";
import CippButtonCard from "../../../../components/CippCards/CippButtonCard";
import { Delete, Search } from "@mui/icons-material";
import { Add, Delete, Search } from "@mui/icons-material";
import CippFormComponent from "../../../../components/CippComponents/CippFormComponent";
import { ApiPostCall } from "../../../../api/ApiCall";
import { getCippValidator } from "../../../../utils/get-cipp-validator";
Expand All @@ -26,15 +26,33 @@ const Page = () => {
customFunction: (row) => setIpAddress(row.RowKey),
noConfirm: true,
icon: <MapPinIcon />,
hideBulk: true,
},
{
label: "Add to Whitelist",
url: `/api/ExecAddTrustedIP`,
type: "POST",
data: {
IP: "RowKey",
State: "!Trusted",
},
icon: <Add />,
confirmText: "Are you sure you want to add this IP to the whitelist?",
multiPost: false,
condition: (row) => row.state !== "Trusted",
},
{
label: "Remove from Whitelist",
customFunction: (row) =>
addGeoIP.mutate({
url: `/api/ExecAddTrustedIP?IP=${row.RowKey}&TenantFilter=${currentTenant}&State=NotTrusted`,
}),
url: `/api/ExecAddTrustedIP`,
type: "POST",
data: {
IP: "RowKey",
State: "!NotTrusted",
},
icon: <Delete />,
confirmText: "Are you sure you want to remove this IP from the whitelist?",
multiPost: false,
condition: (row) => row.state !== "NotTrusted",
},
];

Expand All @@ -44,13 +62,23 @@ const Page = () => {

const handleAddToWhitelist = () => {
addGeoIP.mutate({
url: `/api/ExecAddTrustedIP?IP=${ip}&TenantFilter=${currentTenant}&State=Trusted`,
url: `/api/ExecAddTrustedIP`,
data: {
IP: ip,
State: "Trusted",
tenantFilter: currentTenant,
}
});
};

const handleRemoveFromWhitelist = () => {
addGeoIP.mutate({
url: `/api/ExecAddTrustedIP?IP=${ip}&TenantFilter=${currentTenant}&State=NotTrusted`,
url: `/api/ExecAddTrustedIP`,
data: {
IP: ip,
State: "NotTrusted",
tenantFilter: currentTenant,
}
});
};

Expand Down

0 comments on commit 4453e8e

Please sign in to comment.