Skip to content

Commit 31ee8e5

Browse files
committed
Add code interactive to CSE
1 parent 922f56a commit 31ee8e5

File tree

2 files changed

+110
-37
lines changed

2 files changed

+110
-37
lines changed

src/pages/cse/ConfigureCse.tsx

Lines changed: 56 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,30 @@
1-
import { useEffect } from "react"
2-
import { Link } from "react-router-dom"
1+
import { message } from "antd"
2+
import { useState } from "react"
3+
import { Link, useNavigate } from "react-router-dom"
4+
import Code from "../../component/Code"
35
import Split from "../../component/Split"
46
import { useBoundStore } from "../../store/store"
57
import { findCurrentNavigationItem, updateNavigationSteps } from "../../utils/navigationActions"
8+
import { Language } from "../../utils/types"
9+
10+
const activeLanguageList: Language[] = [];
611

712
const ConfigureCse = (): JSX.Element => {
813
const { steps, setSteps } = useBoundStore((state) => state);
14+
const [key, setKey] = useState<string | undefined>();
15+
16+
const navigate = useNavigate();
917
const currentItem = findCurrentNavigationItem(steps);
1018

11-
useEffect(() => {
12-
return () => {
19+
const handleSetup = async (): Promise<void> => {
20+
try {
21+
setKey("google_cse");
1322
updateNavigationSteps(steps, setSteps);
14-
};
15-
}, []);
23+
navigate("#");
24+
} catch (error) {
25+
message.error(typeof error === "string" ? error : (error as Error).message);
26+
}
27+
};
1628

1729
return (
1830
<Split>
@@ -35,39 +47,55 @@ const ConfigureCse = (): JSX.Element => {
3547
<li>Choose and configure an <b>Identity Provider</b></li>
3648
<li>Instantiate and configure a <b>Key Management Server</b> (Cosmian KMS)</li>
3749
<li>Generate <b><i>google_cse</i> key</b> from the KMS</li>
38-
<div className="code-cmd">
39-
<code>
40-
{GOOGLE_CSE_KEY}
41-
</code>
42-
<br />
43-
<code>
44-
{GOOGLE_CSE_GRANT}
45-
</code>
46-
</div>
4750
<li>Handle <b>guest Identity Providers</b> for external users <i>(optional)</i></li>
4851
<li>Generate <b>Gmail S/MIME</b> elements: users key-pairs and identities <i>(optional)</i></li>
49-
<div className="code-cmd">
50-
<code>
51-
{GOOGLE_CSE_SMIME_KEYPAIR}
52-
</code>
53-
< br/>
54-
<code>
55-
{GOOGLE_CSE_SMIME_IDENTITY}
56-
</code>
57-
</div>
5852
</ul>
5953
</Split.Content>
54+
<Split.Code>
55+
<Code
56+
activeLanguageList={activeLanguageList}
57+
codeInputList={{
58+
java: GOOGLE_CSE_KEY,
59+
javascript: GOOGLE_CSE_KEY,
60+
python: GOOGLE_CSE_KEY,
61+
}}
62+
codeOutputList={
63+
key
64+
? {
65+
java: GOOGLE_CSE_KEY_OUTPUT,
66+
javascript: GOOGLE_CSE_KEY_OUTPUT,
67+
python: GOOGLE_CSE_KEY_OUTPUT,
68+
}
69+
: undefined
70+
}
71+
codeLanguage="bash"
72+
runCode={handleSetup}
73+
/>
74+
</Split.Code>
6075
</Split>
6176
);
6277
};
6378

6479
export default ConfigureCse;
6580

6681

67-
const GOOGLE_CSE_KEY = "> ckms sym keys create -t google_cse google_cse";
82+
const GOOGLE_CSE_KEY = `# Generate google_cse symmetric key
83+
84+
ckms sym keys create -t google_cse google_cse
85+
86+
87+
# Grant access to the generated key
88+
89+
ckms access-rights grant USER_ID google_cse get encrypt decrypt
90+
`;
91+
92+
const GOOGLE_CSE_KEY_OUTPUT = `The symmetric key was successfully generated.
93+
Unique identifier: google_cse
6894
69-
const GOOGLE_CSE_GRANT = "> ckms access-rights grant USER_ID google_cse get encrypt decrypt";
95+
Tags:
96+
- google_cse`;
7097

71-
const GOOGLE_CSE_SMIME_KEYPAIR = "> ckms google key-pairs create --cse-key-id CSE_KEY_ID --subject-name \"C=FR, ST=IdF, L=Paris, O=YOUR_ORGANIZATION, OU=DEPARTMENT, CN=user@your_organization.com, emailAddress=user@your_organization.com\" -i ISSUER_PRIVATE_KEY_ID user@your_organization.com";
98+
// const GOOGLE_CSE_SMIME = `ckms google key-pairs create --cse-key-id CSE_KEY_ID --subject-name \"C=FR, ST=IdF, L=Paris, O=YOUR_ORGANIZATION, OU=DEPARTMENT, CN=user@your_organization.com, emailAddress=user@your_organization.com\" -i ISSUER_PRIVATE_KEY_ID user@your_organization.com
7299

73-
const GOOGLE_CSE_SMIME_IDENTITY = "> ckms google identities insert --user-id user@your_organization.com CREATED_KEYPAIR_ID";
100+
// ckms google identities insert --user-id user@your_organization.com CREATED_KEYPAIR_ID
101+
// `;

src/pages/cse/ConfigureDke.tsx

Lines changed: 54 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,32 @@
1-
import { Link } from "react-router-dom"
1+
import { message } from "antd"
2+
import { useState } from "react"
3+
import { Link, useNavigate } from "react-router-dom"
4+
import Code from "../../component/Code"
25
import Split from "../../component/Split"
36
import { useBoundStore } from "../../store/store"
4-
import { findCurrentNavigationItem } from "../../utils/navigationActions"
7+
import { findCurrentNavigationItem, updateNavigationSteps } from "../../utils/navigationActions"
8+
import { Language } from "../../utils/types"
9+
10+
const activeLanguageList: Language[] = [];
511

612
const ConfigureDke = (): JSX.Element => {
7-
const { steps } = useBoundStore((state) => state);
13+
const { steps, setSteps } = useBoundStore((state) => state);
14+
const [key, setKey] = useState<string | undefined>();
15+
16+
const navigate = useNavigate();
817
const currentItem = findCurrentNavigationItem(steps);
918

19+
const handleSetup = async (): Promise<void> => {
20+
try {
21+
setKey("dke_key");
22+
updateNavigationSteps(steps, setSteps);
23+
navigate("#");
24+
} catch (error) {
25+
message.error(typeof error === "string" ? error : (error as Error).message);
26+
}
27+
};
28+
29+
1030
return (
1131
<Split>
1232
<Split.Content>
@@ -29,17 +49,42 @@ const ConfigureDke = (): JSX.Element => {
2949
<li>Configure Microsoft DKE in Purview and create a sensitivity label for encryption</li>
3050
<li>Instantiate and configure Cosmian <b>Key Management Server</b> (Cosmian KMS)</li>
3151
<li>Generate <b>RSA key</b> with tag <i>dke_key</i></li>
32-
<div className="code-cmd">
33-
<code>
34-
{DKE_KEY}
35-
</code>
36-
</div>
3752
</ul>
3853
</Split.Content>
54+
<Split.Code>
55+
<Code
56+
activeLanguageList={activeLanguageList}
57+
codeInputList={{
58+
java: DKE_KEY,
59+
javascript: DKE_KEY,
60+
python: DKE_KEY,
61+
}}
62+
codeOutputList={
63+
key
64+
? {
65+
java: DKE_KEY_OUTPUT,
66+
javascript: DKE_KEY_OUTPUT,
67+
python: DKE_KEY_OUTPUT,
68+
}
69+
: undefined
70+
}
71+
codeLanguage="bash"
72+
runCode={handleSetup}
73+
/>
74+
</Split.Code>
3975
</Split>
4076
);
4177
};
4278

4379
export default ConfigureDke;
4480

45-
const DKE_KEY = "> ckms rsa keys create --tag dke_key --size_in_bits 2048";
81+
const DKE_KEY = `# Generate DKE key
82+
83+
ckms rsa keys create --tag dke_key --size_in_bits 2048`;
84+
85+
const DKE_KEY_OUTPUT = `The RSA key pair has been created.
86+
Public key unique identifier: 978cb116-c498-436a-9b9c-e0ed1ddf4cfa
87+
Private key unique identifier: b18f274c-f9a7-4c3d-902d-733b1aa58a15
88+
89+
Tags:
90+
- dke_key`;

0 commit comments

Comments
 (0)