Skip to content

Commit 671145c

Browse files
✨ [#4650] Add option to skip ownership checks to options UI
1 parent 76436ad commit 671145c

File tree

3 files changed

+59
-8
lines changed

3 files changed

+59
-8
lines changed

src/openforms/js/components/admin/form_design/variables/prefill/PrefillSummary.js

+2
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ const PrefillSummary = ({
9494
}
9595
isOpen={modalOpen}
9696
closeModal={() => setModalOpen(false)}
97+
// FIXME: push this down to the plugin-specific components, somehow
98+
extraModifiers={plugin === 'objects_api' ? ['large'] : undefined}
9799
>
98100
<ErrorBoundary>
99101
<PrefillConfigurationForm

src/openforms/js/components/admin/form_design/variables/prefill/objects_api/ObjectsAPIFields.js

+23-8
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import ErrorBoundary from 'components/errors/ErrorBoundary';
2727
import {get} from 'utils/fetch';
2828

2929
import CopyConfigurationFromRegistrationBackend from './CopyConfigurationFromRegistrationBackend';
30+
import SkipOwnershipCheck from './SkipOwnershipCheck';
3031
import useStatus from './useStatus';
3132

3233
const PLUGIN_ID = 'objects_api';
@@ -82,14 +83,15 @@ const ObjectsAPIFields = () => {
8283
const {values, setFieldValue, setValues} = useFormikContext();
8384
const {
8485
plugin,
85-
options: {objecttypeUuid, objecttypeVersion, objectsApiGroup},
86+
options: {objecttypeUuid, objecttypeVersion, objectsApiGroup, skipOwnershipCheck},
8687
} = values;
8788
const {showCopyButton, toggleShowCopyButton} = useStatus();
8889

8990
const defaults = {
9091
objectsApiGroup: null,
9192
objecttypeUuid: '',
9293
objecttypeVersion: null,
94+
skipOwnershipCheck: false,
9395
authAttributePath: undefined,
9496
variablesMapping: [],
9597
};
@@ -235,13 +237,26 @@ const ObjectsAPIFields = () => {
235237
objectTypeFieldName="options.objecttypeUuid"
236238
/>
237239
</ErrorBoundary>
238-
<AuthAttributePath
239-
name={'options.authAttributePath'}
240-
objectsApiGroup={objectsApiGroup}
241-
objecttypeUuid={objecttypeUuid}
242-
objecttypeVersion={objecttypeVersion}
243-
required
244-
/>
240+
</Fieldset>
241+
242+
<Fieldset
243+
title={
244+
<FormattedMessage
245+
description="Objects API ownership check fieldset title"
246+
defaultMessage="Ownership checks"
247+
/>
248+
}
249+
>
250+
<SkipOwnershipCheck />
251+
{!skipOwnershipCheck && (
252+
<AuthAttributePath
253+
name={'options.authAttributePath'}
254+
objectsApiGroup={objectsApiGroup}
255+
objecttypeUuid={objecttypeUuid}
256+
objecttypeVersion={objecttypeVersion}
257+
required
258+
/>
259+
)}
245260
</Fieldset>
246261

247262
<Fieldset
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import {useField} from 'formik';
2+
import {FormattedMessage} from 'react-intl';
3+
4+
import FormRow from 'components/admin/forms/FormRow';
5+
import {Checkbox} from 'components/admin/forms/Inputs';
6+
7+
const SkipOwnershipCheck = () => {
8+
const [fieldProps] = useField({name: 'options.skipOwnershipCheck', type: 'checkbox'});
9+
return (
10+
<FormRow>
11+
<Checkbox
12+
label={
13+
<FormattedMessage
14+
description="Objects API registration: skipOwnershipCheck label"
15+
defaultMessage="Skip ownership check"
16+
/>
17+
}
18+
helpText={
19+
<FormattedMessage
20+
description="Objects API registration: skipOwnershipCheck helpText"
21+
defaultMessage={`If enabled, then no access control on the referenced object is performed.
22+
Ensure that it does not contain private data before checking this!
23+
`}
24+
/>
25+
}
26+
{...fieldProps}
27+
/>
28+
</FormRow>
29+
);
30+
};
31+
32+
SkipOwnershipCheck.propTypes = {};
33+
34+
export default SkipOwnershipCheck;

0 commit comments

Comments
 (0)