Skip to content

Commit 1e1c11b

Browse files
bexsoftBenjamin Perez
andauthored
Added FSGroupChangePolicy support to create tenant screen (#2233)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net> Signed-off-by: Benjamin Perez <benjamin@bexsoft.net> Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
1 parent 25c1c85 commit 1e1c11b

File tree

11 files changed

+197
-10
lines changed

11 files changed

+197
-10
lines changed

operatorapi/tenants_helper.go

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,14 @@ func convertModelSCToK8sSC(sc *models.SecurityContext) (*corev1.PodSecurityConte
5858
if err != nil {
5959
return nil, err
6060
}
61+
FSGroupChangePolicy := corev1.PodFSGroupChangePolicy(sc.FsGroupChangePolicy)
62+
6163
return &corev1.PodSecurityContext{
62-
RunAsUser: &runAsUser,
63-
RunAsGroup: &runAsGroup,
64-
RunAsNonRoot: sc.RunAsNonRoot,
65-
FSGroup: &fsGroup,
64+
RunAsUser: &runAsUser,
65+
RunAsGroup: &runAsGroup,
66+
RunAsNonRoot: sc.RunAsNonRoot,
67+
FSGroup: &fsGroup,
68+
FSGroupChangePolicy: &FSGroupChangePolicy,
6669
}, nil
6770
}
6871

@@ -71,11 +74,18 @@ func convertK8sSCToModelSC(sc *corev1.PodSecurityContext) *models.SecurityContex
7174
runAsUser := strconv.FormatInt(*sc.RunAsUser, 10)
7275
runAsGroup := strconv.FormatInt(*sc.RunAsGroup, 10)
7376
fsGroup := strconv.FormatInt(*sc.FSGroup, 10)
77+
fsGroupPolicy := ""
78+
79+
if sc.FSGroupChangePolicy != nil {
80+
fsGroupPolicy = string(*sc.FSGroupChangePolicy)
81+
}
82+
7483
return &models.SecurityContext{
75-
RunAsUser: &runAsUser,
76-
RunAsGroup: &runAsGroup,
77-
RunAsNonRoot: sc.RunAsNonRoot,
78-
FsGroup: fsGroup,
84+
RunAsUser: &runAsUser,
85+
RunAsGroup: &runAsGroup,
86+
RunAsNonRoot: sc.RunAsNonRoot,
87+
FsGroup: fsGroup,
88+
FsGroupChangePolicy: fsGroupPolicy,
7989
}
8090
}
8191

portal-ui/src/screens/Console/Tenants/AddTenant/Steps/ConfigLogSearch.tsx

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,13 @@ const ConfigLogSearch = ({ classes }: IConfigureProps) => {
400400
min="0"
401401
/>
402402
</div>
403+
</div>
404+
</Grid>
405+
<br />
406+
<Grid item xs={12}>
407+
<div
408+
className={`${classes.multiContainer} ${classes.responsiveSectionItem}`}
409+
>
403410
<div className={classes.configSectionItem}>
404411
<InputBoxWrapper
405412
type="number"
@@ -422,6 +429,30 @@ const ConfigLogSearch = ({ classes }: IConfigureProps) => {
422429
min="0"
423430
/>
424431
</div>
432+
<div className={classes.configSectionItem}>
433+
<SelectWrapper
434+
label="FsGroupChangePolicy"
435+
id="securityContext_fsGroupChangePolicy"
436+
name="securityContext_fsGroupChangePolicy"
437+
value={logSearchSecurityContext.fsGroupChangePolicy}
438+
onChange={(e: SelectChangeEvent<string>) => {
439+
updateField("logSearchSecurityContext", {
440+
...logSearchSecurityContext,
441+
fsGroupChangePolicy: e.target.value,
442+
});
443+
}}
444+
options={[
445+
{
446+
label: "Always",
447+
value: "Always",
448+
},
449+
{
450+
label: "OnRootMismatch",
451+
value: "OnRootMismatch",
452+
},
453+
]}
454+
/>
455+
</div>
425456
</div>
426457
</Grid>
427458
<br />
@@ -500,6 +531,13 @@ const ConfigLogSearch = ({ classes }: IConfigureProps) => {
500531
min="0"
501532
/>
502533
</div>
534+
</div>
535+
</Grid>
536+
<br />
537+
<Grid item xs={12}>
538+
<div
539+
className={`${classes.multiContainer} ${classes.responsiveSectionItem}`}
540+
>
503541
<div className={classes.configSectionItem}>
504542
<InputBoxWrapper
505543
type="number"
@@ -522,6 +560,32 @@ const ConfigLogSearch = ({ classes }: IConfigureProps) => {
522560
min="0"
523561
/>
524562
</div>
563+
<div className={classes.configSectionItem}>
564+
<SelectWrapper
565+
label="FsGroupChangePolicy"
566+
id="securityContext_fsGroupChangePolicy"
567+
name="securityContext_fsGroupChangePolicy"
568+
value={
569+
logSearchPostgresSecurityContext.fsGroupChangePolicy
570+
}
571+
onChange={(e: SelectChangeEvent<string>) => {
572+
updateField("logSearchPostgresSecurityContext", {
573+
...logSearchPostgresSecurityContext,
574+
fsGroupChangePolicy: e.target.value,
575+
});
576+
}}
577+
options={[
578+
{
579+
label: "Always",
580+
value: "Always",
581+
},
582+
{
583+
label: "OnRootMismatch",
584+
value: "OnRootMismatch",
585+
},
586+
]}
587+
/>
588+
</div>
525589
</div>
526590
</Grid>
527591
<br />

portal-ui/src/screens/Console/Tenants/AddTenant/Steps/ConfigPrometheus.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,13 @@ const ConfigPrometheus = ({ classes }: IConfigureProps) => {
368368
min="0"
369369
/>
370370
</div>
371+
</div>
372+
</Grid>
373+
<br />
374+
<Grid item xs={12} className={classes.configSectionItem}>
375+
<div
376+
className={`${classes.multiContainer} ${classes.responsiveSectionItem}`}
377+
>
371378
<div className={classes.configSectionItem}>
372379
<InputBoxWrapper
373380
type="number"
@@ -391,8 +398,33 @@ const ConfigPrometheus = ({ classes }: IConfigureProps) => {
391398
min="0"
392399
/>
393400
</div>
401+
<div className={classes.configSectionItem}>
402+
<SelectWrapper
403+
label="FsGroupChangePolicy"
404+
id="securityContext_fsGroupChangePolicy"
405+
name="securityContext_fsGroupChangePolicy"
406+
value={prometheusSecurityContext.fsGroupChangePolicy}
407+
onChange={(e: SelectChangeEvent<string>) => {
408+
updateField("prometheusSecurityContext", {
409+
...prometheusSecurityContext,
410+
fsGroupChangePolicy: e.target.value,
411+
});
412+
}}
413+
options={[
414+
{
415+
label: "Always",
416+
value: "Always",
417+
},
418+
{
419+
label: "OnRootMismatch",
420+
value: "OnRootMismatch",
421+
},
422+
]}
423+
/>
424+
</div>
394425
</div>
395426
</Grid>
427+
<br />
396428
<Grid item xs={12} className={classes.configSectionItem}>
397429
<div
398430
className={`${classes.multiContainer} ${classes.fieldSpaceTop}`}

portal-ui/src/screens/Console/Tenants/AddTenant/Steps/Configure.tsx

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { useSelector } from "react-redux";
1919
import { Theme } from "@mui/material/styles";
2020
import createStyles from "@mui/styles/createStyles";
2121
import withStyles from "@mui/styles/withStyles";
22-
import { Grid, IconButton, Paper } from "@mui/material";
22+
import { Grid, IconButton, Paper, SelectChangeEvent } from "@mui/material";
2323
import {
2424
createTenantCommon,
2525
modalBasic,
@@ -42,6 +42,7 @@ import {
4242
removeMinIODomain,
4343
updateAddField,
4444
} from "../createTenantSlice";
45+
import SelectWrapper from "../../../Common/FormComponents/SelectWrapper/SelectWrapper";
4546

4647
interface IConfigureProps {
4748
classes: any;
@@ -438,6 +439,13 @@ const Configure = ({ classes }: IConfigureProps) => {
438439
min="0"
439440
/>
440441
</div>
442+
</div>
443+
</Grid>
444+
<br />
445+
<Grid item xs={12} className={`${classes.configSectionItem}`}>
446+
<div
447+
className={`${classes.multiContainer} ${classes.responsiveSectionItem}`}
448+
>
441449
<div className={classes.containerItem}>
442450
<InputBoxWrapper
443451
type="number"
@@ -459,6 +467,32 @@ const Configure = ({ classes }: IConfigureProps) => {
459467
min="0"
460468
/>
461469
</div>
470+
<div className={classes.containerItem}>
471+
<div className={classes.configSectionItem}>
472+
<SelectWrapper
473+
label="FsGroupChangePolicy"
474+
id="securityContext_fsGroupChangePolicy"
475+
name="securityContext_fsGroupChangePolicy"
476+
value={tenantSecurityContext.fsGroupChangePolicy}
477+
onChange={(e: SelectChangeEvent<string>) => {
478+
updateField("tenantSecurityContext", {
479+
...tenantSecurityContext,
480+
fsGroupChangePolicy: e.target.value,
481+
});
482+
}}
483+
options={[
484+
{
485+
label: "Always",
486+
value: "Always",
487+
},
488+
{
489+
label: "OnRootMismatch",
490+
value: "OnRootMismatch",
491+
},
492+
]}
493+
/>
494+
</div>
495+
</div>
462496
</div>
463497
</Grid>
464498
<br />

portal-ui/src/screens/Console/Tenants/AddTenant/Steps/Encryption.tsx

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { useSelector } from "react-redux";
1919
import { Theme } from "@mui/material/styles";
2020
import createStyles from "@mui/styles/createStyles";
2121
import withStyles from "@mui/styles/withStyles";
22-
import { Paper } from "@mui/material";
22+
import { Paper, SelectChangeEvent } from "@mui/material";
2323
import Grid from "@mui/material/Grid";
2424

2525
import {
@@ -50,6 +50,7 @@ import AzureKMSAdd from "./Encryption/AzureKMSAdd";
5050
import GCPKMSAdd from "./Encryption/GCPKMSAdd";
5151
import GemaltoKMSAdd from "./Encryption/GemaltoKMSAdd";
5252
import AWSKMSAdd from "./Encryption/AWSKMSAdd";
53+
import SelectWrapper from "../../../Common/FormComponents/SelectWrapper/SelectWrapper";
5354

5455
interface IEncryptionProps {
5556
classes: any;
@@ -525,6 +526,13 @@ const Encryption = ({ classes }: IEncryptionProps) => {
525526
min="0"
526527
/>
527528
</div>
529+
</div>
530+
</Grid>
531+
<br />
532+
<Grid item xs={12} className={classes.kesSecurityContext}>
533+
<div
534+
className={`${classes.multiContainer} ${classes.responsiveContainer}`}
535+
>
528536
<div
529537
className={`${classes.formFieldRow} ${classes.rightSpacer}`}
530538
>
@@ -548,6 +556,32 @@ const Encryption = ({ classes }: IEncryptionProps) => {
548556
min="0"
549557
/>
550558
</div>
559+
<div
560+
className={`${classes.formFieldRow} ${classes.rightSpacer}`}
561+
>
562+
<SelectWrapper
563+
label="FsGroupChangePolicy"
564+
id="securityContext_fsGroupChangePolicy"
565+
name="securityContext_fsGroupChangePolicy"
566+
value={kesSecurityContext.fsGroupChangePolicy}
567+
onChange={(e: SelectChangeEvent<string>) => {
568+
updateField("kesSecurityContext", {
569+
...kesSecurityContext,
570+
fsGroupChangePolicy: e.target.value,
571+
});
572+
}}
573+
options={[
574+
{
575+
label: "Always",
576+
value: "Always",
577+
},
578+
{
579+
label: "OnRootMismatch",
580+
value: "OnRootMismatch",
581+
},
582+
]}
583+
/>
584+
</div>
551585
</div>
552586
</Grid>
553587
<br />

portal-ui/src/screens/Console/Tenants/AddTenant/createTenantSlice.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,24 +125,28 @@ const initialState: ICreateTenant = {
125125
runAsUser: "1000",
126126
runAsGroup: "1000",
127127
fsGroup: "1000",
128+
fsGroupChangePolicy: "Always",
128129
runAsNonRoot: true,
129130
},
130131
logSearchSecurityContext: {
131132
runAsUser: "1000",
132133
runAsGroup: "1000",
133134
fsGroup: "1000",
135+
fsGroupChangePolicy: "Always",
134136
runAsNonRoot: true,
135137
},
136138
logSearchPostgresSecurityContext: {
137139
runAsUser: "999",
138140
runAsGroup: "999",
139141
fsGroup: "999",
142+
fsGroupChangePolicy: "Always",
140143
runAsNonRoot: true,
141144
},
142145
prometheusSecurityContext: {
143146
runAsUser: "1000",
144147
runAsGroup: "1000",
145148
fsGroup: "1000",
149+
fsGroupChangePolicy: "Always",
146150
runAsNonRoot: true,
147151
},
148152
},
@@ -212,6 +216,7 @@ const initialState: ICreateTenant = {
212216
runAsUser: "1000",
213217
runAsGroup: "1000",
214218
fsGroup: "1000",
219+
fsGroupChangePolicy: "Always",
215220
runAsNonRoot: true,
216221
},
217222
},

portal-ui/src/screens/Console/Tenants/TenantDetails/Pools/AddPool/addPoolSlice.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ const initialState: IAddPool = {
6868
runAsUser: "1000",
6969
runAsGroup: "1000",
7070
fsGroup: "1000",
71+
fsGroupChangePolicy: "Always",
7172
runAsNonRoot: true,
7273
},
7374
},

portal-ui/src/screens/Console/Tenants/TenantDetails/Pools/EditPool/editPoolSlice.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const initialState: IEditPool = {
5050
runAsUser: "1000",
5151
runAsGroup: "1000",
5252
fsGroup: "1000",
53+
fsGroupChangePolicy: "Always",
5354
runAsNonRoot: true,
5455
},
5556
},
@@ -151,6 +152,8 @@ export const editPoolSlice = createSlice({
151152
runAsUser: action.payload.securityContext?.runAsUser || "",
152153
runAsGroup: action.payload.securityContext?.runAsGroup || "",
153154
fsGroup: action.payload.securityContext?.fsGroup || "",
155+
fsGroupChangePolicy:
156+
action.payload.securityContext?.fsGroupChangePolicy || "Always",
154157
runAsNonRoot: !!action.payload.securityContext?.runAsNonRoot,
155158
},
156159
},

portal-ui/src/screens/Console/Tenants/TenantDetails/TenantEncryption.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ const TenantEncryption = ({ classes }: ITenantEncryption) => {
9797
useState<boolean>(false);
9898
const [securityContext, setSecurityContext] = useState<ISecurityContext>({
9999
fsGroup: "1000",
100+
fsGroupChangePolicy: "Always",
100101
runAsGroup: "1000",
101102
runAsNonRoot: true,
102103
runAsUser: "1000",

portal-ui/src/screens/Console/Tenants/TenantDetails/tenantAuditLogSlice.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,14 @@ const initialState: IEditTenantAuditLogging = {
6262
runAsUser: "1000",
6363
runAsGroup: "1000",
6464
fsGroup: "1000",
65+
fsGroupChangePolicy: "Always",
6566
runAsNonRoot: false,
6667
},
6768
dbSecurityContext: {
6869
runAsUser: "1000",
6970
runAsGroup: "1000",
7071
fsGroup: "1000",
72+
fsGroupChangePolicy: "Always",
7173
runAsNonRoot: false,
7274
},
7375
refreshLoggingInfo: true,

0 commit comments

Comments
 (0)