|
1 | | -import type { |
2 | | - FrontendSettings, |
3 | | - IEnterpriseSettings, |
4 | | - ITelemetrySettings, |
5 | | - N8nEnvFeatFlags, |
6 | | -} from '@n8n/api-types'; |
| 1 | +import type { FrontendSettings, ITelemetrySettings, N8nEnvFeatFlags } from '@n8n/api-types'; |
7 | 2 | import { LicenseState, Logger, ModuleRegistry } from '@n8n/backend-common'; |
8 | 3 | import { GlobalConfig, SecurityConfig } from '@n8n/config'; |
9 | 4 | import { LICENSE_FEATURES } from '@n8n/constants'; |
@@ -37,29 +32,63 @@ import { |
37 | 32 | getWorkflowHistoryPruneTime, |
38 | 33 | } from '@/workflows/workflow-history/workflow-history-helper'; |
39 | 34 |
|
40 | | -export type PublicEnterpriseSettings = Pick< |
41 | | - IEnterpriseSettings, |
42 | | - 'saml' | 'ldap' | 'oidc' | 'showNonProdBanner' |
43 | | ->; |
44 | | - |
45 | | -export type PublicFrontendSettings = Pick< |
46 | | - FrontendSettings, |
47 | | - | 'settingsMode' |
48 | | - | 'instanceId' |
49 | | - | 'defaultLocale' |
50 | | - | 'versionCli' |
51 | | - | 'releaseChannel' |
52 | | - | 'versionNotifications' |
53 | | - | 'userManagement' |
54 | | - | 'sso' |
55 | | - | 'mfa' |
56 | | - | 'authCookie' |
57 | | - | 'oauthCallbackUrls' |
58 | | - | 'banners' |
59 | | - | 'previewMode' |
60 | | - | 'telemetry' |
61 | | -> & { |
62 | | - enterprise: PublicEnterpriseSettings; |
| 35 | +/** |
| 36 | + * IMPORTANT: Only add settings that are absolutely necessary for non-authenticated pages |
| 37 | + */ |
| 38 | +export type PublicFrontendSettings = { |
| 39 | + /** Controls initialization flow in settings store */ |
| 40 | + settingsMode: FrontendSettings['settingsMode']; |
| 41 | + |
| 42 | + /** Used to bypass authentication on the workflows/demo page */ |
| 43 | + previewMode: FrontendSettings['previewMode']; |
| 44 | + |
| 45 | + authCookie: { |
| 46 | + /** Blocks insecure access incompatible with the authentication cookie. */ |
| 47 | + secure: FrontendSettings['authCookie']['secure']; |
| 48 | + }; |
| 49 | + |
| 50 | + userManagement: { |
| 51 | + /** Used to control login page UI behaviour and conditional SSO Login display */ |
| 52 | + authenticationMethod: FrontendSettings['userManagement']['authenticationMethod']; |
| 53 | + |
| 54 | + /** Enables initial owner setup */ |
| 55 | + showSetupOnFirstLoad: FrontendSettings['userManagement']['showSetupOnFirstLoad']; |
| 56 | + |
| 57 | + /** Determines forgot password page UX */ |
| 58 | + smtpSetup: FrontendSettings['userManagement']['smtpSetup']; |
| 59 | + }; |
| 60 | + |
| 61 | + enterprise: { |
| 62 | + /** License check for SAML for SSO button visibility */ |
| 63 | + saml: FrontendSettings['enterprise']['saml']; |
| 64 | + |
| 65 | + /** License check for OIDC for SSO button visibility */ |
| 66 | + oidc: FrontendSettings['enterprise']['oidc']; |
| 67 | + |
| 68 | + /** License check for LDAP authentication */ |
| 69 | + ldap: FrontendSettings['enterprise']['ldap']; |
| 70 | + }; |
| 71 | + |
| 72 | + sso: { |
| 73 | + saml: { |
| 74 | + /** Config flag for SSO button*/ |
| 75 | + loginEnabled: FrontendSettings['sso']['saml']['loginEnabled']; |
| 76 | + }; |
| 77 | + ldap: { |
| 78 | + /** Config flag for LDAP authentication */ |
| 79 | + loginEnabled: FrontendSettings['sso']['ldap']['loginEnabled']; |
| 80 | + |
| 81 | + /** Customizes login form label (defaults to "Email") */ |
| 82 | + loginLabel: FrontendSettings['sso']['ldap']['loginLabel']; |
| 83 | + }; |
| 84 | + oidc: { |
| 85 | + /** Config flag for SSO button*/ |
| 86 | + loginEnabled: FrontendSettings['sso']['oidc']['loginEnabled']; |
| 87 | + |
| 88 | + /** Required for OIDC authentication redirect URL */ |
| 89 | + loginUrl: FrontendSettings['sso']['oidc']['loginUrl']; |
| 90 | + }; |
| 91 | + }; |
63 | 92 | }; |
64 | 93 |
|
65 | 94 | @Service() |
@@ -491,39 +520,31 @@ export class FrontendService { |
491 | 520 | getPublicSettings(): PublicFrontendSettings { |
492 | 521 | // Get full settings to ensure all required properties are initialized |
493 | 522 | const { |
494 | | - instanceId, |
495 | | - defaultLocale, |
496 | | - versionCli, |
497 | | - releaseChannel, |
498 | | - versionNotifications, |
499 | | - userManagement, |
500 | | - sso, |
501 | | - mfa, |
| 523 | + userManagement: { authenticationMethod, showSetupOnFirstLoad, smtpSetup }, |
| 524 | + sso: { saml: ssoSaml, ldap: ssoLdap, oidc: ssoOidc }, |
502 | 525 | authCookie, |
503 | | - oauthCallbackUrls, |
504 | | - banners, |
505 | 526 | previewMode, |
506 | | - telemetry, |
507 | | - enterprise: { saml, ldap, oidc, showNonProdBanner }, |
| 527 | + enterprise: { saml, ldap, oidc }, |
508 | 528 | } = this.getSettings(); |
509 | 529 |
|
510 | | - return { |
| 530 | + const publicSettings: PublicFrontendSettings = { |
511 | 531 | settingsMode: 'public', |
512 | | - instanceId, |
513 | | - defaultLocale, |
514 | | - versionCli, |
515 | | - releaseChannel, |
516 | | - versionNotifications, |
517 | | - userManagement, |
518 | | - sso, |
519 | | - mfa, |
| 532 | + userManagement: { authenticationMethod, showSetupOnFirstLoad, smtpSetup }, |
| 533 | + sso: { |
| 534 | + saml: { |
| 535 | + loginEnabled: ssoSaml.loginEnabled, |
| 536 | + }, |
| 537 | + ldap: ssoLdap, |
| 538 | + oidc: { |
| 539 | + loginEnabled: ssoOidc.loginEnabled, |
| 540 | + loginUrl: ssoOidc.loginUrl, |
| 541 | + }, |
| 542 | + }, |
520 | 543 | authCookie, |
521 | | - oauthCallbackUrls, |
522 | | - banners, |
523 | 544 | previewMode, |
524 | | - telemetry, |
525 | | - enterprise: { saml, ldap, oidc, showNonProdBanner }, |
| 545 | + enterprise: { saml, ldap, oidc }, |
526 | 546 | }; |
| 547 | + return publicSettings; |
527 | 548 | } |
528 | 549 |
|
529 | 550 | getModuleSettings() { |
|
0 commit comments