feat(email): option to allow self signed certificates

pull/471/head
sct 4 years ago
parent a7db01fba4
commit 6898357b13

@ -824,7 +824,9 @@ components:
authPass: authPass:
type: string type: string
nullable: true nullable: true
allowSelfSigned:
type: boolean
example: false
PersonDetail: PersonDetail:
type: object type: object
properties: properties:

@ -41,6 +41,11 @@ class EmailAgent
host: emailSettings.smtpHost, host: emailSettings.smtpHost,
port: emailSettings.smtpPort, port: emailSettings.smtpPort,
secure: emailSettings.secure, secure: emailSettings.secure,
tls: emailSettings.allowSelfSigned
? {
rejectUnauthorized: false,
}
: undefined,
auth: auth:
emailSettings.authUser && emailSettings.authPass emailSettings.authUser && emailSettings.authPass
? { ? {

@ -74,6 +74,7 @@ export interface NotificationAgentEmail extends NotificationAgentConfig {
secure: boolean; secure: boolean;
authUser?: string; authUser?: string;
authPass?: string; authPass?: string;
allowSelfSigned: boolean;
}; };
} }
@ -129,8 +130,9 @@ class Settings {
options: { options: {
emailFrom: '', emailFrom: '',
smtpHost: '127.0.0.1', smtpHost: '127.0.0.1',
smtpPort: 465, smtpPort: 587,
secure: false, secure: false,
allowSelfSigned: false,
}, },
}, },
discord: { discord: {

@ -25,6 +25,9 @@ const messages = defineMessages({
emailsettingsfailed: 'Email notification settings failed to save.', emailsettingsfailed: 'Email notification settings failed to save.',
test: 'Test', test: 'Test',
testsent: 'Test notification sent!', testsent: 'Test notification sent!',
allowselfsigned: 'Allow Self-Signed Certificates',
ssldisabletip:
'SSL should be disabled on standard TLS connections (Port 587)',
}); });
const NotificationsEmail: React.FC = () => { const NotificationsEmail: React.FC = () => {
@ -61,6 +64,7 @@ const NotificationsEmail: React.FC = () => {
secure: data.options.secure, secure: data.options.secure,
authUser: data.options.authUser, authUser: data.options.authUser,
authPass: data.options.authPass, authPass: data.options.authPass,
allowSelfSigned: data.options.allowSelfSigned,
}} }}
validationSchema={NotificationsDiscordSchema} validationSchema={NotificationsDiscordSchema}
onSubmit={async (values) => { onSubmit={async (values) => {
@ -75,6 +79,7 @@ const NotificationsEmail: React.FC = () => {
secure: values.secure, secure: values.secure,
authUser: values.authUser, authUser: values.authUser,
authPass: values.authPass, authPass: values.authPass,
allowSelfSigned: values.allowSelfSigned,
}, },
}); });
addToast(intl.formatMessage(messages.emailsettingssaved), { addToast(intl.formatMessage(messages.emailsettingssaved), {
@ -116,7 +121,7 @@ const NotificationsEmail: React.FC = () => {
<Form> <Form>
<div className="sm:grid sm:grid-cols-3 sm:gap-4 sm:items-start sm:border-t sm:border-gray-200 sm:pt-5"> <div className="sm:grid sm:grid-cols-3 sm:gap-4 sm:items-start sm:border-t sm:border-gray-200 sm:pt-5">
<label <label
htmlFor="isDefault" htmlFor="enabled"
className="block text-sm font-medium leading-5 text-gray-400 sm:mt-px sm:pt-2" className="block text-sm font-medium leading-5 text-gray-400 sm:mt-px sm:pt-2"
> >
{intl.formatMessage(messages.agentenabled)} {intl.formatMessage(messages.agentenabled)}
@ -126,131 +131,152 @@ const NotificationsEmail: React.FC = () => {
type="checkbox" type="checkbox"
id="enabled" id="enabled"
name="enabled" name="enabled"
className="form-checkbox rounded-md h-6 w-6 text-indigo-600 transition duration-150 ease-in-out" className="w-6 h-6 text-indigo-600 transition duration-150 ease-in-out rounded-md form-checkbox"
/> />
</div> </div>
</div> </div>
<div className="mt-6 sm:mt-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:items-start sm:border-t sm:border-gray-800 sm:pt-5"> <div className="mt-6 sm:mt-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:items-start sm:border-t sm:border-gray-800 sm:pt-5">
<label <label
htmlFor="name" htmlFor="emailFrom"
className="block text-sm font-medium leading-5 text-gray-400 sm:mt-px sm:pt-2" className="block text-sm font-medium leading-5 text-gray-400 sm:mt-px sm:pt-2"
> >
{intl.formatMessage(messages.emailsender)} {intl.formatMessage(messages.emailsender)}
</label> </label>
<div className="mt-1 sm:mt-0 sm:col-span-2"> <div className="mt-1 sm:mt-0 sm:col-span-2">
<div className="max-w-lg flex rounded-md shadow-sm"> <div className="flex max-w-lg rounded-md shadow-sm">
<Field <Field
id="emailFrom" id="emailFrom"
name="emailFrom" name="emailFrom"
type="text" type="text"
placeholder="no-reply@example.com" placeholder="no-reply@example.com"
className="flex-1 form-input block w-full min-w-0 rounded-md transition duration-150 ease-in-out sm:text-sm sm:leading-5 bg-gray-700 border border-gray-500" className="flex-1 block w-full min-w-0 transition duration-150 ease-in-out bg-gray-700 border border-gray-500 rounded-md form-input sm:text-sm sm:leading-5"
/> />
</div> </div>
{errors.emailFrom && touched.emailFrom && ( {errors.emailFrom && touched.emailFrom && (
<div className="text-red-500 mt-2">{errors.emailFrom}</div> <div className="mt-2 text-red-500">{errors.emailFrom}</div>
)} )}
</div> </div>
</div> </div>
<div className="mt-6 sm:mt-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:items-start sm:border-t sm:border-gray-800 sm:pt-5"> <div className="mt-6 sm:mt-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:items-start sm:border-t sm:border-gray-800 sm:pt-5">
<label <label
htmlFor="name" htmlFor="smtpHost"
className="block text-sm font-medium leading-5 text-gray-400 sm:mt-px sm:pt-2" className="block text-sm font-medium leading-5 text-gray-400 sm:mt-px sm:pt-2"
> >
{intl.formatMessage(messages.smtpHost)} {intl.formatMessage(messages.smtpHost)}
</label> </label>
<div className="mt-1 sm:mt-0 sm:col-span-2"> <div className="mt-1 sm:mt-0 sm:col-span-2">
<div className="max-w-lg flex rounded-md shadow-sm"> <div className="flex max-w-lg rounded-md shadow-sm">
<Field <Field
id="smtpHost" id="smtpHost"
name="smtpHost" name="smtpHost"
type="text" type="text"
placeholder="localhost" placeholder="localhost"
className="flex-1 form-input block w-full min-w-0 rounded-md transition duration-150 ease-in-out sm:text-sm sm:leading-5 bg-gray-700 border border-gray-500" className="flex-1 block w-full min-w-0 transition duration-150 ease-in-out bg-gray-700 border border-gray-500 rounded-md form-input sm:text-sm sm:leading-5"
/> />
</div> </div>
{errors.smtpHost && touched.smtpHost && ( {errors.smtpHost && touched.smtpHost && (
<div className="text-red-500 mt-2">{errors.smtpHost}</div> <div className="mt-2 text-red-500">{errors.smtpHost}</div>
)} )}
</div> </div>
</div> </div>
<div className="mt-6 sm:mt-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:items-start sm:border-t sm:border-gray-800 sm:pt-5"> <div className="mt-6 sm:mt-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:items-start sm:border-t sm:border-gray-800 sm:pt-5">
<label <label
htmlFor="name" htmlFor="smtpPort"
className="block text-sm font-medium leading-5 text-gray-400 sm:mt-px sm:pt-2" className="block text-sm font-medium leading-5 text-gray-400 sm:mt-px sm:pt-2"
> >
{intl.formatMessage(messages.smtpPort)} {intl.formatMessage(messages.smtpPort)}
</label> </label>
<div className="mt-1 sm:mt-0 sm:col-span-2"> <div className="mt-1 sm:mt-0 sm:col-span-2">
<div className="max-w-lg flex rounded-md shadow-sm"> <div className="flex max-w-lg rounded-md shadow-sm">
<Field <Field
id="smtpPort" id="smtpPort"
name="smtpPort" name="smtpPort"
type="text" type="text"
placeholder="465" placeholder="465"
className="form-input block w-24 rounded-md transition duration-150 ease-in-out sm:text-sm sm:leading-5 bg-gray-700 border border-gray-500" className="block w-24 transition duration-150 ease-in-out bg-gray-700 border border-gray-500 rounded-md form-input sm:text-sm sm:leading-5"
/> />
</div> </div>
{errors.smtpPort && touched.smtpPort && ( {errors.smtpPort && touched.smtpPort && (
<div className="text-red-500 mt-2">{errors.smtpPort}</div> <div className="mt-2 text-red-500">{errors.smtpPort}</div>
)} )}
</div> </div>
</div> </div>
<div className="mt-6 sm:mt-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:items-start sm:border-t sm:border-gray-200 sm:pt-5"> <div className="mt-6 sm:mt-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:items-start sm:border-t sm:border-gray-200 sm:pt-5">
<label <label
htmlFor="isDefault" htmlFor="secure"
className="block text-sm font-medium leading-5 text-gray-400 sm:mt-px sm:pt-2" className="block text-sm font-medium leading-5 text-gray-400 sm:mt-px sm:pt-2"
> >
{intl.formatMessage(messages.enableSsl)} <div className="flex flex-col">
<span>{intl.formatMessage(messages.enableSsl)}</span>
<span className="text-gray-500">
{intl.formatMessage(messages.ssldisabletip)}
</span>
</div>
</label> </label>
<div className="mt-1 sm:mt-0 sm:col-span-2"> <div className="mt-1 sm:mt-0 sm:col-span-2">
<Field <Field
type="checkbox" type="checkbox"
id="secure" id="secure"
name="secure" name="secure"
className="form-checkbox rounded-md h-6 w-6 text-indigo-600 transition duration-150 ease-in-out" className="w-6 h-6 text-indigo-600 transition duration-150 ease-in-out rounded-md form-checkbox"
/>
</div>
</div>
<div className="mt-6 sm:mt-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:items-start sm:border-t sm:border-gray-200 sm:pt-5">
<label
htmlFor="allowSelfSigned"
className="block text-sm font-medium leading-5 text-gray-400 sm:mt-px sm:pt-2"
>
{intl.formatMessage(messages.allowselfsigned)}
</label>
<div className="mt-1 sm:mt-0 sm:col-span-2">
<Field
type="checkbox"
id="allowSelfSigned"
name="allowSelfSigned"
className="w-6 h-6 text-indigo-600 transition duration-150 ease-in-out rounded-md form-checkbox"
/> />
</div> </div>
</div> </div>
<div className="mt-6 sm:mt-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:items-start sm:border-t sm:border-gray-800 sm:pt-5"> <div className="mt-6 sm:mt-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:items-start sm:border-t sm:border-gray-800 sm:pt-5">
<label <label
htmlFor="name" htmlFor="authUser"
className="block text-sm font-medium leading-5 text-gray-400 sm:mt-px sm:pt-2" className="block text-sm font-medium leading-5 text-gray-400 sm:mt-px sm:pt-2"
> >
{intl.formatMessage(messages.authUser)} {intl.formatMessage(messages.authUser)}
</label> </label>
<div className="mt-1 sm:mt-0 sm:col-span-2"> <div className="mt-1 sm:mt-0 sm:col-span-2">
<div className="max-w-lg flex rounded-md shadow-sm"> <div className="flex max-w-lg rounded-md shadow-sm">
<Field <Field
id="authUser" id="authUser"
name="authUser" name="authUser"
type="text" type="text"
className="flex-1 form-input block w-full min-w-0 rounded-md transition duration-150 ease-in-out sm:text-sm sm:leading-5 bg-gray-700 border border-gray-500" className="flex-1 block w-full min-w-0 transition duration-150 ease-in-out bg-gray-700 border border-gray-500 rounded-md form-input sm:text-sm sm:leading-5"
/> />
</div> </div>
</div> </div>
</div> </div>
<div className="mt-6 sm:mt-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:items-start sm:border-t sm:border-gray-800 sm:pt-5"> <div className="mt-6 sm:mt-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:items-start sm:border-t sm:border-gray-800 sm:pt-5">
<label <label
htmlFor="name" htmlFor="authPass"
className="block text-sm font-medium leading-5 text-gray-400 sm:mt-px sm:pt-2" className="block text-sm font-medium leading-5 text-gray-400 sm:mt-px sm:pt-2"
> >
{intl.formatMessage(messages.authPass)} {intl.formatMessage(messages.authPass)}
</label> </label>
<div className="mt-1 sm:mt-0 sm:col-span-2"> <div className="mt-1 sm:mt-0 sm:col-span-2">
<div className="max-w-lg flex rounded-md shadow-sm"> <div className="flex max-w-lg rounded-md shadow-sm">
<Field <Field
id="authPass" id="authPass"
name="authPass" name="authPass"
type="password" type="password"
className="flex-1 form-input block w-full min-w-0 rounded-md transition duration-150 ease-in-out sm:text-sm sm:leading-5 bg-gray-700 border border-gray-500" className="flex-1 block w-full min-w-0 transition duration-150 ease-in-out bg-gray-700 border border-gray-500 rounded-md form-input sm:text-sm sm:leading-5"
/> />
</div> </div>
</div> </div>
</div> </div>
<div className="mt-8 border-t border-gray-700 pt-5"> <div className="pt-5 mt-8 border-t border-gray-700">
<div className="flex justify-end"> <div className="flex justify-end">
<span className="ml-3 inline-flex rounded-md shadow-sm"> <span className="inline-flex ml-3 rounded-md shadow-sm">
<Button <Button
buttonType="warning" buttonType="warning"
disabled={isSubmitting || !isValid} disabled={isSubmitting || !isValid}
@ -263,7 +289,7 @@ const NotificationsEmail: React.FC = () => {
{intl.formatMessage(messages.test)} {intl.formatMessage(messages.test)}
</Button> </Button>
</span> </span>
<span className="ml-3 inline-flex rounded-md shadow-sm"> <span className="inline-flex ml-3 rounded-md shadow-sm">
<Button <Button
buttonType="primary" buttonType="primary"
type="submit" type="submit"

@ -93,6 +93,7 @@
"components.RequestModal.status": "Status", "components.RequestModal.status": "Status",
"components.Search.searchresults": "Search Results", "components.Search.searchresults": "Search Results",
"components.Settings.Notifications.agentenabled": "Agent Enabled", "components.Settings.Notifications.agentenabled": "Agent Enabled",
"components.Settings.Notifications.allowselfsigned": "Allow Self-Signed Certificates",
"components.Settings.Notifications.authPass": "Auth Pass", "components.Settings.Notifications.authPass": "Auth Pass",
"components.Settings.Notifications.authUser": "Auth User", "components.Settings.Notifications.authUser": "Auth User",
"components.Settings.Notifications.discordsettingsfailed": "Discord notification settings failed to save.", "components.Settings.Notifications.discordsettingsfailed": "Discord notification settings failed to save.",
@ -105,6 +106,7 @@
"components.Settings.Notifications.saving": "Saving…", "components.Settings.Notifications.saving": "Saving…",
"components.Settings.Notifications.smtpHost": "SMTP Host", "components.Settings.Notifications.smtpHost": "SMTP Host",
"components.Settings.Notifications.smtpPort": "SMTP Port", "components.Settings.Notifications.smtpPort": "SMTP Port",
"components.Settings.Notifications.ssldisabletip": "SSL should be disabled on standard TLS connections (Port 587)",
"components.Settings.Notifications.test": "Test", "components.Settings.Notifications.test": "Test",
"components.Settings.Notifications.testsent": "Test notification sent!", "components.Settings.Notifications.testsent": "Test notification sent!",
"components.Settings.Notifications.validationFromRequired": "You must provide an email sender address", "components.Settings.Notifications.validationFromRequired": "You must provide an email sender address",

Loading…
Cancel
Save