-
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts
index 04b0175a7..96c67fac7 100644
--- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts
+++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts
@@ -258,7 +258,8 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
this.loadConfigAndUpdateForm()
this.loadCategoriesAndLanguages()
- if (!this.serverConfig.allowEdits) {
+
+ if (!this.isUpdateAllowed()) {
this.form.disable()
}
}
@@ -293,6 +294,10 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
})
}
+ isUpdateAllowed () {
+ return this.serverConfig.webadmin.configuration.edition.allowed === true
+ }
+
hasConsistentOptions () {
if (this.hasLiveAllowReplayConsistentOptions()) return true
diff --git a/client/src/app/shared/shared-forms/markdown-textarea.component.html b/client/src/app/shared/shared-forms/markdown-textarea.component.html
index a460cb9b7..7c2a42791 100644
--- a/client/src/app/shared/shared-forms/markdown-textarea.component.html
+++ b/client/src/app/shared/shared-forms/markdown-textarea.component.html
@@ -2,7 +2,7 @@
diff --git a/config/default.yaml b/config/default.yaml
index 99f00a9ec..a8d070cc8 100644
--- a/config/default.yaml
+++ b/config/default.yaml
@@ -258,7 +258,7 @@ peertube:
webadmin:
configuration:
- edit:
+ edition:
# Set this to false if you don't want to allow config edition in the web interface by instance admins
allowed: true
diff --git a/config/production.yaml.example b/config/production.yaml.example
index c3cda52b5..bc9f28e95 100644
--- a/config/production.yaml.example
+++ b/config/production.yaml.example
@@ -256,7 +256,7 @@ peertube:
webadmin:
configuration:
- edit:
+ edition:
# Set this to false if you don't want to allow config edition in the web interface by instance admins
allowed: true
diff --git a/scripts/benchmark.ts b/scripts/benchmark.ts
index 007e3c33b..788318313 100644
--- a/scripts/benchmark.ts
+++ b/scripts/benchmark.ts
@@ -135,7 +135,7 @@ async function run () {
title: 'API - config',
path: '/api/v1/config',
expecter: (body, status) => {
- return status === 200 && body.startsWith('{"allowEdits":')
+ return status === 200 && body.startsWith('{"client":')
}
}
]
diff --git a/server/initializers/config.ts b/server/initializers/config.ts
index a37aae551..48bb5ab8e 100644
--- a/server/initializers/config.ts
+++ b/server/initializers/config.ts
@@ -206,8 +206,8 @@ const CONFIG = {
},
WEBADMIN: {
CONFIGURATION: {
- EDITS: {
- ALLOWED: config.get
('webadmin.configuration.edit.allowed')
+ EDITION: {
+ ALLOWED: config.get('webadmin.configuration.edition.allowed')
}
}
},
@@ -463,7 +463,7 @@ export function reloadConfig () {
function getConfigDirectories () {
if (process.env.NODE_CONFIG_DIR) {
- return process.env.NODE_CONFIG_DIR.split(":")
+ return process.env.NODE_CONFIG_DIR.split(':')
}
return [ join(root(), 'config') ]
diff --git a/server/lib/server-config-manager.ts b/server/lib/server-config-manager.ts
index 58a37b56c..b78251e8c 100644
--- a/server/lib/server-config-manager.ts
+++ b/server/lib/server-config-manager.ts
@@ -42,7 +42,6 @@ class ServerConfigManager {
const defaultTheme = getThemeOrDefault(CONFIG.THEME.DEFAULT, DEFAULT_THEME_NAME)
return {
- allowEdits: CONFIG.WEBADMIN.CONFIGURATION.EDITS.ALLOWED,
client: {
videos: {
miniature: {
@@ -50,6 +49,15 @@ class ServerConfigManager {
}
}
},
+
+ webadmin: {
+ configuration: {
+ edition: {
+ allowed: CONFIG.WEBADMIN.CONFIGURATION.EDITION.ALLOWED
+ }
+ }
+ },
+
instance: {
name: CONFIG.INSTANCE.NAME,
shortDescription: CONFIG.INSTANCE.SHORT_DESCRIPTION,
diff --git a/server/middlewares/validators/config.ts b/server/middlewares/validators/config.ts
index 5f1ac89bc..f0385ab44 100644
--- a/server/middlewares/validators/config.ts
+++ b/server/middlewares/validators/config.ts
@@ -106,12 +106,13 @@ const customConfigUpdateValidator = [
]
function ensureConfigIsEditable (req: express.Request, res: express.Response, next: express.NextFunction) {
- if (!CONFIG.WEBADMIN.CONFIGURATION.EDITS.ALLOWED) {
+ if (!CONFIG.WEBADMIN.CONFIGURATION.EDITION.ALLOWED) {
return res.fail({
status: HttpStatusCode.METHOD_NOT_ALLOWED_405,
message: 'Server configuration is static and cannot be edited'
})
}
+
return next()
}
diff --git a/server/tests/api/server/auto-follows.ts b/server/tests/api/server/auto-follows.ts
index ca6475bd5..90a668edb 100644
--- a/server/tests/api/server/auto-follows.ts
+++ b/server/tests/api/server/auto-follows.ts
@@ -186,6 +186,10 @@ describe('Test auto follows', function () {
await checkFollow(servers[0], servers[1], false)
await checkFollow(servers[0], servers[2], true)
})
+
+ after(async function () {
+ await instanceIndexServer.terminate()
+ })
})
after(async function () {
diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.ts
index 8363318f6..1d996d454 100644
--- a/server/tests/api/server/config.ts
+++ b/server/tests/api/server/config.ts
@@ -379,14 +379,14 @@ describe('Test static config', function () {
before(async function () {
this.timeout(30000)
- server = await createSingleServer(1, { webadmin: { configuration: { edit: { allowed: false } } } })
+ server = await createSingleServer(1, { webadmin: { configuration: { edition: { allowed: false } } } })
await setAccessTokensToServers([ server ])
})
it('Should tell the client that edits are not allowed', async function () {
const data = await server.config.getConfig()
- expect(data.allowEdits).to.be.false
+ expect(data.webadmin.configuration.edition.allowed).to.be.false
})
it('Should error when client tries to update', async function () {
diff --git a/shared/extra-utils/mock-servers/mock-instances-index.ts b/shared/extra-utils/mock-servers/mock-instances-index.ts
index 5baec00de..43c2e9f6e 100644
--- a/shared/extra-utils/mock-servers/mock-instances-index.ts
+++ b/shared/extra-utils/mock-servers/mock-instances-index.ts
@@ -1,7 +1,11 @@
import express from 'express'
+import { Server } from 'http'
import { randomInt } from '@shared/core-utils'
+import { terminateServer } from './utils'
export class MockInstancesIndex {
+ private server: Server
+
private readonly indexInstances: { host: string, createdAt: string }[] = []
initialize () {
@@ -30,11 +34,15 @@ export class MockInstancesIndex {
})
const port = 42000 + randomInt(1, 1000)
- app.listen(port, () => res(port))
+ this.server = app.listen(port, () => res(port))
})
}
addInstance (host: string) {
this.indexInstances.push({ host, createdAt: new Date().toISOString() })
}
+
+ terminate () {
+ return terminateServer(this.server)
+ }
}
diff --git a/shared/models/server/server-config.model.ts b/shared/models/server/server-config.model.ts
index 4bd4b0cb4..5bbb61252 100644
--- a/shared/models/server/server-config.model.ts
+++ b/shared/models/server/server-config.model.ts
@@ -30,7 +30,6 @@ export interface RegisteredIdAndPassAuthConfig {
}
export interface ServerConfig {
- allowEdits: boolean
serverVersion: string
serverCommit?: string
@@ -42,6 +41,14 @@ export interface ServerConfig {
}
}
+ webadmin: {
+ configuration: {
+ edition: {
+ allowed: boolean
+ }
+ }
+ },
+
instance: {
name: string
shortDescription: string
diff --git a/support/docker/production/config/custom-environment-variables.yaml b/support/docker/production/config/custom-environment-variables.yaml
index 7c430a995..c7cd28e65 100644
--- a/support/docker/production/config/custom-environment-variables.yaml
+++ b/support/docker/production/config/custom-environment-variables.yaml
@@ -70,9 +70,9 @@ object_storage:
webadmin:
configuration:
- edit:
- allowed:
- __name: "PEERTUBE_ALLOW_WEBADMIN_CONFIG"
+ edition:
+ allowed:
+ __name: "PEERTUBE_WEBADMIN_CONFIGURATION_EDITION_ALLOWED"
__format: "json"
log: