Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix: make SMTP_PASS write-only (#28816)

Bobbie Soedirgo2ed16a690ce7
diff --git a/apps/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsx b/apps/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsx
index 078392f0d0f..3d388a1073b 100644
--- a/apps/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsx
+++ b/apps/studio/components/interfaces/Auth/SmtpForm/SmtpForm.tsx
@@ -113,7 +113,7 @@ const SmtpForm = () => {
}),
SMTP_PASS: string().when([], {
is: () => {
- return enableSmtp
+ return enableSmtp && authConfig?.SMTP_PASS === null
},
then: (schema) => schema.required('SMTP password is required'),
otherwise: (schema) => schema,
@@ -127,6 +127,12 @@ const SmtpForm = () => {
delete payload.ENABLE_SMTP
payload.SMTP_PORT = payload.SMTP_PORT ? payload.SMTP_PORT.toString() : payload.SMTP_PORT
+ // the SMTP_PASS is write-only, it's never shown. If we don't delete it from the payload, it will replace the
+ // previously saved value with an empty one
+ if (payload.SMTP_PASS === '') {
+ delete payload.SMTP_PASS
+ }
+
updateAuthConfig(
{ projectRef: projectRef!, config: payload },
{
@@ -338,7 +344,7 @@ const SmtpForm = () => {
id="SMTP_PASS"
type={hidden ? 'password' : 'text'}
label="Password"
- placeholder="SMTP Password"
+ placeholder={authConfig?.SMTP_PASS === null ? 'SMTP Password' : '••••••••'}
actions={
<Button
icon={hidden ? <IconEye /> : <IconEyeOff />}
@@ -347,6 +353,12 @@ const SmtpForm = () => {
/>
}
disabled={!canUpdateConfig}
+ descriptionText={
+ <span>
+ For security reasons, the password is write-only. Once saved, it cannot be
+ retrieved or displayed.
+ </span>
+ }
/>
</FormSectionContent>
</FormSection>
diff --git a/apps/studio/components/interfaces/Auth/SmtpForm/SmtpForm.utils.ts b/apps/studio/components/interfaces/Auth/SmtpForm/SmtpForm.utils.ts
index b69ad2be5a1..7b7e12b8020 100644
--- a/apps/studio/components/interfaces/Auth/SmtpForm/SmtpForm.utils.ts
+++ b/apps/studio/components/interfaces/Auth/SmtpForm/SmtpForm.utils.ts
@@ -25,7 +25,7 @@ export const generateFormValues = (config?: Partial<AuthConfig>): Partial<AuthCo
SMTP_SENDER_NAME: config?.SMTP_SENDER_NAME ?? '',
SMTP_USER: config?.SMTP_USER ?? '',
SMTP_HOST: config?.SMTP_HOST ?? '',
- SMTP_PASS: config?.SMTP_PASS ?? '',
+ SMTP_PASS: '',
SMTP_PORT: config?.SMTP_PORT ?? '465',
SMTP_MAX_FREQUENCY: config?.SMTP_MAX_FREQUENCY ?? 60,
RATE_LIMIT_EMAIL_SENT: config?.RATE_LIMIT_EMAIL_SENT ?? 30,