Commit 3b394020 authored by Joram Wilander's avatar Joram Wilander Committed by Harrison Healey

PLT-7633 Add config setting for session idle timeout (#76)

* Add config setting for session idle timeout

* Tweak idle timeout help text (#78)

* Update en.json

* Update session_settings.jsx

* Add minimum and update help text
parent 6f7603fe
......@@ -21,10 +21,6 @@ export default class AdminSettings extends React.Component {
constructor(props) {
super(props);
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
this.doSubmit = this.doSubmit.bind(this);
this.state = Object.assign(this.getStateFromConfig(props.config), {
saveNeeded: false,
saving: false,
......@@ -32,20 +28,20 @@ export default class AdminSettings extends React.Component {
});
}
handleChange(id, value) {
handleChange = (id, value) => {
this.setState({
saveNeeded: true,
[id]: value
});
}
handleSubmit(e) {
handleSubmit = (e) => {
e.preventDefault();
this.doSubmit();
}
doSubmit(callback) {
doSubmit = (callback) => {
this.setState({
saving: true,
serverError: null
......
......@@ -6,10 +6,12 @@ import React from 'react';
import * as Utils from 'utils/utils.jsx';
import AdminSettings from './admin_settings.jsx';
import {FormattedMessage} from 'react-intl';
import {FormattedMessage, FormattedHTMLMessage} from 'react-intl';
import SettingsGroup from './settings_group.jsx';
import TextSetting from './text_setting.jsx';
const MINIMUM_IDLE_TIMEOUT = 5;
export default class SessionSettings extends AdminSettings {
constructor(props) {
super(props);
......@@ -25,6 +27,13 @@ export default class SessionSettings extends AdminSettings {
config.ServiceSettings.SessionLengthSSOInDays = this.parseIntNonZero(this.state.sessionLengthSSOInDays);
config.ServiceSettings.SessionCacheInMinutes = this.parseIntNonZero(this.state.sessionCacheInMinutes);
const timeout = this.parseInt(this.state.sessionIdleTimeoutInMinutes);
if (timeout !== 0 && timeout < MINIMUM_IDLE_TIMEOUT) {
config.ServiceSettings.SessionIdleTimeoutInMinutes = MINIMUM_IDLE_TIMEOUT;
} else {
config.ServiceSettings.SessionIdleTimeoutInMinutes = timeout;
}
return config;
}
......@@ -33,7 +42,8 @@ export default class SessionSettings extends AdminSettings {
sessionLengthWebInDays: config.ServiceSettings.SessionLengthWebInDays,
sessionLengthMobileInDays: config.ServiceSettings.SessionLengthMobileInDays,
sessionLengthSSOInDays: config.ServiceSettings.SessionLengthSSOInDays,
sessionCacheInMinutes: config.ServiceSettings.SessionCacheInMinutes
sessionCacheInMinutes: config.ServiceSettings.SessionCacheInMinutes,
sessionIdleTimeoutInMinutes: config.ServiceSettings.SessionIdleTimeoutInMinutes
};
}
......@@ -47,6 +57,30 @@ export default class SessionSettings extends AdminSettings {
}
renderSettings() {
let idleTimeout;
if (window.mm_license.IsLicensed === 'true' && global.window.mm_license.Compliance === 'true') {
idleTimeout = (
<TextSetting
id='sessionIdleTimeoutInMinutes'
label={
<FormattedMessage
id='admin.service.sessionIdleTimeout'
defaultMessage='Session Idle Timeout (minutes):'
/>
}
placeholder={Utils.localizeMessage('admin.service.sessionIdleTimeoutEx', 'Ex "60"')}
helpText={
<FormattedHTMLMessage
id='admin.service.sessionIdleTimeoutDesc'
defaultMessage="The number of minutes from the last time a user was active on the system to the expiry of the user's session. Once expired, the user will need to log in to continue. Minimum is 5 minutes, and 0 is unlimited.<br/><br/>Applies to the desktop app and browsers. For mobile apps, use an EMM provider to lock the app when not in use. In High Availability mode, enable IP hash load balancing for reliable timeout measurement."
/>
}
value={this.state.sessionIdleTimeoutInMinutes}
onChange={this.handleChange}
/>
);
}
return (
<SettingsGroup>
<TextSetting
......@@ -54,7 +88,7 @@ export default class SessionSettings extends AdminSettings {
label={
<FormattedMessage
id='admin.service.webSessionDays'
defaultMessage='Session length AD/LDAP and email (days):'
defaultMessage='Session Length AD/LDAP and Email (days):'
/>
}
placeholder={Utils.localizeMessage('admin.service.sessionDaysEx', 'Ex "30"')}
......@@ -72,7 +106,7 @@ export default class SessionSettings extends AdminSettings {
label={
<FormattedMessage
id='admin.service.mobileSessionDays'
defaultMessage='Session length mobile (days):'
defaultMessage='Session Length Mobile (days):'
/>
}
placeholder={Utils.localizeMessage('admin.service.sessionDaysEx', 'Ex "30"')}
......@@ -90,7 +124,7 @@ export default class SessionSettings extends AdminSettings {
label={
<FormattedMessage
id='admin.service.ssoSessionDays'
defaultMessage='Session length SSO (days):'
defaultMessage='Session Length SSO (days):'
/>
}
placeholder={Utils.localizeMessage('admin.service.sessionDaysEx', 'Ex "30"')}
......@@ -121,6 +155,7 @@ export default class SessionSettings extends AdminSettings {
value={this.state.sessionCacheInMinutes}
onChange={this.handleChange}
/>
{idleTimeout}
</SettingsGroup>
);
}
......
......@@ -883,7 +883,7 @@
"admin.service.listenExample": "E.g.: \":8065\"",
"admin.service.mfaDesc": "When true, users with AD/LDAP or email login can add multi-factor authentication to their account using Google Authenticator.",
"admin.service.mfaTitle": "Enable Multi-factor Authentication:",
"admin.service.mobileSessionDays": "Session length mobile (days):",
"admin.service.mobileSessionDays": "Session Length Mobile (days):",
"admin.service.mobileSessionDaysDesc": "The number of days from the last time a user entered their credentials to the expiry of the user's session. After changing this setting, the new session length will take effect after the next time the user enters their credentials.",
"admin.service.outWebhooksDesc": "When true, outgoing webhooks will be allowed. See <a href='http://docs.mattermost.com/developer/webhooks-outgoing.html' target='_blank'>documentation</a> to learn more.",
"admin.service.outWebhooksTitle": "Enable Outgoing Webhooks: ",
......@@ -893,13 +893,16 @@
"admin.service.readTimeoutDescription": "Maximum time allowed from when the connection is accepted to when the request body is fully read.",
"admin.service.securityDesc": "When true, System Administrators are notified by email if a relevant security fix alert has been announced in the last 12 hours. Requires email to be enabled.",
"admin.service.securityTitle": "Enable Security Alerts: ",
"admin.service.sessionIdleTimeout": "Session Idle Timeout (minutes):",
"admin.service.sessionIdleTimeoutEx": "Ex \"60\"",
"admin.service.sessionIdleTimeoutDesc": "The number of minutes from the last time a user was active on the system to the expiry of the user's session. Once expired, the user will need to log in to continue. Minimum is 5 minutes, and 0 is unlimited.<br/><br/>Applies to the desktop app and browsers. For mobile apps, use an EMM provider to lock the app when not in use. In High Availability mode, enable IP hash load balancing for reliable timeout measurement.",
"admin.service.sessionCache": "Session Cache (minutes):",
"admin.service.sessionCacheDesc": "The number of minutes to cache a session in memory.",
"admin.service.sessionDaysEx": "E.g.: \"30\"",
"admin.service.siteURL": "Site URL:",
"admin.service.siteURLDescription": "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.",
"admin.service.siteURLExample": "E.g.: \"https://mattermost.example.com:1234\"",
"admin.service.ssoSessionDays": "Session length SSO (days):",
"admin.service.ssoSessionDays": "Session Length SSO (days):",
"admin.service.ssoSessionDaysDesc": "The number of days from the last time a user entered their credentials to the expiry of the user's session. If the authentication method is SAML or GitLab, the user may automatically be logged back in to Mattermost if they are already logged in to SAML or GitLab. After changing this setting, the setting will take effect after the next time the user enters their credentials.",
"admin.service.testingDescription": "When true, /test slash command is enabled to load test accounts, data and text formatting. Changing this requires a server restart before taking effect.",
"admin.service.testingTitle": "Enable Testing Commands: ",
......@@ -913,7 +916,7 @@
"admin.service.userAccessTokensDescription": "When true, users can create <a href=\"https://about.mattermost.com/default-user-access-tokens\" target=\"_blank\">personal access tokens</a> for integrations in <strong>Account Settings > Security</strong>. They can be used to authenticate against the API and give full access to the account.<br/><br/>To manage who can create personal access tokens or to search users by token ID, go to the <strong>System Console > Users</strong> page.",
"admin.service.userAccessTokensIdLabel": "Token ID: ",
"admin.service.userAccessTokensTitle": "Enable Personal Access Tokens: ",
"admin.service.webSessionDays": "Session length AD/LDAP and email (days):",
"admin.service.webSessionDays": "Session Length AD/LDAP and Email (days):",
"admin.service.webSessionDaysDesc": "The number of days from the last time a user entered their credentials to the expiry of the user's session. After changing this setting, the new session length will take effect after the next time the user enters their credentials.",
"admin.service.webhooksDescription": "When true, incoming webhooks will be allowed. To help combat phishing attacks, all posts from webhooks will be labelled by a BOT tag. See <a href='http://docs.mattermost.com/developer/webhooks-incoming.html' target='_blank'>documentation</a> to learn more.",
"admin.service.webhooksTitle": "Enable Incoming Webhooks: ",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment