emailengine-app 2.89.0 → 2.90.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/.ncurc.js +19 -8
  2. package/.release-please-manifest.json +1 -1
  3. package/CHANGELOG.md +44 -0
  4. package/Dockerfile +5 -1
  5. package/bin/healthcheck.js +1 -1
  6. package/copy-static-files.sh +0 -8
  7. package/data/google-crawlers.json +1 -1
  8. package/encrypt.js +1 -4
  9. package/lib/account/field-codec.js +396 -0
  10. package/lib/account.js +158 -453
  11. package/lib/api-routes/account-routes.js +42 -6
  12. package/lib/api-routes/route-metadata.js +5 -2
  13. package/lib/api-routes/submit-routes.js +15 -2
  14. package/lib/api-token-auth.js +342 -274
  15. package/lib/arf-detect.js +174 -149
  16. package/lib/attachment-size.js +29 -0
  17. package/lib/autodetect-imap-settings.js +83 -234
  18. package/lib/consts.js +1 -5
  19. package/lib/db.js +1 -4
  20. package/lib/email-client/base-client.js +907 -780
  21. package/lib/email-client/gmail-client.js +557 -450
  22. package/lib/email-client/imap/cid-parts.js +61 -0
  23. package/lib/email-client/imap/mailbox.js +376 -422
  24. package/lib/email-client/imap/sync-operations.js +239 -178
  25. package/lib/email-client/new-message-steps.js +168 -2
  26. package/lib/email-client/outlook/graph-message.js +266 -0
  27. package/lib/email-client/outlook/subscription-expiry.js +30 -0
  28. package/lib/email-client/outlook-client.js +652 -808
  29. package/lib/get-raw-email.js +338 -232
  30. package/lib/get-secret.js +1 -4
  31. package/lib/license-subscription.js +60 -0
  32. package/lib/load-env.js +48 -0
  33. package/lib/logger.js +1 -4
  34. package/lib/mcp/tools.js +244 -207
  35. package/lib/metric-values.js +76 -0
  36. package/lib/metrics.js +320 -0
  37. package/lib/oauth/gmail.js +39 -120
  38. package/lib/oauth/http-request.js +195 -0
  39. package/lib/oauth/mail-ru.js +24 -58
  40. package/lib/oauth/outlook.js +37 -137
  41. package/lib/oauth/pubsub/google.js +176 -117
  42. package/lib/oauth2-apps.js +440 -463
  43. package/lib/openapi/build-document.js +10 -10
  44. package/lib/read-env-value.js +1 -1
  45. package/lib/route-descriptors.js +78 -0
  46. package/lib/schemas.js +10 -1
  47. package/lib/sentry-integrations.js +299 -0
  48. package/lib/sentry.js +75 -27
  49. package/lib/sso-routes.js +249 -0
  50. package/lib/sso.js +29 -6
  51. package/lib/ui-routes/account-edit-form.js +198 -0
  52. package/lib/ui-routes/account-page.js +241 -0
  53. package/lib/ui-routes/account-routes.js +12 -318
  54. package/lib/ui-routes/auth-routes.js +10 -10
  55. package/lib/ui-view-context.js +328 -0
  56. package/lib/utils/public-suffix.js +22 -101
  57. package/lib/web-safe-html.js +20 -7
  58. package/lib/worker-metrics.js +82 -0
  59. package/list-generate.js +2 -5
  60. package/package.json +23 -19
  61. package/sbom.json +267 -908
  62. package/scripts/refresh-test-tokens.js +1 -1
  63. package/server.js +320 -676
  64. package/static/css/flyonui.css +1 -1
  65. package/static/css/src/app.tailwind.css +18 -0
  66. package/static/js/ee-client.js +2619 -645
  67. package/static/js/ui.js +12 -2
  68. package/static/licenses.html +219 -737
  69. package/translations/messages.pot +64 -53
  70. package/views/accounts/browse.hbs +19 -1
  71. package/workers/api.js +20 -451
  72. package/data/public_suffix_list.dat +0 -16698
package/workers/api.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const { parentPort, workerData } = require('worker_threads');
4
- const { isSuspended } = require('../lib/license-subscription');
4
+ const { buildViewContext } = require('../lib/ui-view-context');
5
5
 
6
6
  const packageData = require('../package.json');
7
7
  const config = require('@zone-eu/wild-config');
@@ -40,12 +40,10 @@ const {
40
40
  readEnvList,
41
41
  threadStats,
42
42
  hasEnvValue,
43
- getBoolean,
44
43
  loadTlsConfig,
45
44
  resolveOAuthErrorStatus,
46
45
  verifyServiceSignature,
47
46
  SIGNING_PURPOSE,
48
- setAdminSession,
49
47
  isEndedSession
50
48
  } = require('../lib/tools');
51
49
  const { matchIp, resolveClientIp, detectAutomatedRequest, getAccountHttpRoute } = require('../lib/utils/network');
@@ -95,6 +93,7 @@ const settings = require('../lib/settings');
95
93
  const getSecret = require('../lib/get-secret');
96
94
 
97
95
  const sso = require('../lib/sso');
96
+ const { registerOktaAuth, registerOidcAuth } = require('../lib/sso-routes');
98
97
 
99
98
  const routesUi = require('../lib/routes-ui');
100
99
  const specOptions = require('../lib/swagger-options');
@@ -120,8 +119,7 @@ const {
120
119
  DEFAULT_EENGINE_TIMEOUT,
121
120
  DEFAULT_MAX_ATTACHMENT_SIZE,
122
121
  MAX_FORM_TTL,
123
- NONCE_BYTES,
124
- LAST_DOCUMENT_STORE_VERSION
122
+ NONCE_BYTES
125
123
  } = consts;
126
124
 
127
125
  const registerApiRoutes = require('../lib/api-routes');
@@ -950,215 +948,28 @@ async function registerSessionAuth(server) {
950
948
  return secureCookie;
951
949
  }
952
950
 
953
- // Shared by the SSO strategies. The redirect URL is captured at strategy registration;
954
- // the validators re-read it from settings so an origin change after startup (which would
955
- // break the registered callback URL) disables the SSO button instead of failing mid-flow.
956
- let getServiceRedirectUrl = async () => new URL((await settings.get('serviceUrl')) || `http://${API_HOST}${API_PORT !== 80 ? `:${API_PORT}` : ''}`);
957
- let serviceOriginUnchanged = async redirectUrl => (await getServiceRedirectUrl()).origin === redirectUrl.origin;
958
- // A sign-in the IdP denied, or the user cancelled, comes back as an unauthenticated try-mode
959
- // request. It gets the same flash-and-redirect the allow-list denial in the OIDC handler
960
- // uses, so the user lands on the login form with a way to try again rather than on the
961
- // generic error page with bell's raw message. The reason goes to the log only. ?sso_denied=1
962
- // stops a forced instance from auto-redirecting straight back into the flow.
963
- let ssoFailureRedirect = async (request, h, method) => {
964
- request.logger.warn({
965
- msg: 'SSO login failed',
966
- method,
967
- reason: (request.auth.error && request.auth.error.message) || 'unknown',
968
- remoteAddress: request.app.ip
969
- });
970
- await request.flash({ type: 'danger', message: 'Single sign-on failed or was cancelled. Please try again' });
971
- return h.redirect('/admin/login?sso_denied=1');
972
- };
951
+ // What the SSO strategies (lib/sso-routes.js) read from this worker
952
+ function ssoContext(secureCookie) {
953
+ return {
954
+ secureCookie,
955
+ getCookiePassword: () => settings.get('cookiePassword'),
956
+ getServiceRedirectUrl: async () => new URL((await settings.get('serviceUrl')) || `http://${API_HOST}${API_PORT !== 80 ? `:${API_PORT}` : ''}`),
957
+ sessionPasswordVersion,
958
+ logger
959
+ };
960
+ }
973
961
 
974
- async function registerOktaAuth(server, secureCookie) {
962
+ async function registerSsoAuth(server, secureCookie) {
975
963
  if (USE_OKTA_AUTH) {
976
- let redirectUrl = await getServiceRedirectUrl();
977
-
978
- server.decorate('toolkit', 'validateOktaConfig', () => serviceOriginUnchanged(redirectUrl));
979
-
980
- server.auth.strategy('okta', 'bell', {
981
- provider: 'okta',
982
- config: {
983
- uri: OKTA_BASE_URL
984
- },
985
- password: await settings.get('cookiePassword'),
986
- isSecure: secureCookie,
987
- location: redirectUrl.origin,
988
-
964
+ await registerOktaAuth(server, ssoContext(secureCookie), {
965
+ baseUrl: OKTA_BASE_URL,
989
966
  clientId: OKTA_OAUTH2_CLIENT_ID,
990
967
  clientSecret: OKTA_OAUTH2_CLIENT_SECRET
991
968
  });
992
-
993
- server.route({
994
- method: ['GET', 'POST'],
995
- path: '/admin/login/okta',
996
- async handler(request, h) {
997
- if (!request.auth.isAuthenticated) {
998
- return ssoFailureRedirect(request, h, 'okta');
999
- }
1000
-
1001
- let profile = (request.auth.credentials && request.auth.credentials.profile) || {};
1002
-
1003
- // The same minimal shape the OIDC branch below stores, for the same reasons: the
1004
- // full bell credentials carry the access and refresh tokens, the callback query
1005
- // and the raw userinfo document, none of which the session validator reads, and
1006
- // all of which would sit in the browser's cookie for the life of the session.
1007
- setAdminSession(request, {
1008
- provider: 'okta',
1009
- profile: {
1010
- id: profile.id,
1011
- username: profile.username,
1012
- displayName: profile.displayName,
1013
- email: profile.email
1014
- },
1015
- passwordVersion: await sessionPasswordVersion()
1016
- });
1017
-
1018
- request.logger.info({ msg: 'Admin login successful', user: profile.username || 'unknown', method: 'okta', remoteAddress: request.app.ip });
1019
- return h.redirect('/admin');
1020
- },
1021
- options: {
1022
- auth: {
1023
- mode: 'try',
1024
- strategy: 'okta'
1025
- }
1026
- }
1027
- });
1028
969
  }
1029
- }
1030
-
1031
- async function registerOidcAuth(server, secureCookie) {
1032
970
  if (USE_OIDC_AUTH) {
1033
- let redirectUrl = await getServiceRedirectUrl();
1034
-
1035
- // bell needs static auth/token URLs at strategy-registration time, so the
1036
- // discovery document has to be in hand before the strategy and the callback
1037
- // route that depends on it can be registered. A failure to fetch it (IdP outage
1038
- // or misconfig) must NOT take EmailEngine down - password and passkey login plus
1039
- // the REST API have to keep working - so SSO simply stays switched off until a
1040
- // later attempt succeeds.
1041
- //
1042
- // Assigned from enableOidc()'s return value, so it can only be set once that
1043
- // strategy and route exist and validateOidcConfig() can never advertise a login
1044
- // button - or trigger OIDC_FORCED - for a route that is not registered.
1045
- let oidcDiscovery = null;
1046
-
1047
- // Registered unconditionally so the login/security views can call it; returns
1048
- // false when discovery failed or the serviceUrl origin drifted from startup.
1049
- server.decorate('toolkit', 'validateOidcConfig', async () => !!oidcDiscovery && (await serviceOriginUnchanged(redirectUrl)));
1050
-
1051
- // RP-initiated logout URL for the /admin/logout handler. Returns null unless
1052
- // OIDC_LOGOUT is enabled and the IdP advertised an end_session_endpoint.
1053
- // post_logout_redirect_uri is only sent when OIDC_POST_LOGOUT_REDIRECT_URI is
1054
- // configured (and registered at the IdP); otherwise the IdP shows its own
1055
- // logged-out page, so logout needs no IdP-side configuration.
1056
- server.decorate('toolkit', 'oidcLogoutUrl', idToken => {
1057
- if (!sso.OIDC_LOGOUT || !oidcDiscovery || !oidcDiscovery.end_session_endpoint) {
1058
- return null;
1059
- }
1060
- return sso.buildLogoutUrl(oidcDiscovery.end_session_endpoint, {
1061
- idToken,
1062
- clientId: sso.OIDC_CLIENT_ID,
1063
- postLogoutRedirectUri: sso.OIDC_POST_LOGOUT_REDIRECT_URI || undefined
1064
- });
1065
- });
1066
-
1067
- const enableOidc = async discoveryDoc => {
1068
- server.auth.strategy('oidc', 'bell', {
1069
- provider: sso.buildOidcBellProvider(discoveryDoc),
1070
- password: await settings.get('cookiePassword'),
1071
- isSecure: secureCookie,
1072
- location: redirectUrl.origin,
1073
-
1074
- clientId: sso.OIDC_CLIENT_ID,
1075
- clientSecret: sso.OIDC_CLIENT_SECRET
1076
- });
1077
-
1078
- server.route({
1079
- method: ['GET', 'POST'],
1080
- path: '/admin/login/oidc',
1081
- async handler(request, h) {
1082
- if (!request.auth.isAuthenticated) {
1083
- return ssoFailureRedirect(request, h, 'oidc');
1084
- }
1085
-
1086
- let profile = (request.auth.credentials && request.auth.credentials.profile) || {};
1087
-
1088
- // Enforce the optional email/group allow-lists before establishing the session.
1089
- if (!sso.isAuthorized(profile, oidcAllowList, oidcAllowGroups)) {
1090
- request.logger.warn({
1091
- msg: 'OIDC login denied by allow-list',
1092
- user: profile.username || profile.email || 'unknown',
1093
- groups: profile.groups,
1094
- method: 'oidc',
1095
- remoteAddress: request.app.ip
1096
- });
1097
- await request.flash({ type: 'danger', message: 'Your account is not authorized to access this admin panel' });
1098
- // ?sso_denied=1 stops a forced instance from auto-redirecting back into the
1099
- // OIDC flow before the user can see the error.
1100
- return h.redirect('/admin/login?sso_denied=1');
1101
- }
1102
-
1103
- // Store only the minimal profile - not the full bell credentials. OIDC
1104
- // access/refresh tokens (e.g. Keycloak JWTs) can push the iron-sealed
1105
- // `ee` cookie past the ~4KB browser limit and cause a silent login loop.
1106
- // Group names are kept so the per-request authorization re-check works;
1107
- // the id_token is kept only as the logout id_token_hint (RP-initiated logout).
1108
- const passwordVersion = await sessionPasswordVersion();
1109
- setAdminSession(request, {
1110
- provider: 'oidc',
1111
- profile: {
1112
- id: profile.id,
1113
- username: profile.username,
1114
- displayName: profile.displayName,
1115
- email: profile.email,
1116
- // Carried so the per-request isAuthorized() re-check enforces email
1117
- // verification the same way the login gate above does.
1118
- emailVerified: profile.emailVerified,
1119
- groups: profile.groups
1120
- },
1121
- passwordVersion,
1122
- idToken: (request.auth.artifacts && request.auth.artifacts.id_token) || null
1123
- });
1124
-
1125
- request.logger.info({ msg: 'Admin login successful', user: profile.username || 'unknown', method: 'oidc', remoteAddress: request.app.ip });
1126
- return h.redirect('/admin');
1127
- },
1128
- options: {
1129
- auth: {
1130
- mode: 'try',
1131
- strategy: 'oidc'
1132
- }
1133
- }
1134
- });
1135
-
1136
- return discoveryDoc;
1137
- };
1138
-
1139
- let startupDoc = await sso.fetchOidcDiscovery().catch(err => {
1140
- logger.error({ msg: 'OIDC SSO disabled for now: discovery failed, retrying in the background', issuer: sso.OIDC_ISSUER, err });
1141
- return null;
1142
- });
1143
-
1144
- if (startupDoc) {
1145
- // A registration failure here is deliberately fatal: a misconfiguration should
1146
- // stop the worker at boot rather than come up quietly without SSO. The retry
1147
- // path below is the opposite on purpose - it must not kill a serving process.
1148
- oidcDiscovery = await enableOidc(startupDoc);
1149
- } else {
1150
- // Deliberately not awaited - this runs for as long as the IdP is unreachable.
1151
- // hapi accepts both a new auth strategy and a new route after the server has
1152
- // started, so a later success brings SSO up in place, with no restart.
1153
- sso.retryDiscovery({
1154
- onError: (err, attempt) => logger.debug({ msg: 'OIDC discovery retry failed', issuer: sso.OIDC_ISSUER, attempt, err })
1155
- })
1156
- .then(async retriedDoc => {
1157
- oidcDiscovery = await enableOidc(retriedDoc);
1158
- logger.info({ msg: 'OIDC SSO enabled after retrying discovery', issuer: sso.OIDC_ISSUER });
1159
- })
1160
- .catch(err => logger.error({ msg: 'OIDC SSO disabled: discovery retry failed', issuer: sso.OIDC_ISSUER, err }));
1161
- }
971
+ // the background discovery retry, when there is one, is deliberately not awaited
972
+ await registerOidcAuth(server, ssoContext(secureCookie), { allowList: oidcAllowList, allowGroups: oidcAllowGroups });
1162
973
  }
1163
974
  }
1164
975
 
@@ -2650,248 +2461,7 @@ function registerViews(server) {
2650
2461
  // template edits.
2651
2462
  isCached: process.env.NODE_ENV !== 'development',
2652
2463
 
2653
- async context(request) {
2654
- // The three reads are independent, and this runs on every admin page render. The
2655
- // OAuth2 auth flags are best-effort - a failure to read them must not take the page
2656
- // down with it.
2657
- const [pendingMessages, settingsValues, oauthAuthFlags] = await Promise.all([
2658
- flash(redis, request),
2659
- settings.getMulti(
2660
- 'upgrade',
2661
- 'webhookErrorFlag',
2662
- 'webhooksEnabled',
2663
- 'disableTokens',
2664
- 'tract',
2665
- 'templateHeader',
2666
- 'templateHtmlHead',
2667
- 'documentStoreEnabled',
2668
- 'serviceUrl',
2669
- 'language',
2670
- 'locale',
2671
- 'timezone',
2672
- 'pageBrandName',
2673
- 'notificationBaseUrl'
2674
- ),
2675
- oauth2Apps.listAuthFlags().catch(err => {
2676
- logger.error({ msg: 'Failed to list OAuth2 app auth flags', err });
2677
- return [];
2678
- })
2679
- ]);
2680
-
2681
- const {
2682
- upgrade: upgradeInfo,
2683
- webhookErrorFlag,
2684
- webhooksEnabled,
2685
- disableTokens,
2686
- tract,
2687
- templateHeader: embeddedTemplateHeader,
2688
- templateHtmlHead: embeddedTemplateHtmlHead,
2689
- // The Document Store was removed in 2.82.0. The setting that switched it on is
2690
- // read raw off the settings hash (it is no longer in the settings schema), so an
2691
- // instance upgraded with the feature still on is told where it went instead of
2692
- // losing it quietly
2693
- documentStoreEnabled: documentStoreRemoved,
2694
- serviceUrl,
2695
- language,
2696
- locale,
2697
- timezone,
2698
- pageBrandName,
2699
- notificationBaseUrl
2700
- } = settingsValues;
2701
-
2702
- let systemAlerts = [];
2703
- let authData;
2704
-
2705
- switch (request.auth.artifacts && request.auth.artifacts.provider) {
2706
- case 'okta': {
2707
- let profile = request.auth.artifacts.profile || {};
2708
- authData = {
2709
- user: profile.username,
2710
- name:
2711
- []
2712
- .concat(profile.firstName || [])
2713
- .concat(profile.lastName || [])
2714
- .join(' ') || profile.username,
2715
- enabled: !!profile.username,
2716
- isAdmin: false
2717
- };
2718
- break;
2719
- }
2720
-
2721
- case 'oidc': {
2722
- let profile = request.auth.artifacts.profile || {};
2723
- authData = {
2724
- user: profile.username,
2725
- name: profile.displayName || profile.username,
2726
- enabled: !!profile.username,
2727
- isAdmin: false
2728
- };
2729
- break;
2730
- }
2731
-
2732
- default:
2733
- authData = await settings.get('authData');
2734
- if (authData) {
2735
- authData.name = authData.user;
2736
- authData.enabled = true;
2737
- authData.isAdmin = true;
2738
- } else {
2739
- authData = {
2740
- name: 'admin',
2741
- user: 'admin',
2742
- enabled: false,
2743
- isAdmin: true
2744
- };
2745
- }
2746
- break;
2747
- }
2748
-
2749
- if (upgradeInfo && upgradeInfo.canUpgrade) {
2750
- systemAlerts.push({
2751
- url: '/admin/upgrade',
2752
- level: 'info',
2753
- icon: 'icon-[tabler--alert-triangle]',
2754
- message: `An update is available: Emailengine v${upgradeInfo.available}`
2755
- });
2756
- }
2757
-
2758
- // The subscription behind the license (lib/license-subscription.js): paused, or a date it pauses on
2759
- let licenseSubscription = request.app.licenseInfo && request.app.licenseInfo.subscription;
2760
- if (isSuspended(request.app.licenseInfo)) {
2761
- systemAlerts.push({
2762
- url: '/admin/config/license',
2763
- level: 'danger',
2764
- icon: 'icon-[tabler--player-pause]',
2765
- message: 'EmailEngine is paused: the subscription behind the license key is not in good standing'
2766
- });
2767
- } else if (licenseSubscription) {
2768
- systemAlerts.push({
2769
- url: '/admin/config/license',
2770
- level: 'danger',
2771
- icon: 'icon-[tabler--alert-triangle]',
2772
- message: `Subscription payment overdue: EmailEngine pauses in ${licenseSubscription.days} day${
2773
- licenseSubscription.days !== 1 ? 's' : ''
2774
- } unless it is paid`
2775
- });
2776
- }
2777
-
2778
- // OAuth2 apps whose token requests are being refused (setFlag() writes the failure
2779
- // into app meta). Shown on every admin page: the accounts on such an app sit
2780
- // disconnected until the operator acts, so the OAuth config page alone is not enough.
2781
- for (let { app, authFlag } of oauthAuthFlags) {
2782
- systemAlerts.push({
2783
- url: authFlag.url || `/admin/config/oauth/app/${encodeURIComponent(app)}`,
2784
- level: 'danger',
2785
- icon: 'icon-[tabler--lock-open]',
2786
- message: authFlag.message
2787
- });
2788
- }
2789
-
2790
- if (webhooksEnabled && webhookErrorFlag && webhookErrorFlag.message) {
2791
- systemAlerts.push({
2792
- url: '/admin/config/webhooks',
2793
- level: 'danger',
2794
- icon: 'icon-[tabler--link]',
2795
- message: 'Webhook delivery is failing'
2796
- });
2797
- }
2798
-
2799
- // a paused license is still registered, and the alert above says why it is not active
2800
- if (!request.app.licenseInfo || (!request.app.licenseInfo.active && !request.app.licenseInfo.details)) {
2801
- systemAlerts.push({
2802
- url: '/admin/config/license',
2803
- level: 'warning',
2804
- icon: 'icon-[tabler--key]',
2805
- message: 'No license key registered'
2806
- });
2807
- }
2808
-
2809
- let licenseDetails = Object.assign({}, (request.app.licenseInfo && request.app.licenseInfo.details) || {});
2810
-
2811
- if (licenseDetails.expires) {
2812
- let delayMs = new Date(licenseDetails.expires) - Date.now();
2813
- licenseDetails.expiresDays = Math.max(Math.ceil(delayMs / (24 * 3600 * 1000)), 0);
2814
- }
2815
-
2816
- if (licenseDetails.expires && licenseDetails.expiresDays < 31) {
2817
- systemAlerts.push({
2818
- url: '/admin/config/license',
2819
- level: 'warning',
2820
- icon: 'icon-[tabler--key]',
2821
- message: `Your ${licenseDetails.trial ? `trial ` : ''}license key will expire in ${licenseDetails.expiresDays} day${
2822
- licenseDetails.expiresDays !== 1 ? 's' : ''
2823
- }`
2824
- });
2825
- }
2826
-
2827
- if (disableTokens) {
2828
- systemAlerts.push({
2829
- url: '/admin/config/security',
2830
- level: 'warning',
2831
- icon: 'icon-[tabler--key]',
2832
- message: `Access tokens are disabled for API requests`
2833
- });
2834
- }
2835
-
2836
- if (documentStoreRemoved) {
2837
- systemAlerts.push({
2838
- url: '/admin',
2839
- level: 'danger',
2840
- icon: 'icon-[tabler--database]',
2841
- message: `The Document Store has been removed from EmailEngine. Downgrade to v${LAST_DOCUMENT_STORE_VERSION} if you still need it.`
2842
- });
2843
- }
2844
-
2845
- // Check if setup warnings should be disabled (for documentation screenshots, CI, etc.)
2846
- const disableSetupWarnings = hasEnvValue('EENGINE_DISABLE_SETUP_WARNINGS') ? getBoolean(readEnvValue('EENGINE_DISABLE_SETUP_WARNINGS')) : false;
2847
-
2848
- if (disableSetupWarnings) {
2849
- // Keep only critical (danger) alerts, suppress info/warning level
2850
- systemAlerts = systemAlerts.filter(alert => alert.level === 'danger');
2851
- }
2852
-
2853
- // Whether the requester holds a session at all, so a public page (the hosted form's
2854
- // error page, for one) can tell a mailbox owner from an admin without reading
2855
- // authData, which describes the instance rather than the requester
2856
- const isAuthenticated = !!(request.auth && request.auth.isAuthenticated);
2857
-
2858
- return {
2859
- // the per-request CSP nonce every inline <script> carries (lib/security-headers.js)
2860
- cspNonce: request.app.cspNonce,
2861
- pageBrandName: pageBrandName || 'EmailEngine',
2862
- values: request.payload || {},
2863
- errors: (request.error && request.error.details) || {},
2864
- pendingMessages,
2865
- licenseInfo: request.app.licenseInfo,
2866
- licenseDetails,
2867
- trialPossible: !tract,
2868
- authData,
2869
- isAuthenticated,
2870
- // The dashboard is an admin destination: a link to it belongs on a page only for
2871
- // a requester who holds an admin session, or on an instance with no admin login
2872
- showDashboardLink: isAuthenticated || !(authData && authData.enabled),
2873
- packageData,
2874
- systemAlerts,
2875
- embeddedTemplateHeader,
2876
- embeddedTemplateHtmlHead,
2877
- currentYear: new Date().getFullYear(),
2878
- documentStoreRemoved,
2879
- lastDocumentStoreVersion: LAST_DOCUMENT_STORE_VERSION,
2880
- updateBrowserInfo: !serviceUrl || !language || !timezone,
2881
-
2882
- // Suppress large banner warnings when EENGINE_DISABLE_SETUP_WARNINGS is set
2883
- hideLicenseWarning: disableSetupWarnings,
2884
- disableAuthWarning: disableSetupWarnings,
2885
-
2886
- mainServiceUrl: serviceUrl,
2887
- notificationBaseUrl,
2888
-
2889
- userLocale: locale,
2890
- userTimezone: timezone,
2891
-
2892
- templateLocale: request.app.locale
2893
- };
2894
- }
2464
+ context: buildViewContext
2895
2465
  });
2896
2466
  }
2897
2467
 
@@ -3177,8 +2747,7 @@ const init = async () => {
3177
2747
 
3178
2748
  const secureCookie = await registerSessionAuth(server);
3179
2749
 
3180
- await registerOktaAuth(server, secureCookie);
3181
- await registerOidcAuth(server, secureCookie);
2750
+ await registerSsoAuth(server, secureCookie);
3182
2751
 
3183
2752
  await registerServerPlugins(server);
3184
2753