refactor(core): Port SSO config (#17044)

This commit is contained in:
Iván Ovejero
2025-07-07 16:59:35 +02:00
committed by GitHub
parent 044b0bb330
commit 982a7a11f5
13 changed files with 116 additions and 90 deletions

View File

@@ -0,0 +1,48 @@
import { Config, Env, Nested } from '../decorators';
@Config
class SamlConfig {
/** Whether to enable SAML SSO. */
@Env('N8N_SSO_SAML_LOGIN_ENABLED')
loginEnabled: boolean = false;
@Env('N8N_SSO_SAML_LOGIN_LABEL')
loginLabel: string = '';
}
@Config
class OidcConfig {
/** Whether to enable OIDC SSO. */
@Env('N8N_SSO_OIDC_LOGIN_ENABLED')
loginEnabled: boolean = false;
}
@Config
class LdapConfig {
/** Whether to enable LDAP SSO. */
@Env('N8N_SSO_LDAP_LOGIN_ENABLED')
loginEnabled: boolean = false;
@Env('N8N_SSO_LDAP_LOGIN_LABEL')
loginLabel: string = '';
}
@Config
export class SsoConfig {
/** Whether to create users when they log in via SSO. */
@Env('N8N_SSO_JUST_IN_TIME_PROVISIONING')
justInTimeProvisioning: boolean = true;
/** Whether to redirect users from the login dialog to initialize SSO flow. */
@Env('N8N_SSO_REDIRECT_LOGIN_TO_SSO')
redirectLoginToSso: boolean = true;
@Nested
saml: SamlConfig;
@Nested
oidc: OidcConfig;
@Nested
ldap: LdapConfig;
}

View File

@@ -25,6 +25,7 @@ import { TaskRunnersConfig } from './configs/runners.config';
import { ScalingModeConfig } from './configs/scaling-mode.config';
import { SecurityConfig } from './configs/security.config';
import { SentryConfig } from './configs/sentry.config';
import { SsoConfig } from './configs/sso.config';
import { TagsConfig } from './configs/tags.config';
import { TemplatesConfig } from './configs/templates.config';
import { UserManagementConfig } from './configs/user-management.config';
@@ -167,6 +168,9 @@ export class GlobalConfig {
@Nested
personalization: PersonalizationConfig;
@Nested
sso: SsoConfig;
/** Default locale for the UI. */
@Env('N8N_DEFAULT_LOCALE')
defaultLocale: string = 'en';

View File

@@ -331,6 +331,21 @@ describe('GlobalConfig', () => {
enabled: true,
pruneTime: -1,
},
sso: {
justInTimeProvisioning: true,
redirectLoginToSso: true,
saml: {
loginEnabled: false,
loginLabel: '',
},
oidc: {
loginEnabled: false,
},
ldap: {
loginEnabled: false,
loginLabel: '',
},
},
};
it('should use all default values when no env variables are defined', () => {