1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import React from 'react';
import {FormattedMessage, FormattedHTMLMessage} from 'react-intl';
import ErrorStore from 'stores/error_store.jsx';
import {ErrorBarTypes} from 'utils/constants.jsx';
import * as Utils from 'utils/utils.jsx';
import {invalidateAllCaches, reloadConfig} from 'actions/admin_actions.jsx';
import AdminSettings from './admin_settings.jsx';
import BooleanSetting from './boolean_setting.jsx';
import {ConnectionSecurityDropdownSettingWebserver} from './connection_security_dropdown_setting.jsx';
import SettingsGroup from './settings_group.jsx';
import RequestButton from './request_button/request_button';
import TextSetting from './text_setting.jsx';
import WebserverModeDropdownSetting from './webserver_mode_dropdown_setting.jsx';
export default class ConfigurationSettings extends AdminSettings {
constructor(props) {
super(props);
this.getConfigFromState = this.getConfigFromState.bind(this);
this.handleSaved = this.handleSaved.bind(this);
this.renderSettings = this.renderSettings.bind(this);
}
componentWillReceiveProps(nextProps) {
// special case for this page since we don't update AdminSettings components when the
// stored config changes, but we want this page to update when you reload the config
this.setState(this.getStateFromConfig(nextProps.config));
}
getConfigFromState(config) {
config.ServiceSettings.SiteURL = this.state.siteURL;
config.ServiceSettings.ListenAddress = this.state.listenAddress;
config.ServiceSettings.WebserverMode = this.state.webserverMode;
config.ServiceSettings.ConnectionSecurity = this.state.connectionSecurity;
config.ServiceSettings.TLSCertFile = this.state.TLSCertFile;
config.ServiceSettings.TLSKeyFile = this.state.TLSKeyFile;
config.ServiceSettings.UseLetsEncrypt = this.state.useLetsEncrypt;
config.ServiceSettings.LetsEncryptCertificateCacheFile = this.state.letsEncryptCertificateCacheFile;
config.ServiceSettings.Forward80To443 = this.state.forward80To443;
config.ServiceSettings.ReadTimeout = this.parseIntNonZero(this.state.readTimeout);
config.ServiceSettings.WriteTimeout = this.parseIntNonZero(this.state.writeTimeout);
config.ServiceSettings.EnableAPIv3 = this.state.enableAPIv3;
return config;
}
getStateFromConfig(config) {
return {
siteURL: config.ServiceSettings.SiteURL,
listenAddress: config.ServiceSettings.ListenAddress,
webserverMode: config.ServiceSettings.WebserverMode,
connectionSecurity: config.ServiceSettings.ConnectionSecurity,
TLSCertFile: config.ServiceSettings.TLSCertFile,
TLSKeyFile: config.ServiceSettings.TLSKeyFile,
useLetsEncrypt: config.ServiceSettings.UseLetsEncrypt,
letsEncryptCertificateCacheFile: config.ServiceSettings.LetsEncryptCertificateCacheFile,
forward80To443: config.ServiceSettings.Forward80To443,
readTimeout: config.ServiceSettings.ReadTimeout,
writeTimeout: config.ServiceSettings.WriteTimeout,
enableAPIv3: config.ServiceSettings.EnableAPIv3
};
}
handleSaved(newConfig) {
if (newConfig.ServiceSettings.SiteURL) {
ErrorStore.clearError(ErrorBarTypes.SITE_URL);
}
}
renderTitle() {
return (
<FormattedMessage
id='admin.general.configuration'
defaultMessage='Configuration'
/>
);
}
renderSettings() {
const reloadConfigurationHelpText = (
<FormattedMessage
id='admin.reload.reloadDescription'
defaultMessage='Deployments using multiple databases can switch from one master database to another without restarting the Mattermost server by updating "config.json" to the new desired configuration and using the {featureName} feature to load the new settings while the server is running. The administrator should then use the {recycleDatabaseConnections} feature to recycle the database connections based on the new settings.'
values={{
featureName: (
<b>
<FormattedMessage
id='admin.reload.reloadDescription.featureName'
defaultMessage='Reload Configuration from Disk'
/>
</b>
),
recycleDatabaseConnections: (
<a href='../advanced/database'>
<b>
<FormattedMessage
id='admin.reload.reloadDescription.recycleDatabaseConnections'
defaultMessage='Database > Recycle Database Connections'
/>
</b>
</a>
)
}}
/>
);
let reloadConfigButton = <div/>;
if (global.window.mm_license.IsLicensed === 'true') {
reloadConfigButton = (
<RequestButton
requestAction={reloadConfig}
helpText={reloadConfigurationHelpText}
buttonText={
<FormattedMessage
id='admin.reload.button'
defaultMessage='Reload Configuration From Disk'
/>
}
showSuccessMessage={false}
errorMessage={{
id: 'admin.reload.reloadFail',
defaultMessage: 'Reload unsuccessful: {error}'
}}
/>
);
}
return (
<SettingsGroup>
<div className='banner'>
<div className='banner__content'>
<FormattedMessage
id='admin.rate.noteDescription'
defaultMessage='Changing properties other than Site URL in this section will require a server restart before taking effect.'
/>
</div>
</div>
<TextSetting
id='siteURL'
label={
<FormattedMessage
id='admin.service.siteURL'
defaultMessage='Site URL:'
/>
}
placeholder={Utils.localizeMessage('admin.service.siteURLExample', 'Ex "https://mattermost.example.com:1234"')}
helpText={
<FormattedMessage
id='admin.service.siteURLDescription'
defaultMessage='The URL that users will use to access Mattermost. Standard ports, such as 80 and 443, can be omitted, but non-standard ports are required. For example: http://mattermost.example.com:8065. This setting is required.'
/>
}
value={this.state.siteURL}
onChange={this.handleChange}
/>
<TextSetting
id='listenAddress'
label={
<FormattedMessage
id='admin.service.listenAddress'
defaultMessage='Listen Address:'
/>
}
placeholder={Utils.localizeMessage('admin.service.listenExample', 'Ex ":8065"')}
helpText={
<FormattedMessage
id='admin.service.listenDescription'
defaultMessage='The address and port to which to bind and listen. Specifying ":8065" will bind to all network interfaces. Specifying "127.0.0.1:8065" will only bind to the network interface having that IP address. If you choose a port of a lower level (called "system ports" or "well-known ports", in the range of 0-1023), you must have permissions to bind to that port. On Linux you can use: "sudo setcap cap_net_bind_service=+ep ./bin/platform" to allow Mattermost to bind to well-known ports.'
/>
}
value={this.state.listenAddress}
onChange={this.handleChange}
/>
<ConnectionSecurityDropdownSettingWebserver
value={this.state.connectionSecurity}
onChange={this.handleChange}
disabled={false}
/>
<TextSetting
id='TLSCertFile'
label={
<FormattedMessage
id='admin.service.tlsCertFile'
defaultMessage='TLS Certificate File:'
/>
}
helpText={
<FormattedMessage
id='admin.service.tlsCertFileDescription'
defaultMessage='The certificate file to use.'
/>
}
disabled={this.state.useLetsEncrypt}
value={this.state.TLSCertFile}
onChange={this.handleChange}
/>
<TextSetting
id='TLSKeyFile'
label={
<FormattedMessage
id='admin.service.tlsKeyFile'
defaultMessage='TLS Key File:'
/>
}
helpText={
<FormattedMessage
id='admin.service.tlsKeyFileDescription'
defaultMessage='The private key file to use.'
/>
}
disabled={this.state.useLetsEncrypt}
value={this.state.TLSKeyFile}
onChange={this.handleChange}
/>
<BooleanSetting
id='useLetsEncrypt'
label={
<FormattedMessage
id='admin.service.useLetsEncrypt'
defaultMessage="Use Let's Encrypt:"
/>
}
helpText={
<FormattedMessage
id='admin.service.useLetsEncryptDescription'
defaultMessage="Enable the automatic retreval of certificates from the Let's Encrypt. The certificate will be retrieved when a client attempts to connect from a new domain. This will work with multiple domains."
/>
}
value={this.state.useLetsEncrypt}
onChange={this.handleChange}
/>
<TextSetting
id='letsEncryptCertificateCacheFile'
label={
<FormattedMessage
id='admin.service.letsEncryptCertificateCacheFile'
defaultMessage="Let's Encrypt Certificate Cache File:"
/>
}
helpText={
<FormattedMessage
id='admin.service.letsEncryptCertificateCacheFileDescription'
defaultMessage="Certificates retrieved and other data about the Let's Encrypt service will be stored in this file."
/>
}
disabled={!this.state.useLetsEncrypt}
value={this.state.letsEncryptCertificateCacheFile}
onChange={this.handleChange}
/>
<BooleanSetting
id='forward80To443'
label={
<FormattedMessage
id='admin.service.forward80To443'
defaultMessage='Forward port 80 to 443:'
/>
}
helpText={
<FormattedMessage
id='admin.service.forward80To443Description'
defaultMessage='Forwards all insecure traffic from port 80 to secure port 443'
/>
}
value={this.state.forward80To443}
onChange={this.handleChange}
/>
<TextSetting
id='readTimeout'
label={
<FormattedMessage
id='admin.service.readTimeout'
defaultMessage='Read Timeout:'
/>
}
helpText={
<FormattedMessage
id='admin.service.readTimeoutDescription'
defaultMessage='Maximum time allowed from when the connection is accepted to when the request body is fully read.'
/>
}
value={this.state.readTimeout}
onChange={this.handleChange}
/>
<TextSetting
id='writeTimeout'
label={
<FormattedMessage
id='admin.service.writeTimeout'
defaultMessage='Write Timeout:'
/>
}
helpText={
<FormattedMessage
id='admin.service.writeTimeoutDescription'
defaultMessage='If using HTTP (insecure), this is the maximum time allowed from the end of reading the request headers until the response is written. If using HTTPS, it is the total time from when the connection is accepted until the response is written.'
/>
}
value={this.state.writeTimeout}
onChange={this.handleChange}
/>
<BooleanSetting
id='enableAPIv3'
label={
<FormattedMessage
id='admin.service.enableAPIv3'
defaultMessage='Allow use of API v3 endpoints:'
/>
}
helpText={
<FormattedHTMLMessage
id='admin.service.enableAPIv3Description'
defaultMessage='Set to false to disable all version 3 endpoints of the REST API. Integrations that rely on API v3 will fail and can then be identified for migration to API v4. API v3 is deprecated and will be removed in the near future. See <a href="https://api.mattermost.com" target="_blank">https://api.mattermost.com</a> for details.'
/>
}
value={this.state.enableAPIv3}
onChange={this.handleChange}
/>
<WebserverModeDropdownSetting
value={this.state.webserverMode}
onChange={this.handleChange}
disabled={false}
/>
{reloadConfigButton}
<RequestButton
requestAction={invalidateAllCaches}
helpText={
<FormattedMessage
id='admin.purge.purgeDescription'
defaultMessage='This will purge all the in-memory caches for things like sessions, accounts, channels, etc. Deployments using High Availability will attempt to purge all the servers in the cluster. Purging the caches may adversely impact performance.'
/>
}
buttonText={
<FormattedMessage
id='admin.purge.button'
defaultMessage='Purge All Caches'
/>
}
showSuccessMessage={false}
includeDetailedError={true}
errorMessage={{
id: 'admin.purge.purgeFail',
defaultMessage: 'Purging unsuccessful: {error}'
}}
/>
</SettingsGroup>
);
}
}
|