Skip to content
This repository was archived by the owner on Jun 29, 2025. It is now read-only.

Commit bfb0d15

Browse files
committed
fix: obscure critical config variables
1 parent 1f63f22 commit bfb0d15

File tree

9 files changed

+29
-25
lines changed

9 files changed

+29
-25
lines changed

backend/prisma/schema.prisma

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ model Config {
8484
type String
8585
value String
8686
description String
87+
obscured Boolean @default(false)
8788
secret Boolean @default(true)
8889
locked Boolean @default(false)
8990
}

backend/prisma/seed/config.seed.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { PrismaClient } from "@prisma/client";
1+
import { Prisma, PrismaClient } from "@prisma/client";
22
import * as crypto from "crypto";
33

4-
const configVariables = [
4+
const configVariables: Prisma.ConfigCreateInput[] = [
55
{
66
key: "SETUP_FINISHED",
77
description: "Whether the setup has been finished",
@@ -83,6 +83,7 @@ const configVariables = [
8383
description: "Password of the SMTP server",
8484
type: "string",
8585
value: "",
86+
obscured: true,
8687
},
8788
];
8889

backend/src/config/dto/adminConfig.dto.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ export class AdminConfigDTO extends ConfigDTO {
1111
@Expose()
1212
description: string;
1313

14+
@Expose()
15+
obscured: boolean;
16+
1417
from(partial: Partial<AdminConfigDTO>) {
1518
return plainToClass(AdminConfigDTO, partial, {
1619
excludeExtraneousValues: true,

frontend/src/components/admin/AdminConfigTable.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,20 @@ const AdminConfigTable = () => {
5454
<tbody>
5555
{isLoading
5656
? skeletonRows
57-
: configVariables.map((element) => (
58-
<tr key={element.key}>
57+
: configVariables.map((configVariable) => (
58+
<tr key={configVariable.key}>
5959
<td style={{ maxWidth: "200px" }}>
60-
<Code>{element.key}</Code> {element.secret && <TbLock />}{" "}
61-
<br />
60+
<Code>{configVariable.key}</Code>{" "}
61+
{configVariable.secret && <TbLock />} <br />
6262
<Text size="xs" color="dimmed">
63-
{element.description}
63+
{configVariable.description}
6464
</Text>
6565
</td>
66-
<td>{element.value}</td>
67-
66+
<td>
67+
{configVariable.obscured
68+
? "••••••••••••"
69+
: configVariable.value}
70+
</td>
6871
<td>
6972
<Group position="right">
7073
<ActionIcon
@@ -74,7 +77,7 @@ const AdminConfigTable = () => {
7477
onClick={() =>
7578
showUpdateConfigVariableModal(
7679
modals,
77-
element,
80+
configVariable,
7881
getConfigVariables
7982
)
8083
}

frontend/src/components/admin/showCreateUserModal.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,7 @@ const Body = ({
6262
>
6363
<Stack>
6464
<TextInput label="Username" {...form.getInputProps("username")} />
65-
<TextInput
66-
label="Email"
67-
{...form.getInputProps("email")}
68-
/>
65+
<TextInput label="Email" {...form.getInputProps("email")} />
6966
<PasswordInput
7067
label="New password"
7168
{...form.getInputProps("password")}

frontend/src/components/admin/showUpdateConfigVariableModal.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
Button,
33
Code,
44
NumberInput,
5+
PasswordInput,
56
Select,
67
Space,
78
Stack,
@@ -53,9 +54,12 @@ const Body = ({
5354
<Text>
5455
Set <Code>{configVariable.key}</Code> to
5556
</Text>
56-
{configVariable.type == "string" && (
57-
<TextInput label="Value" {...form.getInputProps("stringValue")} />
58-
)}
57+
{configVariable.type == "string" &&
58+
(configVariable.obscured ? (
59+
<PasswordInput label="Value" {...form.getInputProps("stringValue")} />
60+
) : (
61+
<TextInput label="Value" {...form.getInputProps("stringValue")} />
62+
))}
5963
{configVariable.type == "number" && (
6064
<NumberInput label="Value" {...form.getInputProps("numberValue")} />
6165
)}

frontend/src/components/admin/showUpdateUserModal.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,7 @@ const Body = ({
7979
label="Username"
8080
{...accountForm.getInputProps("username")}
8181
/>
82-
<TextInput
83-
label="Email"
84-
{...accountForm.getInputProps("email")}
85-
/>
82+
<TextInput label="Email" {...accountForm.getInputProps("email")} />
8683
<Switch
8784
mt="xs"
8885
labelPosition="left"

frontend/src/pages/account/index.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,7 @@ const Account = () => {
8080
label="Username"
8181
{...accountForm.getInputProps("username")}
8282
/>
83-
<TextInput
84-
label="Email"
85-
{...accountForm.getInputProps("email")}
86-
/>
83+
<TextInput label="Email" {...accountForm.getInputProps("email")} />
8784
<Group position="right">
8885
<Button type="submit">Save</Button>
8986
</Group>

frontend/src/types/config.type.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export type AdminConfig = Config & {
88
updatedAt: Date;
99
secret: boolean;
1010
description: string;
11+
obscured: boolean;
1112
};
1213

1314
export default Config;

0 commit comments

Comments
 (0)