mirror of
https://github.com/fleetdm/fleet
synced 2026-04-24 06:57:21 +00:00
> Related issue: #9956 # Checklist for submitter If some of the following don't apply, delete the relevant line. <!-- Note that API documentation changes are now addressed by the product design team. --> - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/Committing-Changes.md#changes-files) for more information. - [x] Input data is properly validated, `SELECT *` is avoided, SQL injection is prevented (using placeholders for values in statements) - [x] Added/updated tests - [x] If paths of existing endpoints are modified without backwards compatibility, checked the frontend/CLI for any necessary changes - [x] If database migrations are included, checked table schema to confirm autoupdate - For database migrations: - [x] Checked schema for all modified table for columns that will auto-update timestamps during migration. - [x] Confirmed that updating the timestamps is acceptable, and will not cause unwanted side effects. - [x] Ensured the correct collation is explicitly set for character columns (`COLLATE utf8mb4_unicode_ci`). - [x] Manual QA for all new/changed functionality --------- Co-authored-by: Martin Angers <martin.n.angers@gmail.com> Co-authored-by: Gabriel Hernandez <ghernandez345@gmail.com> Co-authored-by: Roberto Dip <rroperzh@gmail.com> Co-authored-by: Sarah Gillespie <73313222+gillespi314@users.noreply.github.com> Co-authored-by: Dante Catalfamo <43040593+dantecatalfamo@users.noreply.github.com> Co-authored-by: Roberto Dip <dip.jesusr@gmail.com>
117 lines
3.5 KiB
TypeScript
117 lines
3.5 KiB
TypeScript
import React from "react";
|
|
import { InjectedRouter } from "react-router";
|
|
import PATHS from "router/paths";
|
|
import { useQuery } from "react-query";
|
|
|
|
import configAPI from "services/entities/config";
|
|
import teamsAPI, { ILoadTeamResponse } from "services/entities/teams";
|
|
import { IConfig, IMdmConfig } from "interfaces/config";
|
|
import { ITeamConfig } from "interfaces/team";
|
|
|
|
import SectionHeader from "components/SectionHeader/SectionHeader";
|
|
import Spinner from "components/Spinner";
|
|
import EndUserExperiencePreview from "pages/ManageControlsPage/components/EndUserExperiencePreview";
|
|
|
|
import RequireEndUserAuth from "./components/RequireEndUserAuth/RequireEndUserAuth";
|
|
import EndUserAuthForm from "./components/EndUserAuthForm/EndUserAuthForm";
|
|
|
|
import OsSetupPreview from "../../../../../../assets/images/os-setup-preview.gif";
|
|
|
|
const baseClass = "end-user-authentication";
|
|
|
|
const getEnabledEndUserAuth = (
|
|
currentTeamId: number,
|
|
globalConfig?: IConfig,
|
|
teamConfig?: ITeamConfig
|
|
) => {
|
|
if (globalConfig === undefined && teamConfig === undefined) {
|
|
return false;
|
|
}
|
|
|
|
// team is "No team" when currentTeamId === 0
|
|
if (currentTeamId === 0) {
|
|
return (
|
|
globalConfig?.mdm?.macos_setup.enable_end_user_authentication ?? false
|
|
);
|
|
}
|
|
|
|
return teamConfig?.mdm?.macos_setup.enable_end_user_authentication ?? false;
|
|
};
|
|
|
|
const isIdPConfigured = ({
|
|
end_user_authentication: idp,
|
|
}: Pick<IMdmConfig, "end_user_authentication">) => {
|
|
return !!idp.entity_id && !!idp.metadata_url && !!idp.idp_name;
|
|
};
|
|
|
|
interface IEndUserAuthenticationProps {
|
|
currentTeamId: number;
|
|
router: InjectedRouter;
|
|
}
|
|
|
|
const EndUserAuthentication = ({
|
|
currentTeamId,
|
|
router,
|
|
}: IEndUserAuthenticationProps) => {
|
|
const { data: globalConfig, isLoading: isLoadingGlobalConfig } = useQuery<
|
|
IConfig,
|
|
Error
|
|
>(["config", currentTeamId], () => configAPI.loadAll(), {
|
|
refetchOnWindowFocus: false,
|
|
retry: false,
|
|
});
|
|
|
|
const { data: teamConfig, isLoading: isLoadingTeamConfig } = useQuery<
|
|
ILoadTeamResponse,
|
|
Error,
|
|
ITeamConfig
|
|
>(["team", currentTeamId], () => teamsAPI.load(currentTeamId), {
|
|
refetchOnWindowFocus: false,
|
|
retry: false,
|
|
enabled: currentTeamId !== 0,
|
|
select: (res) => res.team,
|
|
});
|
|
|
|
const defaultIsEndUserAuthEnabled = getEnabledEndUserAuth(
|
|
currentTeamId,
|
|
globalConfig,
|
|
teamConfig
|
|
);
|
|
|
|
const onClickConnect = () => {
|
|
router.push(PATHS.ADMIN_INTEGRATIONS_MDM);
|
|
};
|
|
|
|
return (
|
|
<div className={baseClass}>
|
|
<SectionHeader title="End user authentication" />
|
|
{isLoadingGlobalConfig || isLoadingTeamConfig ? (
|
|
<Spinner />
|
|
) : (
|
|
<div className={`${baseClass}__content`}>
|
|
{!globalConfig || !isIdPConfigured(globalConfig.mdm) ? (
|
|
<RequireEndUserAuth onClickConnect={onClickConnect} />
|
|
) : (
|
|
<EndUserAuthForm
|
|
currentTeamId={currentTeamId}
|
|
defaultIsEndUserAuthEnabled={defaultIsEndUserAuthEnabled}
|
|
/>
|
|
)}
|
|
<EndUserExperiencePreview previewImage={OsSetupPreview}>
|
|
<p>
|
|
When the end user reaches the <b>Remote Management</b> pane in the
|
|
macOS Setup Assistant, they are asked to authenticate and agree to
|
|
the end user license agreement (EULA).
|
|
</p>
|
|
<p>
|
|
After, Fleet enrolls the Mac, applies macOS settings, and installs
|
|
the bootstrap package.
|
|
</p>
|
|
</EndUserExperiencePreview>
|
|
</div>
|
|
)}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default EndUserAuthentication;
|