feat: Add ability to configure and test SMTP via UI

This commit is contained in:
Maksim Eltyshev
2025-09-22 20:35:13 +02:00
parent 3a12bb7457
commit c6f4dcdb70
114 changed files with 2161 additions and 301 deletions

View File

@@ -17,54 +17,131 @@
* Config:
* type: object
* required:
* - version
* - oidc
* - id
* - isInitialized
* properties:
* version:
* id:
* type: string
* description: Current version of the PLANKA application
* example: 2.0.0
* activeUsersLimit:
* description: Unique identifier for the config (always set to '1')
* example: 1
* smtpHost:
* type: string
* nullable: true
* description: Hostname or IP address of the SMTP server
* example: smtp.example.com
* smtpPort:
* type: number
* nullable: true
* description: Maximum number of active users allowed (conditionally added for admins if configured)
* example: 100
* oidc:
* type: object
* required:
* - authorizationUrl
* - endSessionUrl
* - isEnforced
* description: Port number of the SMTP server
* example: 587
* smtpName:
* type: string
* nullable: true
* description: OpenID Connect configuration (null if not configured)
* properties:
* authorizationUrl:
* type: string
* format: uri
* description: OIDC authorization URL for initiating authentication
* example: https://oidc.example.com/auth
* endSessionUrl:
* type: string
* format: uri
* nullable: true
* description: OIDC end session URL for logout (null if not supported by provider)
* example: https://oidc.example.com/logout
* isEnforced:
* type: boolean
* description: Whether OIDC authentication is enforced (users must use OIDC to login)
* example: false
* description: Client hostname used in the EHLO command for SMTP
* example: localhost
* smtpSecure:
* type: boolean
* description: Whether to use a secure connection for SMTP
* example: false
* smtpTlsRejectUnauthorized:
* type: boolean
* description: Whether to reject unauthorized or self-signed TLS certificates for SMTP connections
* example: true
* smtpUser:
* type: string
* nullable: true
* description: Username for authenticating with the SMTP server
* example: no-reply@example.com
* smtpPassword:
* type: string
* nullable: true
* description: Password for authenticating with the SMTP server
* example: SecurePassword123!
* smtpFrom:
* type: string
* nullable: true
* description: Default "from" used for outgoing SMTP emails
* example: no-reply@example.com
* isInitialized:
* type: boolean
* description: Whether the PLANKA instance has been initialized
* example: true
* createdAt:
* type: string
* format: date-time
* nullable: true
* description: When the config was created
* example: 2024-01-01T00:00:00.000Z
* updatedAt:
* type: string
* format: date-time
* nullable: true
* description: When the config was last updated
* example: 2024-01-01T00:00:00.000Z
*/
const MAIN_ID = '1';
const SMTP_FIELD_NAMES = [
'smtpHost',
'smtpPort',
'smtpName',
'smtpSecure',
'smtpTlsRejectUnauthorized',
'smtpUser',
'smtpPassword',
'smtpFrom',
];
module.exports = {
MAIN_ID,
SMTP_FIELD_NAMES,
attributes: {
// ╔═╗╦═╗╦╔╦╗╦╔╦╗╦╦ ╦╔═╗╔═╗
// ╠═╝╠╦╝║║║║║ ║ ║╚╗╔╝║╣ ╚═╗
// ╩ ╩╚═╩╩ ╩╩ ╩ ╩ ╚╝ ╚═╝╚═╝
smtpHost: {
type: 'string',
allowNull: true,
columnName: 'smtp_host',
},
smtpPort: {
type: 'number',
allowNull: true,
columnName: 'smtp_port',
},
smtpName: {
type: 'string',
allowNull: true,
columnName: 'smtp_name',
},
smtpSecure: {
type: 'boolean',
required: true,
columnName: 'smtp_secure',
},
smtpTlsRejectUnauthorized: {
type: 'boolean',
required: true,
columnName: 'smtp_tls_reject_unauthorized',
},
smtpUser: {
type: 'string',
allowNull: true,
columnName: 'smtp_user',
},
smtpPassword: {
type: 'string',
allowNull: true,
columnName: 'smtp_password',
},
smtpFrom: {
type: 'string',
allowNull: true,
columnName: 'smtp_from',
},
isInitialized: {
type: 'boolean',
required: true,