Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/KelvinTegelaar/CIPP into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
KelvinTegelaar committed Aug 3, 2023
2 parents a598530 + 4b50b87 commit bb28a63
Show file tree
Hide file tree
Showing 2 changed files with 135 additions and 34 deletions.
151 changes: 124 additions & 27 deletions src/views/cipp/CIPPSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ import { Form } from 'react-final-form'
import useConfirmModal from 'src/hooks/useConfirmModal'
import { setCurrentTenant } from 'src/store/features/app'
import {
CippOffcanvas,
CippCodeBlock,
ModalService,
StatusIcon,
Expand Down Expand Up @@ -821,7 +822,7 @@ const ExcludedTenantsSettings = () => {
}
const SecuritySettings = () => {
const [listBackend, listBackendResult] = useLazyGenericGetRequestQuery()

const [visible, setVisible] = useState(false)
return (
<div>
{listBackendResult.isUninitialized && listBackend({ path: 'api/ExecBackendURLs' })}
Expand All @@ -833,16 +834,16 @@ const SecuritySettings = () => {
<CCardTitle>Resource Group</CCardTitle>
</CCardHeader>
<CCardBody>
<CRow className="mb-3">
<p>
The Resource group contains all the CIPP resources in your tenant, except the SAM
Application
</CRow>
</p>
<a
target={'_blank'}
href={listBackendResult.data?.Results?.ResourceGroup}
rel="noreferrer"
>
<CButton>Go to Resource Group</CButton>
<CButton className="mb-3">Go to Resource Group</CButton>
</a>
</CCardBody>
</CCard>
Expand All @@ -853,16 +854,16 @@ const SecuritySettings = () => {
<CCardTitle>Key Vault</CCardTitle>
</CCardHeader>
<CCardBody>
<CRow className="mb-3">
<p>
The keyvault allows you to check token information. By default you do not have
access.
</CRow>
</p>
<a
target={'_blank'}
href={listBackendResult.data?.Results?.KeyVault}
rel="noreferrer"
>
<CButton>Go to Keyvault</CButton>
<CButton className="mb-3">Go to Keyvault</CButton>
</a>
</CCardBody>
</CCard>
Expand All @@ -873,16 +874,16 @@ const SecuritySettings = () => {
<CCardTitle>Static Web App (Role Management)</CCardTitle>
</CCardHeader>
<CCardBody>
<CRow className="mb-3">
<p>
The Static Web App role management allows you to invite other users to the
application.
</CRow>
</p>
<a
target={'_blank'}
href={listBackendResult.data?.Results?.SWARoles}
rel="noreferrer"
>
<CButton>Go to Role Management</CButton>
<CButton className="mb-3">Go to Role Management</CButton>
</a>
</CCardBody>
</CCard>
Expand All @@ -895,15 +896,13 @@ const SecuritySettings = () => {
<CCardTitle>Function App (Deployment Center)</CCardTitle>
</CCardHeader>
<CCardBody>
<CRow className="mb-3">
The Function App Deployment Center allows you to run updates on the API
</CRow>
<p>The Function App Deployment Center allows you to run updates on the API</p>
<a
target={'_blank'}
href={listBackendResult.data?.Results?.FunctionDeployment}
rel="noreferrer"
>
<CButton>Go to Function App Deployment Center</CButton>
<CButton className="mb-3">Go to Function App Deployment Center</CButton>
</a>
</CCardBody>
</CCard>
Expand All @@ -914,17 +913,17 @@ const SecuritySettings = () => {
<CCardTitle>Function App (Configuration)</CCardTitle>
</CCardHeader>
<CCardBody>
<CRow className="mb-3">
<p>
At the Function App Configuration you can check the status of the API access to
your keyvault
<a
target={'_blank'}
href={listBackendResult.data?.Results?.FunctionConfig}
rel="noreferrer"
>
<CButton>Go to Function App Configuration</CButton>
</a>
</CRow>
</p>
<a
target={'_blank'}
href={listBackendResult.data?.Results?.FunctionConfig}
rel="noreferrer"
>
<CButton className="mb-3">Go to Function App Configuration</CButton>
</a>
</CCardBody>
</CCard>
</CCol>
Expand All @@ -934,20 +933,118 @@ const SecuritySettings = () => {
<CCardTitle>Function App (Overview)</CCardTitle>
</CCardHeader>
<CCardBody>
<CRow className="mb-3">
At the function App Overview, you can stop and start the backend API
</CRow>
<p>At the function App Overview, you can stop and start the backend API</p>
<a
target={'_blank'}
href={listBackendResult.data?.Results?.FunctionApp}
rel="noreferrer"
>
<CButton>Go to Function App Overview</CButton>
<CButton className="mb-3">Go to Function App Overview</CButton>
</a>
</CCardBody>
</CCard>
</CCol>
</CRow>
<CRow className="mb-3">
<CCol md={4}>
<CCard className="h-100">
<CCardHeader>
<CCardTitle>Cloud Shell</CCardTitle>
</CCardHeader>
<CCardBody>
<p>Launch an Azure Cloud Shell Window</p>
<CLink
onClick={() =>
window.open(
'https://shell.azure.com/powershell',
'_blank',
'toolbar=no,scrollbars=yes,resizable=yes,menubar=no,location=no,status=no',
)
}
rel="noreferrer"
>
<CButton className="mb-3 me-3">Cloud Shell</CButton>
</CLink>
<CButton onClick={() => setVisible(true)} className="mb-3">
Command Reference
</CButton>
</CCardBody>
</CCard>
</CCol>
</CRow>
<CippOffcanvas
id="command-offcanvas"
visible={visible}
placement="end"
className="cipp-offcanvas"
hideFunction={() => setVisible(false)}
title="Command Reference"
>
<h5 className="my-3">Function App Config</h5>
<CippCodeBlock
language="powershell"
code={
'$Function = Get-AzFunctionApp -ResourceGroupName ' +
listBackendResult.data?.Results?.RGName +
' -Name ' +
listBackendResult.data?.Results?.FunctionName +
'; $Function | select Name, Status, Location, Runtime, ApplicationSettings'
}
showLineNumbers={false}
wrapLongLines={true}
/>
<h5 className="my-3">Function App Deployment</h5>
<CippCodeBlock
language="powershell"
code={
'$FunctionDeployment = az webapp deployment source show --resource-group ' +
listBackendResult.data?.Results?.RGName +
' --name ' +
listBackendResult.data?.Results?.FunctionName +
' | ConvertFrom-Json; $FunctionDeployment | Select-Object repoUrl, branch, isGitHubAction, isManualIntegration, githubActionConfiguration'
}
showLineNumbers={false}
wrapLongLines={true}
/>
<h5 className="my-3">Watch Function Logs</h5>
<CippCodeBlock
language="powershell"
code={
'az webapp log tail --resource-group ' +
listBackendResult.data?.Results?.RGName +
' --name ' +
listBackendResult.data?.Results?.FunctionName
}
showLineNumbers={false}
wrapLongLines={true}
/>
<h5 className="my-3">Static Web App Config</h5>
<CippCodeBlock
language="powershell"
code={
'$StaticWebApp = Get-AzStaticWebApp -ResourceGroupName ' +
listBackendResult.data?.Results?.RGName +
' -Name ' +
listBackendResult.data?.Results?.SWAName +
'; $StaticWebApp | Select-Object Name, CustomDomain, DefaultHostname, RepositoryUrl'
}
showLineNumbers={false}
wrapLongLines={true}
/>
<h5 className="my-3">List CIPP Users</h5>
<CippCodeBlock
language="powershell"
code={
'Get-AzStaticWebAppUser -ResourceGroupName ' +
listBackendResult.data?.Results?.RGName +
' -Name ' +
listBackendResult.data?.Results?.SWAName +
' -AuthProvider all | Select-Object DisplayName, Role'
}
showLineNumbers={false}
wrapLongLines={true}
/>
</CippOffcanvas>
</>
</div>
)
Expand Down
18 changes: 11 additions & 7 deletions src/views/tenant/administration/TenantLookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ import { CippContentCard } from 'src/components/layout'
import Skeleton from 'react-loading-skeleton'
import { domainsApi } from 'src/store/api/domains'

const isValidTenantInput = (value) => {
// Regular expression for validating GUID
const guidRegex = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/
// Regular expression for validating domain
const domainRegex = /^([a-zA-Z0-9](-?[a-zA-Z0-9])*\.)+[a-zA-Z]{2,}$/

// Check if the input is a valid GUID or domain
return !(guidRegex.test(value) || domainRegex.test(value))
}

const GraphExplorer = () => {
let navigate = useNavigate()
const tenant = useSelector((state) => state.app.currentTenant)
Expand Down Expand Up @@ -57,12 +67,6 @@ const GraphExplorer = () => {
})
}
}, [execGraphRequest, tenant.defaultDomainName, query, tenantdomain])
const isValidDomain = (value) =>
/^(((?!-))(xn--|_{1,1})?[a-z0-9-]{0,61}[a-z0-9]{1,1}\.)*(xn--)?([a-z0-9][a-z0-9-]{0,60}|[a-z0-9-]{1,30}\.[a-z]{2,})$/i.test(
value,
)
? undefined
: value

return (
<CRow>
Expand All @@ -80,7 +84,7 @@ const GraphExplorer = () => {
render={({ handleSubmit, submitting, pristine }) => {
return (
<CForm onSubmit={handleSubmit}>
<Field name="domain" validate={isValidDomain}>
<Field name="domain" validate={isValidTenantInput}>
{({ input, meta }) => {
return (
<>
Expand Down

0 comments on commit bb28a63

Please sign in to comment.