Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.
TypeScript cloud-alternativecollaborationcollaborative-editingdropboxfile-serverfile-sharingfile-storagefile-syncfull-text-searchhomelabnextcloudon-premiseopen-sourceprivacy-firstprivate-cloudrealtimesecureself-hostedstorage-serverwebdav
feat(config): group editor config under files.editors
johavenbd50a298d64e
diff --git a/backend/src/app.bootstrap.ts b/backend/src/app.bootstrap.tsindex 97fa98b1..63b4e3c1 100644--- a/backend/src/app.bootstrap.ts+++ b/backend/src/app.bootstrap.ts@@ -61,8 +61,8 @@ export async function appBootstrap(): Promise<NestFastifyApplication> {/* SECURITY */await app.register(fastifyHelmet, {contentSecurityPolicy: CONTENT_SECURITY_POLICY(- configuration.applications.files.onlyoffice.externalServer,- configuration.applications.files.collabora.externalServer+ configuration.applications.files.editors.onlyoffice.externalServer,+ configuration.applications.files.editors.collabora.externalServer)})diff --git a/backend/src/app.service.spec.ts b/backend/src/app.service.spec.tsindex 1dac417b..4f63f48b 100644--- a/backend/src/app.service.spec.ts+++ b/backend/src/app.service.spec.ts@@ -83,6 +83,7 @@ describe(AppService.name, () => {expect(conf.logger.colorize).toBe(true)const tmpSecretFile = path.join(os.tmpdir(), 'secret')fs.writeFileSync(tmpSecretFile, 'fooBAR8888')+ const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => undefined)process.env[`${ENVIRONMENT_PREFIX}APPLICATIONS_FILES_ONLYOFFICE_SECRET`] = 'fooBAR'process.env[`${ENVIRONMENT_PREFIX}LOGGER_STDOUT`] = 'false'process.env[`${ENVIRONMENT_PREFIX}LOGGER_COLORIZE`] = '"false"'@@ -91,7 +92,10 @@ describe(AppService.name, () => {// docker compose secret fileprocess.env[`${ENVIRONMENT_PREFIX}AUTH_TOKEN_ACCESS_SECRET_FILE`] = tmpSecretFileconf = exportConfiguration(true)- expect(conf.applications.files.onlyoffice.secret).toBe('fooBAR')+ expect(conf.applications.files.editors.onlyoffice.secret).toBe('fooBAR')+ expect(warnSpy).toHaveBeenCalledWith(+ `Environment variable "${ENVIRONMENT_PREFIX}APPLICATIONS_FILES_ONLYOFFICE_SECRET" is deprecated. Please use "${ENVIRONMENT_PREFIX}APPLICATIONS_FILES_EDITORS_ONLYOFFICE_SECRET" instead.`+ )expect(conf.logger.stdout).toBe(false)expect(conf.logger.colorize).toBe(false)expect(conf.applications.files.maxUploadSize).toBe(8888)diff --git a/backend/src/applications/files/editors/collabora-online/collabora-online-manager.service.ts b/backend/src/applications/files/editors/collabora-online/collabora-online-manager.service.tsindex 45368f4e..1b8b72a3 100644--- a/backend/src/applications/files/editors/collabora-online/collabora-online-manager.service.ts+++ b/backend/src/applications/files/editors/collabora-online/collabora-online-manager.service.ts@@ -48,7 +48,7 @@ import { ACTION } from '../../../../common/constants'@Injectable()export class CollaboraOnlineManager {private logger = new Logger(CollaboraOnlineManager.name)- private readonly externalCollaboraOnlineServer = configuration.applications.files.collabora.externalServer || null+ private readonly externalCollaboraOnlineServer = configuration.applications.files.editors.collabora.externalServer || nullprivate readonly expiration = convertHumanTimeToSeconds(configuration.auth.token.refresh.expiration)constructor(diff --git a/backend/src/applications/files/editors/only-office/only-office-manager.service.ts b/backend/src/applications/files/editors/only-office/only-office-manager.service.tsindex 4ff86e82..0b6bd6d2 100644--- a/backend/src/applications/files/editors/only-office/only-office-manager.service.ts+++ b/backend/src/applications/files/editors/only-office/only-office-manager.service.ts@@ -55,8 +55,8 @@ import { ACTION } from '../../../../common/constants'@Injectable()export class OnlyOfficeManager {private logger = new Logger(OnlyOfficeManager.name)- private readonly externalOnlyOfficeServer = configuration.applications.files.onlyoffice.externalServer || null- private readonly rejectUnauthorized: boolean = !configuration.applications.files.onlyoffice?.verifySSL+ private readonly externalOnlyOfficeServer = configuration.applications.files.editors.onlyoffice.externalServer || null+ private readonly rejectUnauthorized: boolean = !configuration.applications.files.editors.onlyoffice?.verifySSLprivate readonly convertUrl = this.externalOnlyOfficeServer ? `${this.externalOnlyOfficeServer}/ConvertService.ashx` : nullprivate readonly expiration = convertHumanTimeToSeconds(configuration.auth.token.refresh.expiration)private readonly mobileRegex: RegExp = /android|webos|iphone|ipad|ipod|blackberry|windows phone|opera mini|iemobile|mobile/i@@ -110,7 +110,7 @@ export class OnlyOfficeManager {}async callBack(user: UserModel, space: SpaceEnv, token: string) {- const callBackData: OnlyOfficeCallBack = await this.jwt.verifyAsync(token, { secret: configuration.applications.files.onlyoffice.secret })+ const callBackData: OnlyOfficeCallBack = await this.jwt.verifyAsync(token, { secret: configuration.applications.files.editors.onlyoffice.secret })try {switch (callBackData.status) {case 1:@@ -230,7 +230,7 @@ export class OnlyOfficeManager {}private genPayloadToken(payload: OnlyOfficeConfig | OnlyOfficeConvertForm): Promise<string> {- return this.jwt.signAsync(payload, { secret: configuration.applications.files.onlyoffice.secret, expiresIn: 60 })+ return this.jwt.signAsync(payload, { secret: configuration.applications.files.editors.onlyoffice.secret, expiresIn: 60 })}private genAuthToken(user: UserModel): Promise<string> {diff --git a/backend/src/applications/files/files.config.ts b/backend/src/applications/files/files.config.tsindex 0abf7a10..d96af88c 100644--- a/backend/src/applications/files/files.config.ts+++ b/backend/src/applications/files/files.config.ts@@ -62,6 +62,18 @@ export class FilesTrashRetentionConfig {spaces: number | false = false}+export class FilesEditorsConfig {+ @IsNotEmptyObject()+ @ValidateNested()+ @Type(() => OnlyOfficeConfig)+ onlyoffice: OnlyOfficeConfig = new OnlyOfficeConfig()++ @IsNotEmptyObject()+ @ValidateNested()+ @Type(() => CollaboraOnlineConfig)+ collabora: CollaboraOnlineConfig = new CollaboraOnlineConfig()+}+export class FilesConfig {@IsNotEmpty()@IsString()@@ -110,11 +122,6 @@ export class FilesConfig {@IsNotEmptyObject()@ValidateNested()- @Type(() => OnlyOfficeConfig)- onlyoffice: OnlyOfficeConfig = new OnlyOfficeConfig()-- @IsNotEmptyObject()- @ValidateNested()- @Type(() => CollaboraOnlineConfig)- collabora: CollaboraOnlineConfig = new CollaboraOnlineConfig()+ @Type(() => FilesEditorsConfig)+ editors: FilesEditorsConfig = new FilesEditorsConfig()}diff --git a/backend/src/applications/files/files.module.ts b/backend/src/applications/files/files.module.tsindex 5397c78e..6a19eab9 100644--- a/backend/src/applications/files/files.module.ts+++ b/backend/src/applications/files/files.module.ts@@ -25,8 +25,8 @@ import { FilesTrashRetention } from './services/files-trash-retention.service'@Module({imports: [- ...(configuration.applications.files.onlyoffice.enabled ? [OnlyOfficeModule] : []),- ...(configuration.applications.files.collabora.enabled ? [CollaboraOnlineModule] : [])+ ...(configuration.applications.files.editors.onlyoffice.enabled ? [OnlyOfficeModule] : []),+ ...(configuration.applications.files.editors.collabora.enabled ? [CollaboraOnlineModule] : [])],controllers: [FilesController, FilesTasksController],providers: [diff --git a/backend/src/configuration/config.environment.ts b/backend/src/configuration/config.environment.tsindex c78b9c11..a569153c 100755--- a/backend/src/configuration/config.environment.ts+++ b/backend/src/configuration/config.environment.ts@@ -6,6 +6,7 @@ import { ACCESS_KEY, CSRF_KEY, TWO_FA_VERIFY_EXPIRATION, WS_KEY } from '../autheimport { TOKEN_TYPE } from '../authentication/interfaces/token.interface'import { transformAndValidate } from '../common/functions'import { ServerConfig } from './config.interfaces'+import { ENVIRONMENT_PREFIX } from './config.constants'import { configLoader } from './config.loader'import { GlobalConfig } from './config.validation'@@ -15,8 +16,8 @@ export const serverConfig: ServerConfig = {mailServerEnabled: !!configuration.mail?.host,files: {editors: {- collabora: configuration.applications.files.collabora.enabled,- onlyoffice: configuration.applications.files.onlyoffice.enabled+ collabora: configuration.applications.files.editors.collabora.enabled,+ onlyoffice: configuration.applications.files.editors.onlyoffice.enabled},sampleDocuments: getDocumentTypes(configuration.applications.files.sampleDocuments)}@@ -24,6 +25,7 @@ export const serverConfig: ServerConfig = {export const exportConfiguration: (reload?: boolean) => GlobalConfig = (reload = false) => (reload ? loadConfiguration() : configuration)function loadConfiguration(): GlobalConfig {+ deprecatedFilesEditorsEnvConfig()const config: GlobalConfig = configLoader()// LOGGERif (config.logger?.stdout === false) {@@ -51,16 +53,8 @@ function loadConfiguration(): GlobalConfig {config.applications.files.spacesPath = join(config.applications.files.dataPath, 'spaces')config.applications.files.tmpPath = join(config.applications.files.dataPath, 'tmp')// DEPRECATIONS- // applications.files.contentIndexing → applications.files.contentIndexing.enabled- if (typeof config.applications.files.contentIndexing === 'boolean') {- const filesContentIndexingConfig = new FilesContentIndexingConfig()- filesContentIndexingConfig.enabled = config.applications.files.contentIndexing- config.applications.files.contentIndexing = filesContentIndexingConfig- console.warn(- '[DEPRECATED][CONFIGURATION] applications.files.contentIndexing is deprecated and will be removed in a future version. ' +- 'Please use applications.files.contentIndexing.enabled instead.'- )- }+ deprecatedFilesEditorsConfig(config)+ deprecatedFilesContentIndexingConfig(config)return transformAndValidate(GlobalConfig,@@ -70,3 +64,69 @@ function loadConfiguration(): GlobalConfig {'Invalid configuration in environment.yaml')}++function deprecatedFilesEditorsEnvConfig(): void {+ for (const editor of ['ONLYOFFICE', 'COLLABORA']) {+ const deprecatedPrefix = `${ENVIRONMENT_PREFIX}APPLICATIONS_FILES_${editor}_`+ const currentPrefix = `${ENVIRONMENT_PREFIX}APPLICATIONS_FILES_EDITORS_${editor}_`++ for (const [deprecatedEnvKey, value] of Object.entries(process.env)) {+ if (!deprecatedEnvKey.startsWith(deprecatedPrefix) || value === undefined) {+ continue+ }++ const suffix = deprecatedEnvKey.slice(deprecatedPrefix.length)+ const currentEnvKey = `${currentPrefix}${suffix}`+ const alternateCurrentEnvKey = suffix.endsWith('_FILE') ? `${currentPrefix}${suffix.slice(0, -5)}` : `${currentEnvKey}_FILE`+ const configuredCurrentEnvKey = [currentEnvKey, alternateCurrentEnvKey].find((key) => process.env[key] !== undefined)++ if (configuredCurrentEnvKey) {+ console.warn(`Ignoring deprecated environment variable: "${deprecatedEnvKey}" because "${configuredCurrentEnvKey}" is set.`)+ continue+ }++ process.env[currentEnvKey] = value+ console.warn(`Environment variable "${deprecatedEnvKey}" is deprecated. Please use "${currentEnvKey}" instead.`)+ }+ }+}++function deprecatedFilesEditorsConfig(config: GlobalConfig): void {+ const files = config.applications.files as unknown as Record<string, any>+ const legacyEditors = ['onlyoffice', 'collabora'].filter((editor) => Object.prototype.hasOwnProperty.call(files, editor))++ if (legacyEditors.length === 0) {+ return+ }++ files.editors ??= {}+ for (const editor of legacyEditors) {+ const legacyConfig = files[editor]+ const currentConfig = files.editors[editor]+ files.editors[editor] =+ legacyConfig && currentConfig && typeof legacyConfig === 'object' && typeof currentConfig === 'object'+ ? { ...legacyConfig, ...currentConfig }+ : (currentConfig ?? legacyConfig)+ delete files[editor]+ }++ console.warn(+ '[DEPRECATED][CONFIGURATION] applications.files.onlyoffice and applications.files.collabora are deprecated and will be removed in a future version. ' ++ 'Please use applications.files.editors.onlyoffice and applications.files.editors.collabora instead.'+ )+}++function deprecatedFilesContentIndexingConfig(config: GlobalConfig): void {+ // applications.files.contentIndexing → applications.files.contentIndexing.enabled+ if (typeof config.applications.files.contentIndexing !== 'boolean') {+ return+ }++ const filesContentIndexingConfig = new FilesContentIndexingConfig()+ filesContentIndexingConfig.enabled = config.applications.files.contentIndexing+ config.applications.files.contentIndexing = filesContentIndexingConfig+ console.warn(+ '[DEPRECATED][CONFIGURATION] applications.files.contentIndexing is deprecated and will be removed in a future version. ' ++ 'Please use applications.files.contentIndexing.enabled instead.'+ )+}diff --git a/backend/src/configuration/config.loader.spec.ts b/backend/src/configuration/config.loader.spec.tsindex d0f4bcca..e73b9e68 100644--- a/backend/src/configuration/config.loader.spec.ts+++ b/backend/src/configuration/config.loader.spec.ts@@ -35,9 +35,9 @@ describe(configLoader.name, () => {})it('should apply nested overrides while preserving camelCase keys', () => {- process.env[`${ENVIRONMENT_PREFIX}APPLICATIONS_FILES_ONLYOFFICE_EXTERNALSERVER`] = 'https://onlyoffice.example.com'+ process.env[`${ENVIRONMENT_PREFIX}APPLICATIONS_FILES_EDITORS_ONLYOFFICE_EXTERNALSERVER`] = 'https://onlyoffice.example.com'- expect(configLoader().applications.files.onlyoffice.externalServer).toBe('https://onlyoffice.example.com')+ expect(configLoader().applications.files.editors.onlyoffice.externalServer).toBe('https://onlyoffice.example.com')})it.each([`${ENVIRONMENT_PREFIX}UNKNOWN_PROPERTY`, `${ENVIRONMENT_PREFIX}LOGGER_UNKNOWN`])(@@ -76,13 +76,13 @@ describe(configLoader.name, () => {})it('should merge an environment override without replacing sibling base configuration', () => {- const baseSecret = configLoader().applications.files.onlyoffice.secret- process.env[`${ENVIRONMENT_PREFIX}APPLICATIONS_FILES_ONLYOFFICE_ENABLED`] = 'true'+ const baseSecret = configLoader().auth.token.access.secret+ process.env[`${ENVIRONMENT_PREFIX}AUTH_TOKEN_ACCESS_EXPIRATION`] = '10m'- const onlyoffice = configLoader().applications.files.onlyoffice+ const accessToken = configLoader().auth.token.access- expect(onlyoffice.enabled).toBe(true)- expect(onlyoffice.secret).toBe(baseSecret)+ expect(accessToken.expiration).toBe('10m')+ expect(accessToken.secret).toBe(baseSecret)})function clearSyncInEnv() {diff --git a/environment/environment.dist.yaml b/environment/environment.dist.yamlindex ac2a1545..bb84a31e 100755--- a/environment/environment.dist.yaml+++ b/environment/environment.dist.yaml@@ -369,30 +369,31 @@ applications:# use [] to only show Text and Markdown# default: [opendocument, microsoft]sampleDocuments: [opendocument, microsoft]- onlyoffice:- # enable onlyoffice integration- # default: false- enabled: false- # Secret used for jwt tokens, it must be the same on the onlyoffice server- # required- secret: 'onlyOfficeSecret'- # If no external server is configured, the local Nginx service from the Docker Compose setup is used.- # If an external server is configured, it will be used instead.- # Note: when using an external server (e.g.: https://onlyoffice.domain.com), make sure it is accessible from the client/browser.- # default: null- externalServer:- # If you use https, set to `true`.- # default: false- verifySSL: false- collabora:- # enable collabora online integration- # default: false- enabled: false- # If no external server is configured, the local Nginx service from the Docker Compose setup is used.- # If an external server is configured, it will be used instead.- # Note: when using an external server (e.g.: https://collabora.domain.com), make sure it is accessible from the client/browser.- # default: null- externalServer:+ editors:+ onlyoffice:+ # enable onlyoffice integration+ # default: false+ enabled: false+ # Secret used for jwt tokens, it must be the same on the onlyoffice server+ # required+ secret: 'onlyOfficeSecret'+ # If no external server is configured, the local Nginx service from the Docker Compose setup is used.+ # If an external server is configured, it will be used instead.+ # Note: when using an external server (e.g.: https://onlyoffice.domain.com), make sure it is accessible from the client/browser.+ # default: null+ externalServer:+ # If you use https, set to `true`.+ # default: false+ verifySSL: false+ collabora:+ # enable collabora online integration+ # default: false+ enabled: false+ # If no external server is configured, the local Nginx service from the Docker Compose setup is used.+ # If an external server is configured, it will be used instead.+ # Note: when using an external server (e.g.: https://collabora.domain.com), make sure it is accessible from the client/browser.+ # default: null+ externalServer:# Client application repository configurationappStore:# repository: `public` | `local`