-
Notifications
You must be signed in to change notification settings - Fork 81
/
rootDNAccessControl.jsx
348 lines (332 loc) · 15.8 KB
/
rootDNAccessControl.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
import React from "react";
import { noop, FormGroup, FormControl, Row, Col, Form, ControlLabel } from "patternfly-react";
import { Typeahead } from "react-bootstrap-typeahead";
import PropTypes from "prop-types";
import PluginBasicConfig from "./pluginBasicConfig.jsx";
import "../../css/ds.css";
class RootDNAccessControl extends React.Component {
componentDidMount(prevProps) {
this.updateFields();
}
componentDidUpdate(prevProps) {
if (this.props.rows !== prevProps.rows) {
this.updateFields();
}
}
constructor(props) {
super(props);
this.state = {
allowHost: [],
denyHost: [],
allowIP: [],
denyIP: [],
openTime: "",
closeTime: "",
daysAllowed: ""
};
this.updateFields = this.updateFields.bind(this);
this.handleFieldChange = this.handleFieldChange.bind(this);
}
handleFieldChange(e) {
this.setState({
[e.target.id]: e.target.value
});
}
updateFields() {
let allowHostList = [];
let denyHostList = [];
let allowIPList = [];
let denyIPList = [];
if (this.props.rows.length > 0) {
const pluginRow = this.props.rows.find(row => row.cn[0] === "RootDN Access Control");
this.setState({
openTime:
pluginRow["rootdn-open-time"] === undefined
? ""
: pluginRow["rootdn-open-time"][0],
closeTime:
pluginRow["rootdn-close-time"] === undefined
? ""
: pluginRow["rootdn-close-time"][0],
daysAllowed:
pluginRow["rootdn-days-allowed"] === undefined
? ""
: pluginRow["rootdn-days-allowed"][0]
});
if (pluginRow["rootdn-allow-host"] === undefined) {
this.setState({ allowHost: [] });
} else {
for (let value of pluginRow["rootdn-allow-host"]) {
allowHostList = [...allowHostList, value];
}
this.setState({ allowHost: allowHostList });
}
if (pluginRow["rootdn-deny-host"] === undefined) {
this.setState({ denyHost: [] });
} else {
for (let value of pluginRow["rootdn-deny-host"]) {
denyHostList = [...denyHostList, value];
}
this.setState({ denyHost: denyHostList });
}
if (pluginRow["rootdn-allow-ip"] === undefined) {
this.setState({ allowIP: [] });
} else {
for (let value of pluginRow["rootdn-allow-ip"]) {
allowIPList = [...allowIPList, value];
}
this.setState({ allowIP: allowIPList });
}
if (pluginRow["rootdn-deny-ip"] === undefined) {
this.setState({ denyIP: [] });
} else {
for (let value of pluginRow["rootdn-deny-ip"]) {
denyIPList = [...denyIPList, value];
}
this.setState({ denyIP: denyIPList });
}
}
}
render() {
const {
allowHost,
denyHost,
allowIP,
denyIP,
openTime,
closeTime,
daysAllowed
} = this.state;
let specificPluginCMD = [
"dsconf",
"-j",
"ldapi://%2fvar%2frun%2fslapd-" + this.props.serverId + ".socket",
"plugin",
"root-dn",
"set",
"--open-time",
openTime || "delete",
"--close-time",
closeTime || "delete",
"--days-allowed",
daysAllowed || "delete"
];
// Delete attributes if the user set an empty value to the field
specificPluginCMD = [...specificPluginCMD, "--allow-host"];
if (allowHost.length != 0) {
for (let value of allowHost) {
specificPluginCMD = [...specificPluginCMD, value];
}
} else {
specificPluginCMD = [...specificPluginCMD, "delete"];
}
specificPluginCMD = [...specificPluginCMD, "--deny-host"];
if (denyHost.length != 0) {
for (let value of denyHost) {
specificPluginCMD = [...specificPluginCMD, value];
}
} else {
specificPluginCMD = [...specificPluginCMD, "delete"];
}
specificPluginCMD = [...specificPluginCMD, "--allow-ip"];
if (allowIP.length != 0) {
for (let value of allowIP) {
specificPluginCMD = [...specificPluginCMD, value];
}
} else {
specificPluginCMD = [...specificPluginCMD, "delete"];
}
specificPluginCMD = [...specificPluginCMD, "--allow-host"];
if (allowHost.length != 0) {
for (let value of allowHost) {
specificPluginCMD = [...specificPluginCMD, value];
}
} else {
specificPluginCMD = [...specificPluginCMD, "delete"];
}
return (
<div>
<PluginBasicConfig
rows={this.props.rows}
serverId={this.props.serverId}
cn="RootDN Access Control"
pluginName="RootDN Access Control"
cmdName="root-dn"
specificPluginCMD={specificPluginCMD}
savePluginHandler={this.props.savePluginHandler}
pluginListHandler={this.props.pluginListHandler}
addNotification={this.props.addNotification}
toggleLoadingHandler={this.props.toggleLoadingHandler}
>
<Row>
<Col sm={12}>
<Form horizontal>
<FormGroup key="allowHost" controlId="allowHost">
<Col
componentClass={ControlLabel}
sm={3}
title="Sets what hosts, by fully-qualified domain name, the root user is allowed to use to access the Directory Server. Any hosts not listed are implicitly denied (rootdn-allow-host)"
>
Allow Host
</Col>
<Col sm={6}>
<Typeahead
allowNew
multiple
onChange={value => {
this.setState({
allowHost: value
});
}}
selected={allowHost}
options={[]}
newSelectionPrefix="Add a host to allow: "
placeholder="Type a hostname (wild cards are allowed)..."
/>
</Col>
</FormGroup>
<FormGroup key="denyHost" controlId="denyHost">
<Col
componentClass={ControlLabel}
sm={3}
title="Sets what hosts, by fully-qualified domain name, the root user is not allowed to use to access the Directory Server Any hosts not listed are implicitly allowed (rootdn-deny-host). If an host address is listed in both the rootdn-allow-host and rootdn-deny-host attributes, it is denied access."
>
Deny Host
</Col>
<Col sm={6}>
<Typeahead
allowNew
multiple
onChange={value => {
this.setState({
denyHost: value
});
}}
selected={denyHost}
options={[]}
newSelectionPrefix="Add a host to deny: "
placeholder="Type a hostname (wild cards are allowed)..."
/>
</Col>
</FormGroup>
<FormGroup key="allowIP" controlId="allowIP">
<Col
componentClass={ControlLabel}
sm={3}
title="Sets what IP addresses, either IPv4 or IPv6, for machines the root user is allowed to use to access the Directory Server Any IP addresses not listed are implicitly denied (rootdn-allow-ip)"
>
Allow IP address
</Col>
<Col sm={6}>
<Typeahead
allowNew
multiple
onChange={value => {
this.setState({
allowIP: value
});
}}
selected={allowIP}
options={[]}
newSelectionPrefix="Add an IP address to allow: "
placeholder="Type an IP address (wild cards are allowed)..."
/>
</Col>
</FormGroup>
<FormGroup key="denyIP" controlId="denyIP">
<Col
componentClass={ControlLabel}
sm={3}
title="Sets what IP addresses, either IPv4 or IPv6, for machines the root user is not allowed to use to access the Directory Server. Any IP addresses not listed are implicitly allowed (rootdn-deny-ip) If an IP address is listed in both the rootdn-allow-ip and rootdn-deny-ip attributes, it is denied access."
>
Deny IP address
</Col>
<Col sm={6}>
<Typeahead
allowNew
multiple
onChange={value => {
this.setState({
denyIP: value
});
}}
selected={denyIP}
options={[]}
newSelectionPrefix="Add an IP address to deny: "
placeholder="Type an IP address (wild cards are allowed)..."
/>
</Col>
</FormGroup>
<FormGroup key="openTime" controlId="openTime">
<Col
componentClass={ControlLabel}
sm={3}
title="Sets part of a time period or range when the root user is allowed to access the Directory Server. This sets when the time-based access begins (rootdn-open-time)"
>
Open Time
</Col>
<Col sm={6}>
<FormControl
type="text"
value={openTime}
onChange={this.handleFieldChange}
/>
</Col>
</FormGroup>
<FormGroup key="closeTime" controlId="closeTime">
<Col
componentClass={ControlLabel}
sm={3}
title="Sets part of a time period or range when the root user is allowed to access the Directory Server. This sets when the time-based access ends (rootdn-close-time)"
>
Close Time
</Col>
<Col sm={6}>
<FormControl
type="text"
value={closeTime}
onChange={this.handleFieldChange}
/>
</Col>
</FormGroup>
<FormGroup key="daysAllowed" controlId="daysAllowed">
<Col
componentClass={ControlLabel}
sm={3}
title="Gives a comma-separated list of what days the root user is allowed to use to access the Directory Server. Any days listed are implicitly denied (rootdn-days-allowed)"
>
Days Allowed
</Col>
<Col sm={6}>
<FormControl
type="text"
value={daysAllowed}
onChange={this.handleFieldChange}
/>
</Col>
</FormGroup>
</Form>
</Col>
</Row>
</PluginBasicConfig>
</div>
);
}
}
RootDNAccessControl.propTypes = {
rows: PropTypes.array,
serverId: PropTypes.string,
savePluginHandler: PropTypes.func,
pluginListHandler: PropTypes.func,
addNotification: PropTypes.func,
toggleLoadingHandler: PropTypes.func
};
RootDNAccessControl.defaultProps = {
rows: [],
serverId: "",
savePluginHandler: noop,
pluginListHandler: noop,
addNotification: noop,
toggleLoadingHandler: noop
};
export default RootDNAccessControl;