Skip to content

Commit

Permalink
Merge branch 'develop' into 20-merge-lz-infra
Browse files Browse the repository at this point in the history
  • Loading branch information
aloftus23 committed Aug 12, 2024
2 parents 5fb071a + c342b82 commit 59a27b0
Show file tree
Hide file tree
Showing 29 changed files with 1,361 additions and 1,634 deletions.
2 changes: 1 addition & 1 deletion backend/src/api/organizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ export const getRegion = async (organizationId: string) => {
*
*/
export const getAllV2 = wrapHandler(async (event) => {
if (!isRegionalAdmin(event)) return Unauthorized;
if (!isGlobalViewAdmin(event) && !isRegionalAdmin(event)) return Unauthorized;
const filterParams = {};

if (event.query && event.query.state) {
Expand Down
32 changes: 16 additions & 16 deletions backend/src/api/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,25 +243,25 @@ const sendInviteEmail = async (email: string, organization?: Organization) => {

await sendEmail(
email,
'Crossfeed Invitation',
'CyHy Dashboard Invitation',
`Hi there,
You've been invited to join ${
organization?.name ? `the ${organization?.name} organization on ` : ''
}Crossfeed. To accept the invitation and start using Crossfeed, sign on at ${
}CyHy Dashboard. To accept the invitation and start using CyHy Dashboard, sign on at ${
process.env.FRONTEND_DOMAIN
}/signup.
Crossfeed access instructions:
CyHy Dashboard access instructions:
1. Visit ${process.env.FRONTEND_DOMAIN}/signup.
2. Select "Create Account."
3. Enter your email address and a new password for Crossfeed.
3. Enter your email address and a new password for CyHy Dashboard.
4. A confirmation code will be sent to your email. Enter this code when you receive it.
5. You will be prompted to enable MFA. Scan the QR code with an authenticator app on your phone, such as Microsoft Authenticator. Enter the MFA code you see after scanning.
6. After configuring your account, you will be redirected to Crossfeed.
6. After configuring your account, you will be redirected to CyHy Dashboard.
For more information on using Crossfeed, view the Crossfeed user guide at https://docs.crossfeed.cyber.dhs.gov/user-guide/quickstart/.
For more information on using CyHy Dashboard, view the CyHy Dashboard user guide at https://docs.crossfeed.cyber.dhs.gov/user-guide/quickstart/.
If you encounter any difficulties, please feel free to reply to this email (or send an email to ${
process.env.CROSSFEED_SUPPORT_EMAIL_REPLYTO
Expand All @@ -279,16 +279,16 @@ const sendRSCInviteEmail = async (email: string) => {
You've been invited to join ReadySetCyber Dashboard. To accept the invitation and start using your Dashboard, sign on at ${process.env.FRONTEND_DOMAIN}/readysetcyber/create-account.
Crossfeed access instructions:
CyHy Dashboard access instructions:
1. Visit ${process.env.FRONTEND_DOMAIN}/readysetcyber/create-account.
2. Select "Create Account."
3. Enter your email address and a new password for Crossfeed.
3. Enter your email address and a new password for CyHy Dashboard.
4. A confirmation code will be sent to your email. Enter this code when you receive it.
5. You will be prompted to enable MFA. Scan the QR code with an authenticator app on your phone, such as Microsoft Authenticator. Enter the MFA code you see after scanning.
6. After configuring your account, you will be redirected to Crossfeed.
6. After configuring your account, you will be redirected to CyHy Dashboard.
For more information on using Crossfeed, view the Crossfeed user guide at https://docs.crossfeed.cyber.dhs.gov/user-guide/quickstart/.
For more information on using CyHy Dashboard, view the CyHy Dashboard user guide at https://docs.crossfeed.cyber.dhs.gov/user-guide/quickstart/.
If you encounter any difficulties, please feel free to reply to this email (or send an email to ${process.env.CROSSFEED_SUPPORT_EMAIL_REPLYTO}).`
);
Expand Down Expand Up @@ -450,7 +450,7 @@ export const acceptTerms = wrapHandler(async (event) => {
*
*/
export const list = wrapHandler(async (event) => {
if (!isGlobalViewAdmin(event)) return Unauthorized;
if (!isGlobalViewAdmin(event) && !isRegionalAdmin(event)) return Unauthorized;
await connectToDatabase();
const result = await User.find({
relations: ['roles', 'roles.organization']
Expand Down Expand Up @@ -591,7 +591,7 @@ export const register = wrapHandler(async (event) => {
// Send email notification
await sendUserRegistrationEmail(
savedUser.email,
'Crossfeed Registration Pending',
'CyHy Dashboard Registration Pending',
savedUser.firstName,
savedUser.lastName,
'crossfeed_registration_notification.html'
Expand Down Expand Up @@ -636,7 +636,7 @@ export const registrationApproval = wrapHandler(async (event) => {
// Send email notification
await sendRegistrationApprovedEmail(
user.email,
'Crossfeed Registration Approved',
'CyHy Dashboard Registration Approved',
user.firstName,
user.lastName,
'crossfeed_approval_notification.html'
Expand Down Expand Up @@ -681,7 +681,7 @@ export const registrationDenial = wrapHandler(async (event) => {

await sendRegistrationDeniedEmail(
user.email,
'Crossfeed Registration Denied',
'CyHy Dashboard Registration Denied',
user.firstName,
user.lastName,
'crossfeed_denial_notification.html'
Expand Down Expand Up @@ -798,9 +798,9 @@ export const inviteV2 = wrapHandler(async (event) => {

await sendEmail(
email,
'Crossfeed Registration',
'CyHy Dashboard Registration',
`Hello,
Your Crossfeed registration is under review.
Your CyHy Dashboard registration is under review.
You will receive an email when your registration is approved.
Thank you!`
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ export const Header: React.FC = () => {
{
title: 'Manage Users',
path: '/users',
users: GLOBAL_ADMIN,
users: REGIONAL_ADMIN,
exact: true
},
{
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/components/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useCallback, useEffect, useState } from 'react';
import React, { useEffect, useState } from 'react';
import { styled } from '@mui/material/styles';
import { useLocation } from 'react-router-dom';
import { Alert, ScopedCssBaseline } from '@mui/material';
import { ScopedCssBaseline } from '@mui/material';
import { Header, GovBanner } from 'components';
import { useUserActivityTimeout } from 'hooks/useUserActivityTimeout';
import { useAuthContext } from 'context/AuthContext';
Expand All @@ -19,7 +19,6 @@ export const Layout: React.FC<LayoutProps> = ({ children }) => {
const [loggedIn, setLoggedIn] = useState<boolean>(
user !== null && user !== undefined ? true : false
);
const [warningBannerText, setWarningBannerText] = useState<JSX.Element[]>([]);
const { isTimedOut, resetTimeout } = useUserActivityTimeout(
14 * 60 * 1000, // set to 14 minutes of inactivity to notify user
loggedIn
Expand Down
28 changes: 12 additions & 16 deletions frontend/src/components/OrganizationList/OrganizationList.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useCallback, useEffect, useState } from 'react';
import EditNoteOutlinedIcon from '@mui/icons-material/EditNoteOutlined';
import { Organization } from 'types';
import { Alert, Box, Button, IconButton, Paper } from '@mui/material';
import { Button, IconButton, Paper } from '@mui/material';
import { DataGrid, GridColDef, GridRenderCellParams } from '@mui/x-data-grid';
import { useHistory } from 'react-router-dom';
import { Add } from '@mui/icons-material';
Expand Down Expand Up @@ -107,20 +107,16 @@ export const OrganizationList: React.FC<{
);

return (
<Box mb={3}>
<Paper elevation={0}>
{organizations?.length === 0 ? (
<Alert severity="warning">Unable to load organizations.</Alert>
) : (
<DataGrid
rows={organizations}
columns={orgCols}
slots={{ toolbar: CustomToolbar }}
slotProps={{
toolbar: { children: addOrgButton }
}}
/>
)}
<>
<Paper elevation={2} sx={{ width: '100%' }}>
<DataGrid
rows={organizations}
columns={orgCols}
slots={{ toolbar: CustomToolbar }}
slotProps={{
toolbar: { children: addOrgButton }
}}
/>
</Paper>
<OrganizationForm
onSubmit={onSubmit}
Expand All @@ -129,6 +125,6 @@ export const OrganizationList: React.FC<{
type="create"
parent={parent}
></OrganizationForm>
</Box>
</>
);
};
15 changes: 13 additions & 2 deletions frontend/src/components/UserMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useHistory } from 'react-router-dom';
import { Box, Button, Menu, MenuItem } from '@mui/material';
import AccountCircleIcon from '@mui/icons-material/AccountCircle';
import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown';
import { useAuthContext } from 'context';

interface MenuItemType {
title: string;
Expand All @@ -18,6 +19,7 @@ interface Props {

export const UserMenu: React.FC<Props> = (props) => {
const { userMenuItems } = props;
const { user } = useAuthContext();
const history = useHistory();
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
const open = Boolean(anchorEl);
Expand All @@ -31,7 +33,16 @@ export const UserMenu: React.FC<Props> = (props) => {
handleClose();
history.push(path);
};

const filteredMenuItems = userMenuItems.filter((item) => {
const userType = user?.userType;
const userAccessLevel = item.users ?? 0;
return (
userType === 'globalAdmin' ||
((userType === 'regionalAdmin' || userType === 'globalView') &&
userAccessLevel <= 2) ||
userAccessLevel <= 1
);
});
return (
<Box ml={2}>
<Button
Expand All @@ -43,7 +54,7 @@ export const UserMenu: React.FC<Props> = (props) => {
My Account
</Button>
<Menu anchorEl={anchorEl} open={open} onClose={handleClose}>
{userMenuItems.map((item, index) => (
{filteredMenuItems.map((item, index) => (
<MenuItem
key={index}
onClick={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,6 @@ exports[`Layout component matches snapshot 1`] = `
<div
class="Layout-root"
>
<div
aria-label="warning label"
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation0 MuiAlert-root MuiAlert-standardWarning MuiAlert-standard css-to2f46-MuiPaper-root-MuiAlert-root"
role="alert"
>
<div
class="MuiAlert-icon css-1ytlwq5-MuiAlert-icon"
>
<svg
aria-hidden="true"
class="MuiSvgIcon-root MuiSvgIcon-fontSizeInherit css-1vooibu-MuiSvgIcon-root"
data-testid="ReportProblemOutlinedIcon"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M12 5.99L19.53 19H4.47L12 5.99M12 2L1 21h22L12 2zm1 14h-2v2h2v-2zm0-6h-2v4h2v-4z"
/>
</svg>
</div>
<div
class="MuiAlert-message css-1pxa9xg-MuiAlert-message"
>
<div />
</div>
</div>
<div
style="display: flex;"
>
Expand Down Expand Up @@ -100,19 +74,6 @@ exports[`Layout component matches snapshot 1`] = `
Home
</a>
</div>
<div
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-2 Footer-footerNavItem css-6vomyv-MuiGrid-root"
>
<p>
<a
class="MuiTypography-root MuiTypography-inherit MuiLink-root MuiLink-underlineAlways Footer-footerNavLink css-smdm7r-MuiTypography-root-MuiLink-root"
href="https://docs.crossfeed.cyber.dhs.gov/"
target="_blank"
>
Documentation
</a>
</p>
</div>
<div
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-2 Footer-footerNavItem css-6vomyv-MuiGrid-root"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,68 @@ export const STATE_ABBREVIATED_OPTIONS = [
'WI', // Wisconsin
'WY' // Wyoming
];

export type RegionStateMap = {
[key: string]: string;
};

export const REGION_STATE_MAP: RegionStateMap = {
Alabama: '4',
Alaska: '10',
'American Samoa': '9',
Arkansas: '6',
Arizona: '9',
California: '9',
Colorado: '8',
'Commonwealth Northern Mariana Islands': '9',
Connecticut: '1',
Delaware: '3',
'District of Columbia': '3',
'Federal States of Micronesia': '9',
Florida: '4',
Georgia: '4',
Guam: '9',
Hawaii: '9',
Idaho: '10',
Illinois: '5',
Indiana: '5',
Iowa: '7',
Kansas: '7',
Kentucky: '4',
Louisiana: '6',
Maine: '1',
Maryland: '3',
Massachusetts: '1',
Michigan: '5',
Minnesota: '5',
Mississippi: '4',
Missouri: '7',
Montana: '8',
Nebraska: '7',
Nevada: '9',
'New Hampshire': '1',
'New Jersey': '2',
'New Mexico': '6',
'New York': '2',
'North Carolina': '4',
'North Dakota': '8',
Ohio: '5',
Oklahoma: '6',
Oregon: '10',
Pennsylvania: '3',
'Puerto Rico': '2',
'Republic of Marshall Islands': '9',
'Rhode Island': '1',
'South Carolina': '4',
'South Dakota': '8',
Tennessee: '4',
Texas: '6',
Utah: '8',
Vermont: '1',
'Virgin Islands': '2',
Virginia: '3',
Washington: '10',
'West Virginia': '3',
Wisconsin: '5',
Wyoming: '8'
};
4 changes: 0 additions & 4 deletions frontend/src/context/userStateUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ export const getTouVersion = (maxRole: string) => {
};

export const getUserMustSign = (user: AuthUser | null, touVersion: string) => {
const approvedEmailAddresses = ['@cisa.dhs.gov', '@associates.cisa.dhs.gov'];
for (const email of approvedEmailAddresses) {
if (user?.email.endsWith(email)) return false;
}
return Boolean(
!user?.dateAcceptedTerms ||
(user.acceptedTermsVersion && user.acceptedTermsVersion !== touVersion)
Expand Down
Loading

0 comments on commit 59a27b0

Please sign in to comment.