From b2d4e6ea9010f9ae4ca098a0bbd78eb81e2bc5e1 Mon Sep 17 00:00:00 2001 From: Kang Ming Date: Fri, 13 May 2022 17:03:38 -0700 Subject: [PATCH] fix: update auth settings with new gotrue configs --- studio/pages/api/auth/[ref]/config.ts | 6 +++-- studio/pages/project/[ref]/auth/settings.tsx | 16 +++++++++++--- .../stores/jsonSchema/auth_gotrue_config.json | 22 +++++++++++++++++++ 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/studio/pages/api/auth/[ref]/config.ts b/studio/pages/api/auth/[ref]/config.ts index 86d60579887..2a057163300 100644 --- a/studio/pages/api/auth/[ref]/config.ts +++ b/studio/pages/api/auth/[ref]/config.ts @@ -34,6 +34,7 @@ const handleGetAll = async (req: NextApiRequest, res: NextApiResponse) => { JWT_DEFAULT_GROUP_NAME: '', URI_ALLOW_LIST: '', MAILER_AUTOCONFIRM: false, + MAILER_OTP_EXP: 86400, MAILER_URLPATHS_INVITE: '', MAILER_URLPATHS_CONFIRMATION: '', MAILER_URLPATHS_RECOVERY: '', @@ -127,8 +128,8 @@ const handleGetAll = async (req: NextApiRequest, res: NextApiResponse) => { SMTP_SENDER_NAME: null, SMS_AUTOCONFIRM: false, SMS_MAX_FREQUENCY: 0, - SMS_OTP_EXP: 0, - SMS_OTP_LENGTH: 0, + SMS_OTP_EXP: 60, + SMS_OTP_LENGTH: 6, SMS_PROVIDER: 'twilio', SMS_TWILIO_ACCOUNT_SID: null, SMS_TWILIO_AUTH_TOKEN: null, @@ -137,6 +138,7 @@ const handleGetAll = async (req: NextApiRequest, res: NextApiResponse) => { SECURITY_CAPTCHA_ENABLED: false, SECURITY_CAPTCHA_PROVIDER: 'hcaptcha', SECURITY_CAPTCHA_SECRET: null, + SECURITY_REFRESH_TOKEN_REUSE_INTERVAL: '10', RATE_LIMIT_EMAIL_SENT: 0, MAILER_SECURE_EMAIL_CHANGE_ENABLED: true, SMS_MESSAGEBIRD_ACCESS_KEY: null, diff --git a/studio/pages/project/[ref]/auth/settings.tsx b/studio/pages/project/[ref]/auth/settings.tsx index 898bd73a8c6..14cae7a359d 100644 --- a/studio/pages/project/[ref]/auth/settings.tsx +++ b/studio/pages/project/[ref]/auth/settings.tsx @@ -14,7 +14,6 @@ import { pluckJsonSchemaFields } from 'lib/helpers' import { AuthLayout } from 'components/layouts' import Table from 'components/to-be-cleaned/Table' import Panel from 'components/to-be-cleaned/Panel' -import Toggle from 'components/to-be-cleaned/forms/Toggle' import ToggleField from 'components/to-be-cleaned/forms/ToggleField' import SecretField from 'components/to-be-cleaned/forms/SecretField' import SchemaFormPanel from 'components/to-be-cleaned/forms/SchemaFormPanel' @@ -122,6 +121,7 @@ const Settings = () => { 'DISABLE_SIGNUP', 'PASSWORD_MIN_LENGTH', 'SECURITY_UPDATE_PASSWORD_REQUIRE_REAUTHENTICATION', + 'SECURITY_REFRESH_TOKEN_REUSE_INTERVAL', ])} model={{ SITE_URL: model.SITE_URL || undefined, @@ -130,6 +130,7 @@ const Settings = () => { JWT_EXP: model.JWT_EXP || undefined, PASSWORD_MIN_LENGTH: model.PASSWORD_MIN_LENGTH || undefined, SECURITY_UPDATE_PASSWORD_REQUIRE_REAUTHENTICATION: model.SECURITY_UPDATE_PASSWORD_REQUIRE_REAUTHENTICATION || false, + SECURITY_REFRESH_TOKEN_REUSE_INTERVAL: model.SECURITY_REFRESH_TOKEN_REUSE_INTERVAL || undefined, }} onSubmit={(model: any) => onFormSubmit(model)} > @@ -144,8 +145,9 @@ const Settings = () => { errorMessage="Must be a comma separated list of exact URIs. No spaces." /> - + + @@ -154,6 +156,7 @@ const Settings = () => { title="Email Auth" schema={pluckJsonSchemaFields(authConfig, [ 'MAILER_SECURE_EMAIL_CHANGE_ENABLED', + 'MAILER_OTP_EXP', 'SMTP_ADMIN_EMAIL', 'SMTP_HOST', 'SMTP_PORT', @@ -164,6 +167,7 @@ const Settings = () => { ])} model={{ MAILER_SECURE_EMAIL_CHANGE_ENABLED: model.MAILER_SECURE_EMAIL_CHANGE_ENABLED, + MAILER_OTP_EXP: model.MAILER_OTP_EXP || undefined, SMTP_ADMIN_EMAIL: isCustomSMTPEnabled ? model.SMTP_ADMIN_EMAIL : '', SMTP_HOST: isCustomSMTPEnabled ? model.SMTP_HOST : '', SMTP_PORT: isCustomSMTPEnabled ? model.SMTP_PORT : '', @@ -188,7 +192,7 @@ const Settings = () => { checked={model.EXTERNAL_EMAIL_ENABLED} descriptionText={authConfig.properties.EXTERNAL_EMAIL_ENABLED.help} /> - + { title="Phone Auth" schema={pluckJsonSchemaFields(authConfig, [ 'SMS_PROVIDER', + 'SMS_OTP_EXP', + 'SMS_OTP_LENGTH', 'SMS_TWILIO_ACCOUNT_SID', 'SMS_TWILIO_AUTH_TOKEN', 'SMS_TWILIO_MESSAGE_SERVICE_SID', @@ -282,6 +288,8 @@ const Settings = () => { ])} model={{ SMS_PROVIDER: model.SMS_PROVIDER, + SMS_OTP_EXP: model.SMS_OTP_EXP || undefined, + SMS_OTP_LENGTH: model.SMS_OTP_LENGTH || undefined, SMS_TEXTLOCAL_API_KEY: model.SMS_TEXTLOCAL_API_KEY || undefined, SMS_TEXTLOCAL_SENDER: model.SMS_TEXTLOCAL_SENDER || undefined, SMS_TWILIO_ACCOUNT_SID: model.SMS_TWILIO_ACCOUNT_SID || undefined, @@ -315,6 +323,8 @@ const Settings = () => { showInlineError errorMessage="Please enter the phone provider." /> + + {smsProviderModel?.SMS_PROVIDER === 'messagebird' ? ( <>