2019-08-31 04:07:25 +05:00
|
|
|
/**
|
|
|
|
* Custom configuration
|
|
|
|
* (sails.config.custom)
|
|
|
|
*
|
|
|
|
* One-off settings specific to your application.
|
|
|
|
*
|
|
|
|
* For more information on custom configuration, visit:
|
|
|
|
* https://sailsjs.com/config/custom
|
|
|
|
*/
|
|
|
|
|
2024-11-12 15:58:22 +01:00
|
|
|
const { URL } = require('url');
|
2019-08-31 04:07:25 +05:00
|
|
|
const sails = require('sails');
|
|
|
|
|
2025-05-10 02:09:06 +02:00
|
|
|
const version = require('../version');
|
|
|
|
|
|
|
|
const envToNumber = (value) => {
|
|
|
|
const number = parseInt(value, 10);
|
|
|
|
return Number.isNaN(number) ? null : number;
|
|
|
|
};
|
|
|
|
|
|
|
|
const envToArray = (value) => (value ? value.split(',') : []);
|
|
|
|
|
2024-11-12 15:58:22 +01:00
|
|
|
const parsedBasedUrl = new URL(process.env.BASE_URL);
|
2024-09-01 09:31:04 +02:00
|
|
|
|
2019-08-31 04:07:25 +05:00
|
|
|
module.exports.custom = {
|
2019-11-05 18:01:42 +05:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Any other custom config this Sails app should use during development.
|
|
|
|
*
|
|
|
|
*/
|
2019-08-31 04:07:25 +05:00
|
|
|
|
2025-05-10 02:09:06 +02:00
|
|
|
version,
|
|
|
|
|
2019-08-31 04:07:25 +05:00
|
|
|
baseUrl: process.env.BASE_URL,
|
2024-09-01 09:31:04 +02:00
|
|
|
baseUrlPath: parsedBasedUrl.pathname,
|
|
|
|
baseUrlSecure: parsedBasedUrl.protocol === 'https:',
|
2019-08-31 04:07:25 +05:00
|
|
|
|
2022-08-09 19:09:07 +02:00
|
|
|
tokenExpiresIn: parseInt(process.env.TOKEN_EXPIRES_IN, 10) || 365,
|
2022-08-09 18:03:21 +02:00
|
|
|
|
feat: Configurable file storage locations (#886)
* feat: Make logfile location customizable
It may be desirable to log to a more standard location (e.g. in /var/log/),
or in some cases to turn logging to file off. To support these, use a
custom config property to determine the location of the output log file,
and default to the previous location if it is unset.
* feat: Support alternate storage locations for uploaded files
This involves a couple primary changes:
1) to make Sails' temporary file-upload directory a configurable location
by using a common file-upload-receiving helper;
2) to create custom static routes for the file-upload locations, so they
can be outside the application's public directory; and
3) to use the file-uploading handler everywhere that receives files, so
config for the helper is applied to all file uploads consistently.
This is sufficient to allow the application directory to be deployed read-
only, with writable storage used for file uploads. The new config property
for Sails' temporary upload directory, combined with the existing settings
for user-avatar and background-image locations are sufficient to handle
uploads; the new custom routes handle serving those files from external
locations.
The default behavior of the application should be unchanged, with files
uploaded to, and served from, the public directory if the relevant
config properties aren't set to other values.
2024-09-20 14:29:11 -04:00
|
|
|
// Location to receive uploaded files in. Default (non-string value) is a Sails-specific location.
|
2024-11-12 15:58:22 +01:00
|
|
|
uploadsTempPath: null,
|
|
|
|
uploadsBasePath: sails.config.appPath,
|
feat: Configurable file storage locations (#886)
* feat: Make logfile location customizable
It may be desirable to log to a more standard location (e.g. in /var/log/),
or in some cases to turn logging to file off. To support these, use a
custom config property to determine the location of the output log file,
and default to the previous location if it is unset.
* feat: Support alternate storage locations for uploaded files
This involves a couple primary changes:
1) to make Sails' temporary file-upload directory a configurable location
by using a common file-upload-receiving helper;
2) to create custom static routes for the file-upload locations, so they
can be outside the application's public directory; and
3) to use the file-uploading handler everywhere that receives files, so
config for the helper is applied to all file uploads consistently.
This is sufficient to allow the application directory to be deployed read-
only, with writable storage used for file uploads. The new config property
for Sails' temporary upload directory, combined with the existing settings
for user-avatar and background-image locations are sufficient to handle
uploads; the new custom routes handle serving those files from external
locations.
The default behavior of the application should be unchanged, with files
uploaded to, and served from, the public directory if the relevant
config properties aren't set to other values.
2024-09-20 14:29:11 -04:00
|
|
|
|
2025-05-10 02:09:06 +02:00
|
|
|
preloadedFaviconsPathSegment: 'public/preloaded-favicons',
|
|
|
|
faviconsPathSegment: 'public/favicons',
|
2024-11-12 15:58:22 +01:00
|
|
|
userAvatarsPathSegment: 'public/user-avatars',
|
2025-05-10 02:09:06 +02:00
|
|
|
backgroundImagesPathSegment: 'public/background-images',
|
2024-11-12 15:58:22 +01:00
|
|
|
attachmentsPathSegment: 'private/attachments',
|
2024-11-11 20:59:18 +07:00
|
|
|
|
2024-03-12 20:40:46 +01:00
|
|
|
defaultAdminEmail:
|
|
|
|
process.env.DEFAULT_ADMIN_EMAIL && process.env.DEFAULT_ADMIN_EMAIL.toLowerCase(),
|
2023-10-17 19:18:19 +02:00
|
|
|
|
2025-07-07 21:35:37 +02:00
|
|
|
internalAccessToken: process.env.INTERNAL_ACCESS_TOKEN,
|
2025-05-10 02:09:06 +02:00
|
|
|
activeUsersLimit: envToNumber(process.env.ACTIVE_USERS_LIMIT),
|
2024-08-30 11:47:29 +02:00
|
|
|
showDetailedAuthErrors: process.env.SHOW_DETAILED_AUTH_ERRORS === 'true',
|
2024-06-14 16:38:06 +02:00
|
|
|
|
2024-11-12 15:58:22 +01:00
|
|
|
s3Endpoint: process.env.S3_ENDPOINT,
|
|
|
|
s3Region: process.env.S3_REGION,
|
|
|
|
s3AccessKeyId: process.env.S3_ACCESS_KEY_ID,
|
|
|
|
s3SecretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
|
|
|
|
s3Bucket: process.env.S3_BUCKET,
|
|
|
|
s3ForcePathStyle: process.env.S3_FORCE_PATH_STYLE === 'true',
|
|
|
|
|
2023-09-04 10:06:59 -05:00
|
|
|
oidcIssuer: process.env.OIDC_ISSUER,
|
|
|
|
oidcClientId: process.env.OIDC_CLIENT_ID,
|
2023-10-19 14:39:21 +02:00
|
|
|
oidcClientSecret: process.env.OIDC_CLIENT_SECRET,
|
2024-07-16 12:19:27 +02:00
|
|
|
oidcIdTokenSignedResponseAlg: process.env.OIDC_ID_TOKEN_SIGNED_RESPONSE_ALG,
|
|
|
|
oidcUserinfoSignedResponseAlg: process.env.OIDC_USERINFO_SIGNED_RESPONSE_ALG,
|
2023-10-17 19:18:19 +02:00
|
|
|
oidcScopes: process.env.OIDC_SCOPES || 'openid email profile',
|
2024-07-16 12:19:27 +02:00
|
|
|
oidcResponseMode: process.env.OIDC_RESPONSE_MODE || 'fragment',
|
2024-07-16 12:33:38 +02:00
|
|
|
oidcUseDefaultResponseMode: process.env.OIDC_USE_DEFAULT_RESPONSE_MODE === 'true',
|
2025-05-10 02:09:06 +02:00
|
|
|
oidcAdminRoles: envToArray(process.env.OIDC_ADMIN_ROLES),
|
|
|
|
oidcProjectOwnerRoles: envToArray(process.env.OIDC_PROJECT_OWNER_ROLES),
|
|
|
|
oidcBoardUserRoles: envToArray(process.env.OIDC_BOARD_USER_ROLES),
|
2024-09-20 16:19:54 +02:00
|
|
|
oidcClaimsSource: process.env.OIDC_CLAIMS_SOURCE || 'userinfo',
|
2024-01-25 23:01:59 +01:00
|
|
|
oidcEmailAttribute: process.env.OIDC_EMAIL_ATTRIBUTE || 'email',
|
|
|
|
oidcNameAttribute: process.env.OIDC_NAME_ATTRIBUTE || 'name',
|
|
|
|
oidcUsernameAttribute: process.env.OIDC_USERNAME_ATTRIBUTE || 'preferred_username',
|
2023-10-17 19:18:19 +02:00
|
|
|
oidcRolesAttribute: process.env.OIDC_ROLES_ATTRIBUTE || 'groups',
|
2024-01-25 23:01:59 +01:00
|
|
|
oidcIgnoreUsername: process.env.OIDC_IGNORE_USERNAME === 'true',
|
2023-10-25 23:39:34 +02:00
|
|
|
oidcIgnoreRoles: process.env.OIDC_IGNORE_ROLES === 'true',
|
2024-02-01 00:31:15 +01:00
|
|
|
oidcEnforced: process.env.OIDC_ENFORCED === 'true',
|
2023-10-19 16:05:34 +02:00
|
|
|
|
|
|
|
// TODO: move client base url to environment variable?
|
|
|
|
oidcRedirectUri: `${
|
|
|
|
sails.config.environment === 'production' ? process.env.BASE_URL : 'http://localhost:3000'
|
|
|
|
}/oidc-callback`,
|
2024-04-08 00:33:29 +02:00
|
|
|
|
|
|
|
smtpHost: process.env.SMTP_HOST,
|
|
|
|
smtpPort: process.env.SMTP_PORT || 587,
|
2024-05-18 14:02:21 +01:00
|
|
|
smtpName: process.env.SMTP_NAME,
|
2024-04-08 00:33:29 +02:00
|
|
|
smtpSecure: process.env.SMTP_SECURE === 'true',
|
|
|
|
smtpUser: process.env.SMTP_USER,
|
|
|
|
smtpPassword: process.env.SMTP_PASSWORD,
|
|
|
|
smtpFrom: process.env.SMTP_FROM,
|
2024-10-02 14:10:31 +02:00
|
|
|
smtpTlsRejectUnauthorized: process.env.SMTP_TLS_REJECT_UNAUTHORIZED !== 'false',
|
2019-08-31 04:07:25 +05:00
|
|
|
};
|