Skip to content

Commit 1bad4c3

Browse files
authored
Add KMS UI (#2377)
Adds components to interact with KMS server connected to minio
1 parent 9edb579 commit 1bad4c3

File tree

21 files changed

+1657
-99
lines changed

21 files changed

+1657
-99
lines changed

models/kms_latency_histogram.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

models/kms_metrics_response.go

Lines changed: 27 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

portal-ui/src/common/SecureComponent/permissions.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,26 @@ export const IAM_SCOPES = {
113113
ADMIN_INSPECT_DATA: "admin:InspectData",
114114
S3_ALL_ACTIONS: "s3:*",
115115
ADMIN_ALL_ACTIONS: "admin:*",
116+
KMS_ALL_ACTIONS: "kms:*",
117+
KMS_STATUS: "kms:Status",
118+
KMS_METRICS: "kms:Metrics",
119+
KMS_APIS: "kms:API",
120+
KMS_Version: "kms:Version",
121+
KMS_CREATE_KEY: "kms:CreateKey",
122+
KMS_DELETE_KEY: "kms:DeleteKey",
123+
KMS_LIST_KEYS: "kms:ListKeys",
124+
KMS_IMPORT_KEY: "kms:ImportKey",
125+
KMS_KEY_STATUS: "kms:KeyStatus",
126+
KMS_DESCRIBE_POLICY: "kms:DescribePolicy",
127+
KMS_ASSIGN_POLICY: "kms:AssignPolicy",
128+
KMS_DELETE_POLICY: "kms:DeletePolicy",
129+
KMS_SET_POLICY: "kms:SetPolicy",
130+
KMS_GET_POLICY: "kms:GetPolicy",
131+
KMS_LIST_POLICIES: "kms:ListPolicies",
132+
KMS_DESCRIBE_IDENTITY: "kms:DescribeIdentity",
133+
KMS_DESCRIBE_SELF_IDENTITY: "kms:DescribeSelfIdentity",
134+
KMS_DELETE_IDENTITY: "kms:DeleteIdentity",
135+
KMS_LIST_IDENTITIES: "kms:ListIdentities",
116136
};
117137

118138
export const IAM_PAGES = {
@@ -160,6 +180,13 @@ export const IAM_PAGES = {
160180
/* Health */
161181
HEALTH: "/health",
162182

183+
/* KMS */
184+
KMS: "/kms",
185+
KMS_STATUS: "/kms/status",
186+
KMS_KEYS: "/kms/keys",
187+
KMS_KEYS_ADD: "/kms/add-key/",
188+
KMS_KEYS_IMPORT: "/kms/import-key/",
189+
163190
/* Support */
164191
TOOLS: "/support",
165192
REGISTER_SUPPORT: "/support/register",
@@ -454,6 +481,24 @@ export const IAM_PAGES_PERMISSIONS = {
454481
IAM_SCOPES.ADMIN_SERVER_INFO,
455482
IAM_SCOPES.ADMIN_CONFIG_UPDATE,
456483
],
484+
[IAM_PAGES.KMS]: [IAM_SCOPES.KMS_ALL_ACTIONS],
485+
[IAM_PAGES.KMS_STATUS]: [IAM_SCOPES.KMS_ALL_ACTIONS, IAM_SCOPES.KMS_STATUS],
486+
[IAM_PAGES.KMS_KEYS]: [
487+
IAM_SCOPES.KMS_ALL_ACTIONS,
488+
IAM_SCOPES.KMS_CREATE_KEY,
489+
IAM_SCOPES.KMS_DELETE_KEY,
490+
IAM_SCOPES.KMS_LIST_KEYS,
491+
IAM_SCOPES.KMS_IMPORT_KEY,
492+
IAM_SCOPES.KMS_KEY_STATUS,
493+
],
494+
[IAM_PAGES.KMS_KEYS_ADD]: [
495+
IAM_SCOPES.KMS_ALL_ACTIONS,
496+
IAM_SCOPES.KMS_CREATE_KEY,
497+
],
498+
[IAM_PAGES.KMS_KEYS_IMPORT]: [
499+
IAM_SCOPES.KMS_ALL_ACTIONS,
500+
IAM_SCOPES.KMS_IMPORT_KEY,
501+
],
457502
[IAM_PAGES.IDP_LDAP_CONFIGURATIONS]: [
458503
IAM_SCOPES.ADMIN_ALL_ACTIONS,
459504
IAM_SCOPES.ADMIN_CONFIG_UPDATE,
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// This file is part of MinIO Console Server
2+
// Copyright (c) 2022 MinIO, Inc.
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Affero General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Affero General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU Affero General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
import * as React from "react";
18+
import { SVGProps } from "react";
19+
20+
const EncryptionIcon = (props: SVGProps<SVGSVGElement>) => (
21+
<svg
22+
xmlns="http://www.w3.org/2000/svg"
23+
width="255.209"
24+
height="255.209"
25+
viewBox="0 0 255.209 255.209"
26+
className={`min-icon`}
27+
fill={"currentcolor"}
28+
{...props}
29+
>
30+
<path
31+
id="KMS"
32+
d="M175.664,255.209V228.695H79.546v26.515H46.4V228.695H3a3,3,0,0,1-3-3V3A3,3,0,0,1,3,0H252.21a3,3,0,0,1,3,3V225.694a3,3,0,0,1-3,3h-43.4v26.515ZM23.2,29.83V198.865a9.954,9.954,0,0,0,9.943,9.943H222.065a9.954,9.954,0,0,0,9.943-9.943V29.83a9.954,9.954,0,0,0-9.943-9.943H33.144A9.954,9.954,0,0,0,23.2,29.83ZM222.065,198.866h0Zm-188.921,0V29.83H222.065V198.865H33.144ZM69.224,88.258a26.52,26.52,0,1,0,34.909,34.375h33.071a2,2,0,0,0,2-2V104.747a2,2,0,0,0-2-2H104.134A26.545,26.545,0,0,0,69.224,88.258ZM59.659,112.69a19.886,19.886,0,1,1,19.886,19.886A19.887,19.887,0,0,1,59.659,112.69Z"
33+
/>
34+
</svg>
35+
);
36+
37+
export default EncryptionIcon;
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// This file is part of MinIO Console Server
2+
// Copyright (c) 2022 MinIO, Inc.
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Affero General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Affero General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU Affero General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
import * as React from "react";
18+
import { SVGProps } from "react";
19+
20+
const EncryptionStatusIcon = (props: SVGProps<SVGSVGElement>) => (
21+
<svg
22+
xmlns="http://www.w3.org/2000/svg"
23+
width="256"
24+
height="162.281"
25+
viewBox="0 0 256 162.281"
26+
className={`min-icon`}
27+
fill={"currentcolor"}
28+
{...props}
29+
>
30+
<path
31+
id="KMS-status"
32+
d="M-13110.45-17976.135a8.3,8.3,0,0,1-7.6-4.979l-30.661-70.426h-41.776a8.3,8.3,0,0,1-8.292-8.3,8.3,8.3,0,0,1,8.292-8.3h47.211a8.289,8.289,0,0,1,7.6,4.98l23.306,53.533,32.412-122.619a8.3,8.3,0,0,1,8.017-6.178h.074a8.293,8.293,0,0,1,7.978,6.336l23.061,94.307,25.367-45.307a8.267,8.267,0,0,1,7.232-4.254c.136,0,.276,0,.416.01a8.315,8.315,0,0,1,7.189,4.979l20.733,47.732h28.818a8.292,8.292,0,0,1,8.293,8.287,8.294,8.294,0,0,1-8.293,8.3h-34.254a8.273,8.273,0,0,1-7.6-4.988l-16.239-37.379-27.48,49.107a8.274,8.274,0,0,1-7.233,4.244,9.94,9.94,0,0,1-1.12-.07,8.309,8.309,0,0,1-6.936-6.258l-20.317-83.1-30.171,114.166a8.3,8.3,0,0,1-7.387,6.152C-13110.021-17976.143-13110.24-17976.135-13110.45-17976.135Z"
33+
transform="translate(13198.776 18138.416)"
34+
/>
35+
</svg>
36+
);
37+
38+
export default EncryptionStatusIcon;
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
// This file is part of MinIO Console Server
2+
// Copyright (c) 2022 MinIO, Inc.
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Affero General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Affero General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU Affero General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
import { DialogContentText, Grid } from "@mui/material";
18+
import React, { useState } from "react";
19+
import { ErrorResponseHandler } from "../../../../common/types";
20+
import { useAppDispatch } from "../../../../store";
21+
import { setErrorSnackMessage } from "../../../../systemSlice";
22+
import InputBoxWrapper from "../../Common/FormComponents/InputBoxWrapper/InputBoxWrapper";
23+
import useApi from "../../Common/Hooks/useApi";
24+
import ConfirmDialog from "../../Common/ModalWrapper/ConfirmDialog";
25+
import KMSHelpBox from "../../KMS/KMSHelpbox";
26+
27+
interface IAddKeyModalProps {
28+
closeAddModalAndRefresh: (refresh: boolean) => void;
29+
addOpen: boolean;
30+
}
31+
32+
const AddKeyModal = ({
33+
closeAddModalAndRefresh,
34+
addOpen,
35+
}: IAddKeyModalProps) => {
36+
const dispatch = useAppDispatch();
37+
const onAddSuccess = () => closeAddModalAndRefresh(true);
38+
const onAddError = (err: ErrorResponseHandler) => {
39+
closeAddModalAndRefresh(false);
40+
dispatch(setErrorSnackMessage(err));
41+
};
42+
const onClose = () => closeAddModalAndRefresh(false);
43+
44+
const [addLoading, invokeAddApi] = useApi(onAddSuccess, onAddError);
45+
const [keyName, setKeyName] = useState<string>("");
46+
47+
const onConfirmAdd = () => {
48+
invokeAddApi("POST", "/api/v1/kms/keys/", { key: keyName });
49+
};
50+
51+
return (
52+
<ConfirmDialog
53+
title={""}
54+
confirmText={"Create"}
55+
isOpen={addOpen}
56+
isLoading={addLoading}
57+
onConfirm={onConfirmAdd}
58+
onClose={onClose}
59+
confirmButtonProps={{
60+
disabled: keyName.indexOf(" ") !== -1 || keyName === "" || addLoading,
61+
variant: "callAction",
62+
}}
63+
confirmationContent={
64+
<DialogContentText>
65+
<KMSHelpBox
66+
helpText={"Create Key"}
67+
contents={[
68+
"Create a new cryptographic key in the Key Management Service server connected to MINIO.",
69+
]}
70+
/>
71+
72+
<Grid item xs={12} marginTop={3}>
73+
<InputBoxWrapper
74+
id="key-name"
75+
name="key-name"
76+
label="Key Name"
77+
autoFocus={true}
78+
value={keyName}
79+
error={
80+
keyName.indexOf(" ") !== -1
81+
? "Key name cannot contain spaces"
82+
: ""
83+
}
84+
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
85+
setKeyName(e.target.value);
86+
}}
87+
/>
88+
</Grid>
89+
</DialogContentText>
90+
}
91+
/>
92+
);
93+
};
94+
95+
export default AddKeyModal;

0 commit comments

Comments
 (0)