1
0
mirror of https://github.com/stonith404/pingvin-share.git synced 2024-07-02 07:20:38 +02:00

fix: obscure critical config variables

This commit is contained in:
Elias Schneider 2022-12-08 19:14:06 +01:00
parent 1f63f22591
commit bfb0d151ea
9 changed files with 29 additions and 25 deletions

View File

@ -84,6 +84,7 @@ model Config {
type String type String
value String value String
description String description String
obscured Boolean @default(false)
secret Boolean @default(true) secret Boolean @default(true)
locked Boolean @default(false) locked Boolean @default(false)
} }

View File

@ -1,7 +1,7 @@
import { PrismaClient } from "@prisma/client"; import { Prisma, PrismaClient } from "@prisma/client";
import * as crypto from "crypto"; import * as crypto from "crypto";
const configVariables = [ const configVariables: Prisma.ConfigCreateInput[] = [
{ {
key: "SETUP_FINISHED", key: "SETUP_FINISHED",
description: "Whether the setup has been finished", description: "Whether the setup has been finished",
@ -83,6 +83,7 @@ const configVariables = [
description: "Password of the SMTP server", description: "Password of the SMTP server",
type: "string", type: "string",
value: "", value: "",
obscured: true,
}, },
]; ];

View File

@ -11,6 +11,9 @@ export class AdminConfigDTO extends ConfigDTO {
@Expose() @Expose()
description: string; description: string;
@Expose()
obscured: boolean;
from(partial: Partial<AdminConfigDTO>) { from(partial: Partial<AdminConfigDTO>) {
return plainToClass(AdminConfigDTO, partial, { return plainToClass(AdminConfigDTO, partial, {
excludeExtraneousValues: true, excludeExtraneousValues: true,

View File

@ -54,17 +54,20 @@ const AdminConfigTable = () => {
<tbody> <tbody>
{isLoading {isLoading
? skeletonRows ? skeletonRows
: configVariables.map((element) => ( : configVariables.map((configVariable) => (
<tr key={element.key}> <tr key={configVariable.key}>
<td style={{ maxWidth: "200px" }}> <td style={{ maxWidth: "200px" }}>
<Code>{element.key}</Code> {element.secret && <TbLock />}{" "} <Code>{configVariable.key}</Code>{" "}
<br /> {configVariable.secret && <TbLock />} <br />
<Text size="xs" color="dimmed"> <Text size="xs" color="dimmed">
{element.description} {configVariable.description}
</Text> </Text>
</td> </td>
<td>{element.value}</td> <td>
{configVariable.obscured
? "••••••••••••"
: configVariable.value}
</td>
<td> <td>
<Group position="right"> <Group position="right">
<ActionIcon <ActionIcon
@ -74,7 +77,7 @@ const AdminConfigTable = () => {
onClick={() => onClick={() =>
showUpdateConfigVariableModal( showUpdateConfigVariableModal(
modals, modals,
element, configVariable,
getConfigVariables getConfigVariables
) )
} }

View File

@ -62,10 +62,7 @@ const Body = ({
> >
<Stack> <Stack>
<TextInput label="Username" {...form.getInputProps("username")} /> <TextInput label="Username" {...form.getInputProps("username")} />
<TextInput <TextInput label="Email" {...form.getInputProps("email")} />
label="Email"
{...form.getInputProps("email")}
/>
<PasswordInput <PasswordInput
label="New password" label="New password"
{...form.getInputProps("password")} {...form.getInputProps("password")}

View File

@ -2,6 +2,7 @@ import {
Button, Button,
Code, Code,
NumberInput, NumberInput,
PasswordInput,
Select, Select,
Space, Space,
Stack, Stack,
@ -53,9 +54,12 @@ const Body = ({
<Text> <Text>
Set <Code>{configVariable.key}</Code> to Set <Code>{configVariable.key}</Code> to
</Text> </Text>
{configVariable.type == "string" && ( {configVariable.type == "string" &&
<TextInput label="Value" {...form.getInputProps("stringValue")} /> (configVariable.obscured ? (
)} <PasswordInput label="Value" {...form.getInputProps("stringValue")} />
) : (
<TextInput label="Value" {...form.getInputProps("stringValue")} />
))}
{configVariable.type == "number" && ( {configVariable.type == "number" && (
<NumberInput label="Value" {...form.getInputProps("numberValue")} /> <NumberInput label="Value" {...form.getInputProps("numberValue")} />
)} )}

View File

@ -79,10 +79,7 @@ const Body = ({
label="Username" label="Username"
{...accountForm.getInputProps("username")} {...accountForm.getInputProps("username")}
/> />
<TextInput <TextInput label="Email" {...accountForm.getInputProps("email")} />
label="Email"
{...accountForm.getInputProps("email")}
/>
<Switch <Switch
mt="xs" mt="xs"
labelPosition="left" labelPosition="left"

View File

@ -80,10 +80,7 @@ const Account = () => {
label="Username" label="Username"
{...accountForm.getInputProps("username")} {...accountForm.getInputProps("username")}
/> />
<TextInput <TextInput label="Email" {...accountForm.getInputProps("email")} />
label="Email"
{...accountForm.getInputProps("email")}
/>
<Group position="right"> <Group position="right">
<Button type="submit">Save</Button> <Button type="submit">Save</Button>
</Group> </Group>

View File

@ -8,6 +8,7 @@ export type AdminConfig = Config & {
updatedAt: Date; updatedAt: Date;
secret: boolean; secret: boolean;
description: string; description: string;
obscured: boolean;
}; };
export default Config; export default Config;