5 Commits
ci-21 ... ci-26

Author SHA1 Message Date
c725f14bf2 Update flitter jobs
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2020-12-04 20:49:37 -06:00
9b5216431d Make jobs use built-in job logging
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2020-12-04 20:40:27 -06:00
1d5c00768c Update flitter jobs
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2020-12-03 20:00:40 -06:00
7f1c9ec9a8 Update libflitter
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2020-10-29 08:52:13 -05:00
fe0a4d5991 Update libflitter and set session max age
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2020-10-29 08:46:30 -05:00
11 changed files with 67 additions and 28 deletions

View File

@@ -12,7 +12,7 @@ class EMailJob extends Job {
const { data } = job const { data } = job
let { from = config.default_sender, to, subject, html = undefined, email_params = undefined } = data let { from = config.default_sender, to, subject, html = undefined, email_params = undefined } = data
this.output.info(`Sending mail to ${to}...`) this.info(`Sending mail to ${to}...`)
if ( !html && email_params ) html = this.email(email_params) if ( !html && email_params ) html = this.email(email_params)
@@ -20,9 +20,11 @@ class EMailJob extends Job {
from, to, subject, html, from, to, subject, html,
}) })
} catch (e) { } catch (e) {
this.output.error(e) this.error(e)
throw e
} }
this.output.success(`Mail sent!`)
this.success(`Mail sent!`)
} }
email({ header_text, body_paragraphs = [], button_text = '', button_link = '' }) { email({ header_text, body_paragraphs = [], button_text = '', button_link = '' }) {

View File

@@ -12,7 +12,7 @@ class ForeignIPLoginAlertJob extends Job {
const user = await User.findById(user_id) const user = await User.findById(user_id)
if ( !user ) throw new Error('Unable to find user with ID: '+user_id) if ( !user ) throw new Error('Unable to find user with ID: '+user_id)
this.output.info('Sending foreign IP login alert to user.') this.info('Sending foreign IP login alert to user ' + user.uid)
await this.jobs.queue('mailer').add('EMail', { await this.jobs.queue('mailer').add('EMail', {
to: user.email, to: user.email,
@@ -29,14 +29,19 @@ class ForeignIPLoginAlertJob extends Job {
} }
}) })
this.info('Logged e-mail job')
if ( user.notify_config && user.notify_config.active ) { if ( user.notify_config && user.notify_config.active ) {
await user.notify_config.log({ await user.notify_config.log({
title: `${this.configs.get('app.name')}: Sign-In From New IP`, title: `${this.configs.get('app.name')}: Sign-In From New IP`,
message: `Someone signed into your account (${user.uid}) from the IP address ${ip}. If this was you, no further action is required.`, message: `Someone signed into your account (${user.uid}) from the IP address ${ip}. If this was you, no further action is required.`,
}) })
this.info('Logged push notification job')
} }
} catch (e) { } catch (e) {
this.output.error(e) this.error(e)
throw e
} }
} }
} }

View File

@@ -13,13 +13,17 @@ class PasswordResetJob extends Job {
const User = this.models.get('auth:User') const User = this.models.get('auth:User')
const user = await User.findById(user_id) const user = await User.findById(user_id)
if (!user) { if (!user) {
this.output.error(`Unable to find user with ID: ${user_id}`) this.error(`Unable to find user with ID: ${user_id}`)
throw new Error('Unable to find user with that ID.') throw new Error('Unable to find user with that ID.')
} }
this.output.info(`Resetting password for user: ${user.uid}`) this.info(`Resetting password for user: ${user.uid}`)
// Create an authenticated key-action // Create an authenticated key-action
const key_action = await this.key_action(user) const key_action = await this.key_action(user)
this.info(`Created reset keyaction ${key_action.id} (key: ${key_action.key}, handler: ${key_action.handler})`)
await this.jobs.queue('mailer').add('EMail', { await this.jobs.queue('mailer').add('EMail', {
to: user.email, to: user.email,
subject: 'Reset Your Password | ' + this.configs.get('app.name'), subject: 'Reset Your Password | ' + this.configs.get('app.name'),
@@ -34,17 +38,22 @@ class PasswordResetJob extends Job {
} }
}) })
this.info('Logged e-mail job.')
if ( user.notify_config && user.notify_config.active ) { if ( user.notify_config && user.notify_config.active ) {
await user.notify_config.log({ await user.notify_config.log({
title: `${this.configs.get('app.name')}: Password Reset Requested`, title: `${this.configs.get('app.name')}: Password Reset Requested`,
message: `A password reset request was logged for your account (${user.uid}). If this was you, please check your e-mail for further instructions.`, message: `A password reset request was logged for your account (${user.uid}). If this was you, please check your e-mail for further instructions.`,
priority: 8, priority: 8,
}) })
this.info('Logged security push notification job')
} }
this.output.success('Password reset logged.') this.success('Password reset logged.')
} catch (e) { } catch (e) {
this.output.error(e) this.error(e)
throw e
} }
} }

View File

@@ -14,7 +14,7 @@ class PasswordResetAlertJob extends Job {
const user = await User.findById(user_id) const user = await User.findById(user_id)
if ( !user ) throw new Error('Unable to find user with ID: '+user_id) if ( !user ) throw new Error('Unable to find user with ID: '+user_id)
this.output.info('Sending password reset alert to user.') this.info('Sending password reset alert to user ' + user.uid)
await this.jobs.queue('mailer').add('EMail', { await this.jobs.queue('mailer').add('EMail', {
to: user.email, to: user.email,
@@ -28,15 +28,20 @@ class PasswordResetAlertJob extends Job {
}, },
}) })
this.info('Logged e-mail job')
if ( user.notify_config && user.notify_config.active ) { if ( user.notify_config && user.notify_config.active ) {
await user.notify_config.log({ await user.notify_config.log({
title: `${this.configs.get('app.name')}: Password Reset`, title: `${this.configs.get('app.name')}: Password Reset`,
message: `The password to your account (${user.uid}) was reset from the IP address ${ip}. If this was not you, please contact your system administrator.`, message: `The password to your account (${user.uid}) was reset from the IP address ${ip}. If this was not you, please contact your system administrator.`,
priority: 8, priority: 8,
}) })
this.info('Logged push notification job')
} }
} catch (e) { } catch (e) {
this.output.error(e) this.error(e)
throw e
} }
} }
} }

View File

@@ -14,14 +14,15 @@ class PopulateAnnouncementJob extends Job {
const announcement = await Announcement.findById(announcement_id) const announcement = await Announcement.findById(announcement_id)
if ( !announcement ) { if ( !announcement ) {
this.output.error(`Unable to find announcement with ID: ${announcement_id}`) this.error(`Unable to find announcement with ID: ${announcement_id}`)
throw new Error('Unable to find announcement with that ID.') throw new Error('Unable to find announcement with that ID.')
} }
await announcement.populate() await announcement.populate()
this.output.success('Populated announcements.') this.success('Populated announcements.')
} catch (e) { } catch (e) {
this.output.error(e) this.error(e)
throw e
} }
} }
} }

View File

@@ -18,13 +18,15 @@ class PushNotifyJob extends Job {
const notify = user.notify_config const notify = user.notify_config
if ( !notify || !notify.active ) throw new Error('User does not have notifications configured.') if ( !notify || !notify.active ) throw new Error('User does not have notifications configured.')
this.output.info(`Sending notification to ${user.uid}...`) this.info(`Sending notification to ${user.uid}...`)
await notify.send({ title, message, priority }) await notify.send({ title, message, priority })
} catch (e) { } catch (e) {
this.output.error(e) this.error(e)
throw e
} }
this.output.success(`Notification sent!`)
this.success(`Notification sent!`)
} }
} }

View File

@@ -31,6 +31,13 @@ const jobs_config = {
// worker processes of the same type. // worker processes of the same type.
// (e.g. you can have two "main" workers) // (e.g. you can have two "main" workers)
}, },
connector: {
enabled: env('JOB_QUEUE_CONNECTOR', false),
mount: env('JOB_QUEUE_CONNECTOR_MOUNT', '/job_queue_api'),
secret: env('JOB_QUEUE_CONNECTOR_SECRET'),
},
} }
module.exports = exports = jobs_config module.exports = exports = jobs_config

View File

@@ -35,7 +35,12 @@ const server_config = {
* The secret used to encrypt the session. * The secret used to encrypt the session.
* This should be set in the environment. * This should be set in the environment.
*/ */
secret: env("SECRET", "changeme") secret: env("SECRET", "changeme"),
/*
* The max age of a session in milliseconds
*/
max_age: env("SESSION_MAX_AGE", 1000 * 60 * 60 * 24 * 2), // default to 2 days
}, },
uploads: { uploads: {

View File

@@ -33,3 +33,6 @@ SMTP_PORT="587"
SMTP_USER="coreid@localhost.localdomain" SMTP_USER="coreid@localhost.localdomain"
SMTP_DEFAULT_SENDER="coreid@localhost.localdomain" SMTP_DEFAULT_SENDER="coreid@localhost.localdomain"
SMTP_PASS="something super secure" SMTP_PASS="something super secure"
JOB_QUEUE_CONNECTOR=true
JOB_QUEUE_CONNECTOR_SECRET=

View File

@@ -25,7 +25,7 @@
"flitter-forms": "^0.8.1", "flitter-forms": "^0.8.1",
"flitter-gotify": "^0.1.0", "flitter-gotify": "^0.1.0",
"flitter-i18n": "^0.1.1", "flitter-i18n": "^0.1.1",
"flitter-jobs": "^0.1.2", "flitter-jobs": "^0.4.0",
"flitter-less": "^0.5.3", "flitter-less": "^0.5.3",
"flitter-orm": "^0.4.0", "flitter-orm": "^0.4.0",
"flitter-redis": "^0.1.1", "flitter-redis": "^0.1.1",
@@ -33,7 +33,7 @@
"ioredis": "^4.17.1", "ioredis": "^4.17.1",
"is-absolute-url": "^3.0.3", "is-absolute-url": "^3.0.3",
"ldapjs": "^1.0.2", "ldapjs": "^1.0.2",
"libflitter": "^0.56.1", "libflitter": "^0.57.1",
"moment": "^2.24.0", "moment": "^2.24.0",
"mongodb": "^3.5.9", "mongodb": "^3.5.9",
"nodemailer": "^6.4.6", "nodemailer": "^6.4.6",

View File

@@ -2148,10 +2148,10 @@ flitter-i18n@^0.1.1:
ncp "^2.0.0" ncp "^2.0.0"
pluralize "^8.0.0" pluralize "^8.0.0"
flitter-jobs@^0.1.2: flitter-jobs@^0.4.0:
version "0.1.2" version "0.4.0"
resolved "https://registry.yarnpkg.com/flitter-jobs/-/flitter-jobs-0.1.2.tgz#5536bb12be728b61f6e0940b6c18760e4f1b59d6" resolved "https://registry.yarnpkg.com/flitter-jobs/-/flitter-jobs-0.4.0.tgz#6871f611fddb43e8e0ecdb144743ada967aedf8a"
integrity sha512-bxJD3akDnoKPRyIXXy8ytlypGI8uj0Fjn2C8gIY2HFxZeFIBJo47MqQ9qZvVWFS28pS6aUY+0emOvTFkuG/2zA== integrity sha512-L7SPCzxR+pR9LflWOsChkalhLav7YSES79dv7N8VEFpQuhXZ01jm0MwUnKMJyS9+QOiogDzQuab7IsVdMojUFQ==
dependencies: dependencies:
bullmq "^1.8.8" bullmq "^1.8.8"
flitter-redis "^0.1.1" flitter-redis "^0.1.1"
@@ -3235,10 +3235,10 @@ leven@^1.0.2:
resolved "https://registry.yarnpkg.com/leven/-/leven-1.0.2.tgz#9144b6eebca5f1d0680169f1a6770dcea60b75c3" resolved "https://registry.yarnpkg.com/leven/-/leven-1.0.2.tgz#9144b6eebca5f1d0680169f1a6770dcea60b75c3"
integrity sha1-kUS27ryl8dBoAWnxpncNzqYLdcM= integrity sha1-kUS27ryl8dBoAWnxpncNzqYLdcM=
libflitter@^0.56.1: libflitter@^0.57.1:
version "0.56.1" version "0.57.1"
resolved "https://registry.yarnpkg.com/libflitter/-/libflitter-0.56.1.tgz#250166027b9cab727c9deb6b1fa1865428b1eafb" resolved "https://registry.yarnpkg.com/libflitter/-/libflitter-0.57.1.tgz#e605333a5e38cadac1203e4be8ea685c5520472b"
integrity sha512-QikFtFRa9okKOjOio5ehpQ6hyacCoMbtOlqcXt4I7uU3lntBeP5qSbz1q3x1wUY/AdBc2k70+Eg8BcpGmBEs4Q== integrity sha512-bEu02HZjcAp53A2xnE0hz/LVhkErvnqaKmlNOqvJJaGMjKClfVuqJlr9bFfWU84qXL9SaHWd06P3nxIVKTvFIw==
dependencies: dependencies:
colors "^1.3.3" colors "^1.3.3"
connect-mongodb-session "^2.2.0" connect-mongodb-session "^2.2.0"