Skip to content

Commit

Permalink
Merge branch 'KelvinTegelaar:dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnDuprey committed Apr 11, 2024
2 parents 706dfac + a4f0d2c commit bad4bf3
Show file tree
Hide file tree
Showing 5 changed files with 293 additions and 20 deletions.
5 changes: 5 additions & 0 deletions src/_nav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,11 @@ const _nav = [
name: 'Deploy CA Policies',
to: '/tenant/conditional/deploy',
},
{
component: CNavItem,
name: 'CA Policy Tester',
to: '/tenant/conditional/test-policy',
},
{
component: CNavItem,
name: 'CA Vacation Mode',
Expand Down
1 change: 1 addition & 0 deletions src/importsMap.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import React from 'react'
"/tenant/administration/app-consent-requests": React.lazy(() => import('./views/tenant/administration/ListAppConsentRequests')),
"/tenant/conditional/list-policies": React.lazy(() => import('./views/tenant/conditional/ConditionalAccess')),
"/tenant/conditional/deploy-vacation": React.lazy(() => import('./views/tenant/conditional/DeployVacation')),
"/tenant/conditional/test-policy": React.lazy(() => import('./views/tenant/conditional/TestCAPolicy')),
"/tenant/conditional/list-named-locations": React.lazy(() => import('./views/tenant/conditional/NamedLocations')),
"/tenant/conditional/deploy": React.lazy(() => import('./views/tenant/conditional/DeployCA')),
"/tenant/conditional/deploy-named-location": React.lazy(() => import('./views/tenant/conditional/DeployNamedLocation')),
Expand Down
6 changes: 6 additions & 0 deletions src/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,12 @@
"component": "views/tenant/conditional/DeployVacation",
"allowedRoles": ["admin", "editor", "readonly"]
},
{
"path": "/tenant/conditional/test-policy",
"name": "Test Conditional Access Policy",
"component": "views/tenant/conditional/TestCAPolicy",
"allowedRoles": ["admin", "editor", "readonly"]
},
{
"path": "/tenant/conditional/list-named-locations",
"name": "Named Locations",
Expand Down
281 changes: 281 additions & 0 deletions src/views/tenant/conditional/TestCAPolicy.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,281 @@
import React, { useState } from 'react'
import { CButton, CCallout, CCol, CForm, CRow, CSpinner, CTooltip } from '@coreui/react'
import { useSelector } from 'react-redux'
import { Field, Form } from 'react-final-form'
import { RFFCFormInput, RFFSelectSearch } from 'src/components/forms'
import { useLazyGenericGetRequestQuery, useLazyGenericPostRequestQuery } from 'src/store/api/app'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faCircleNotch, faEdit, faEye } from '@fortawesome/free-solid-svg-icons'
import { CippContentCard, CippPage, CippPageList } from 'src/components/layout'
import 'react-datepicker/dist/react-datepicker.css'
import { TenantSelector } from 'src/components/utilities'
import arrayMutators from 'final-form-arrays'
import 'react-datepicker/dist/react-datepicker.css'
import { useListUsersQuery } from 'src/store/api/users'
import { useListConditionalAccessPoliciesQuery } from 'src/store/api/tenants'
import { TableContentCard } from 'src/components/contentcards'
import { cellGenericFormatter } from 'src/components/tables/CellGenericFormat'
import countryList from 'src/data/countryList'

const TestCAPolicy = () => {
const [ExecuteGetRequest, getResults] = useLazyGenericGetRequestQuery()
const currentDate = new Date()
const [startDate, setStartDate] = useState(currentDate)
const [endDate, setEndDate] = useState(currentDate)

const tenantDomain = useSelector((state) => state.app.currentTenant.defaultDomainName)
const [refreshState, setRefreshState] = useState(false)
const [genericPostRequest, postResults] = useLazyGenericPostRequestQuery()

const onSubmit = (values) => {
genericPostRequest({
path: '/api/ExecCACheck',
values: { tenantFilter: tenantDomain, ...values },
}).then((res) => {
setRefreshState(res.requestId)
})
}

const {
data: users = [],
isFetching: usersIsFetching,
error: usersError,
} = useListUsersQuery({ tenantDomain })

const {
data: caPolicies = [],
isFetching: caIsFetching,
error: caError,
} = useListConditionalAccessPoliciesQuery({ domain: tenantDomain })
const columns = [
{
name: 'Display Name',
selector: (row) => row['displayName'],
sortable: true,
cell: cellGenericFormatter(),
exportSelector: 'displayName',
},
{
name: 'State',
selector: (row) => row['state'],
sortable: true,
cell: cellGenericFormatter(),
exportSelector: 'state',
},
{
name: 'Policy Applied',
selector: (row) => row['policyApplies'],
sortable: true,
cell: cellGenericFormatter(),
exportSelector: 'policyApplies',
},
{
name: 'Reasons for not applying',
selector: (row) => row['reasons'],
sortable: true,
exportSelector: 'reasons',
},
]
return (
<CippPage title={`Add Schedule`} tenantSelector={false}>
<>
<CRow>
<CCol md={4}>
<CippContentCard title="Test Conditional Access Policy" icon={faEdit}>
<Form
onSubmit={onSubmit}
mutators={{
...arrayMutators,
}}
render={({ handleSubmit, submitting, values }) => {
return (
<CForm onSubmit={handleSubmit}>
<p>
Test your conditional access policies before putting them in production. The
returned results will show you if the user is allowed or denied access based
on the policy.
</p>
<CRow className="mb-3">
<CCol>
<label>Tenant</label>
<Field name="tenantFilter">{(props) => <TenantSelector />}</Field>
</CCol>
</CRow>
<CRow className="mb-3">
<hr />
Mandatory Parameters:
</CRow>
<CRow className="mb-3">
<CCol>
<RFFSelectSearch
label={'Select a user to test'}
values={users?.map((user) => ({
value: user.id,
name: `${user.displayName} <${user.userPrincipalName}>`,
}))}
placeholder={!usersIsFetching ? 'Select user' : 'Loading...'}
name="UserId"
/>
</CCol>
</CRow>
<CRow className="mb-3">
<CCol>
<RFFSelectSearch
label={'Select the application to test.'}
values={caPolicies?.map((ca) => ({
value: ca.id,
name: `${ca.displayName}`,
}))}
placeholder={!caIsFetching ? 'Select Application' : 'Loading...'}
name="includeApplications"
/>
</CCol>
</CRow>
<CRow className="mb-3">
<hr />
Optional Parameters:
</CRow>
<CRow className="mb-3">
<CCol>
<RFFSelectSearch
values={countryList.map(({ Code, Name }) => ({
value: Code,
name: Name,
}))}
name="country"
placeholder="Type to search..."
label="Test from this country"
/>
</CCol>
</CRow>
<CRow className="mb-3">
<CCol>
<RFFCFormInput
placeholder="8.8.8.8"
label="Test from this IP"
name="IpAddress"
/>
</CCol>
</CRow>
<CRow className="mb-3">
<CCol>
<RFFSelectSearch
label={'Select the device platform to test'}
values={[
{ value: 'Windows', name: 'Windows' },
{ value: 'iOS', name: 'iOS' },
{ value: 'Android', name: 'Android' },
{ value: 'MacOS', name: 'MacOS' },
{ value: 'Linux', name: 'Linux' },
]}
placeholder={!caIsFetching ? 'Select platform' : 'Loading...'}
name="devicePlatform"
/>
</CCol>
</CRow>
<CRow className="mb-3">
<CCol>
<RFFSelectSearch
label={'Select the client application type to test'}
values={[
{ value: 'all', name: 'All' },
{ value: 'Browser', name: 'Browser' },
{
value: 'mobileAppsAndDesktopClients',
name: 'Mobile apps and desktop clients',
},
{ value: 'exchangeActiveSync', name: 'Exchange ActiveSync' },
{ value: 'easSupported', name: 'EAS supported' },
{ value: 'other', name: 'Other clients' },
]}
placeholder={!caIsFetching ? 'Select client application' : 'Loading...'}
name="clientAppType"
/>
</CCol>
</CRow>
<CRow className="mb-3">
<CCol>
<RFFSelectSearch
label={'Select the sign in risk level of the user signing in.'}
values={[
{ value: 'low', name: 'Low' },
{ value: 'medium', name: 'Medium' },
{ value: 'high', name: 'High' },
{ value: 'none', name: 'None' },
]}
placeholder={!caIsFetching ? 'Select Sign-in risk' : 'Loading...'}
name="SignInRiskLevel"
/>
</CCol>
</CRow>
<CRow className="mb-3">
<CCol>
<RFFSelectSearch
label={'Select the user risk level of the user signing in.'}
values={[
{ value: 'low', name: 'Low' },
{ value: 'medium', name: 'Medium' },
{ value: 'high', name: 'High' },
{ value: 'none', name: 'None' },
]}
placeholder={!caIsFetching ? 'Select User Risk' : 'Loading...'}
name="userRiskLevel"
/>
</CCol>
</CRow>
<CRow>
<CCol md={6}>
<CButton type="submit" disabled={submitting}>
Test policies
{postResults.isFetching && (
<FontAwesomeIcon
icon={faCircleNotch}
spin
className="ms-2"
size="1x"
/>
)}
</CButton>
</CCol>
</CRow>
{postResults.isSuccess && (
<CCallout color="success">
<li>
{postResults.data?.Results?.value
? 'Test succesful. See the table for the results.'
: postResults.data.Results}
</li>
</CCallout>
)}
{getResults.isFetching && (
<CCallout color="info">
<CSpinner>Loading</CSpinner>
</CCallout>
)}
{getResults.isSuccess && (
<CCallout color="info">{getResults.data?.Results}</CCallout>
)}
{getResults.isError && (
<CCallout color="danger">
Could not connect to API: {getResults.error.message}
</CCallout>
)}
</CForm>
)
}}
/>
</CippContentCard>
</CCol>
<CCol md={8}>
<TableContentCard
title="Results"
table={{ data: postResults.data?.Results?.value, columns: columns }}
/>
</CCol>
</CRow>
</>
</CippPage>
)
}

export default TestCAPolicy
20 changes: 0 additions & 20 deletions src/views/tenant/standards/ListAppliedStandards.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,26 +235,6 @@ const ApplyNewStandard = () => {
values: { tenant: tenantDomain, ...values.standards },
})
}
const tableColumns = [
{
name: 'Tenant',
selector: (row) => row['displayName'],
sortable: true,
exportSelector: 'displayName',
},

{
name: 'Applied Standards',
selector: (row) => row['StandardsExport'],
sortable: true,
exportSelector: 'StandardsExport',
},
{
name: 'Actions',
cell: Offcanvas,
maxWidth: '80px',
},
]
const [intuneGetRequest, intuneTemplates] = useLazyGenericGetRequestQuery()
const [transportGetRequest, transportTemplates] = useLazyGenericGetRequestQuery()
const [exConnectorGetRequest, exConnectorTemplates] = useLazyGenericGetRequestQuery()
Expand Down

0 comments on commit bad4bf3

Please sign in to comment.