Skip to content

Commit

Permalink
✨ [#4650] Add option to skip ownership checks to options UI
Browse files Browse the repository at this point in the history
  • Loading branch information
sergei-maertens committed Dec 31, 2024
1 parent cd450ed commit 34647c5
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ const PrefillSummary = ({
}
isOpen={modalOpen}
closeModal={() => setModalOpen(false)}
// FIXME: push this down to the plugin-specific components, somehow
extraModifiers={plugin === 'objects_api' ? ['large'] : undefined}
>
<ErrorBoundary>
<PrefillConfigurationForm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import ErrorBoundary from 'components/errors/ErrorBoundary';
import {get} from 'utils/fetch';

import CopyConfigurationFromRegistrationBackend from './CopyConfigurationFromRegistrationBackend';
import SkipOwnershipCheck from './SkipOwnershipCheck';
import useStatus from './useStatus';

const PLUGIN_ID = 'objects_api';
Expand Down Expand Up @@ -82,14 +83,15 @@ const ObjectsAPIFields = () => {
const {values, setFieldValue, setValues} = useFormikContext();
const {
plugin,
options: {objecttypeUuid, objecttypeVersion, objectsApiGroup},
options: {objecttypeUuid, objecttypeVersion, objectsApiGroup, skipOwnershipCheck},
} = values;
const {showCopyButton, toggleShowCopyButton} = useStatus();

const defaults = {
objectsApiGroup: null,
objecttypeUuid: '',
objecttypeVersion: null,
skipOwnershipCheck: false,
authAttributePath: undefined,
variablesMapping: [],
};
Expand Down Expand Up @@ -235,13 +237,26 @@ const ObjectsAPIFields = () => {
objectTypeFieldName="options.objecttypeUuid"
/>
</ErrorBoundary>
<AuthAttributePath
name={'options.authAttributePath'}
objectsApiGroup={objectsApiGroup}
objecttypeUuid={objecttypeUuid}
objecttypeVersion={objecttypeVersion}
required
/>
</Fieldset>

<Fieldset
title={
<FormattedMessage
description="Objects API ownership check fieldset title"
defaultMessage="Ownership checks"
/>
}
>
<SkipOwnershipCheck />
{!skipOwnershipCheck && (
<AuthAttributePath
name={'options.authAttributePath'}
objectsApiGroup={objectsApiGroup}
objecttypeUuid={objecttypeUuid}
objecttypeVersion={objecttypeVersion}
required
/>
)}
</Fieldset>

<Fieldset
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import {useField} from 'formik';
import {FormattedMessage} from 'react-intl';

import FormRow from 'components/admin/forms/FormRow';
import {Checkbox} from 'components/admin/forms/Inputs';

const SkipOwnershipCheck = () => {
const [fieldProps] = useField({name: 'options.skipOwnershipCheck', type: 'checkbox'});
return (
<FormRow>
<Checkbox
label={
<FormattedMessage
description="Objects API registration: skipOwnershipCheck label"
defaultMessage="Skip ownership check"
/>
}
helpText={
<FormattedMessage
description="Objects API registration: skipOwnershipCheck helpText"
defaultMessage={`If enabled, then no access control on the referenced object is performed.
Ensure that it does not contain private data before checking this!
`}
/>
}
{...fieldProps}
/>
</FormRow>
);
};

SkipOwnershipCheck.propTypes = {};

export default SkipOwnershipCheck;

0 comments on commit 34647c5

Please sign in to comment.