setupchecks.js 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744
  1. /*
  2. * Copyright (c) 2014
  3. *
  4. * This file is licensed under the Affero General Public License version 3
  5. * or later.
  6. *
  7. * See the COPYING-README file.
  8. *
  9. */
  10. (function() {
  11. OC.SetupChecks = {
  12. /* Message types */
  13. MESSAGE_TYPE_INFO:0,
  14. MESSAGE_TYPE_WARNING:1,
  15. MESSAGE_TYPE_ERROR:2,
  16. /**
  17. * Check whether the WebDAV connection works.
  18. *
  19. * @return $.Deferred object resolved with an array of error messages
  20. */
  21. checkWebDAV: function() {
  22. var deferred = $.Deferred();
  23. var afterCall = function(xhr) {
  24. var messages = [];
  25. if (xhr.status !== 207 && xhr.status !== 401) {
  26. messages.push({
  27. msg: t('core', 'Your web server is not yet properly set up to allow file synchronization, because the WebDAV interface seems to be broken.'),
  28. type: OC.SetupChecks.MESSAGE_TYPE_ERROR
  29. });
  30. }
  31. deferred.resolve(messages);
  32. };
  33. $.ajax({
  34. type: 'PROPFIND',
  35. url: OC.linkToRemoteBase('webdav'),
  36. data: '<?xml version="1.0"?>' +
  37. '<d:propfind xmlns:d="DAV:">' +
  38. '<d:prop><d:resourcetype/></d:prop>' +
  39. '</d:propfind>',
  40. contentType: 'application/xml; charset=utf-8',
  41. complete: afterCall,
  42. allowAuthErrors: true
  43. });
  44. return deferred.promise();
  45. },
  46. /**
  47. * Check whether the .well-known URLs works.
  48. *
  49. * @param url the URL to test
  50. * @param placeholderUrl the placeholder URL - can be found at OC.theme.docPlaceholderUrl
  51. * @param {boolean} runCheck if this is set to false the check is skipped and no error is returned
  52. * @param {int|int[]} expectedStatus the expected HTTP status to be returned by the URL, 207 by default
  53. * @return $.Deferred object resolved with an array of error messages
  54. */
  55. checkWellKnownUrl: function(verb, url, placeholderUrl, runCheck, expectedStatus, checkCustomHeader) {
  56. if (expectedStatus === undefined) {
  57. expectedStatus = [207];
  58. }
  59. if (!Array.isArray(expectedStatus)) {
  60. expectedStatus = [expectedStatus];
  61. }
  62. var deferred = $.Deferred();
  63. if(runCheck === false) {
  64. deferred.resolve([]);
  65. return deferred.promise();
  66. }
  67. var afterCall = function(xhr) {
  68. var messages = [];
  69. var customWellKnown = xhr.getResponseHeader('X-NEXTCLOUD-WELL-KNOWN')
  70. if (expectedStatus.indexOf(xhr.status) === -1 || (checkCustomHeader && !customWellKnown)) {
  71. var docUrl = placeholderUrl.replace('PLACEHOLDER', 'admin-setup-well-known-URL');
  72. messages.push({
  73. msg: t('core', 'Your web server is not properly set up to resolve "{url}". Further information can be found in the {linkstart}documentation ↗{linkend}.', { url: url })
  74. .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + docUrl + '">')
  75. .replace('{linkend}', '</a>'),
  76. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  77. });
  78. }
  79. deferred.resolve(messages);
  80. };
  81. $.ajax({
  82. type: verb,
  83. url: url,
  84. complete: afterCall,
  85. allowAuthErrors: true
  86. });
  87. return deferred.promise();
  88. },
  89. /**
  90. * Check whether the .well-known URLs works.
  91. *
  92. * @param url the URL to test
  93. * @param placeholderUrl the placeholder URL - can be found at OC.theme.docPlaceholderUrl
  94. * @param {boolean} runCheck if this is set to false the check is skipped and no error is returned
  95. *
  96. * @return $.Deferred object resolved with an array of error messages
  97. */
  98. checkProviderUrl: function(url, placeholderUrl, runCheck) {
  99. var expectedStatus = [200];
  100. var deferred = $.Deferred();
  101. if(runCheck === false) {
  102. deferred.resolve([]);
  103. return deferred.promise();
  104. }
  105. var afterCall = function(xhr) {
  106. var messages = [];
  107. if (expectedStatus.indexOf(xhr.status) === -1) {
  108. var docUrl = placeholderUrl.replace('PLACEHOLDER', 'admin-nginx');
  109. messages.push({
  110. msg: t('core', 'Your web server is not properly set up to resolve "{url}". This is most likely related to a web server configuration that was not updated to deliver this folder directly. Please compare your configuration against the shipped rewrite rules in ".htaccess" for Apache or the provided one in the documentation for Nginx at it\'s {linkstart}documentation page ↗{linkend}. On Nginx those are typically the lines starting with "location ~" that need an update.', { docLink: docUrl, url: url })
  111. .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + docUrl + '">')
  112. .replace('{linkend}', '</a>'),
  113. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  114. });
  115. }
  116. deferred.resolve(messages);
  117. };
  118. $.ajax({
  119. type: 'GET',
  120. url: url,
  121. complete: afterCall,
  122. allowAuthErrors: true
  123. });
  124. return deferred.promise();
  125. },
  126. /**
  127. * Check whether the WOFF2 URLs works.
  128. *
  129. * @param url the URL to test
  130. * @param placeholderUrl the placeholder URL - can be found at OC.theme.docPlaceholderUrl
  131. * @return $.Deferred object resolved with an array of error messages
  132. */
  133. checkWOFF2Loading: function(url, placeholderUrl) {
  134. var deferred = $.Deferred();
  135. var afterCall = function(xhr) {
  136. var messages = [];
  137. if (xhr.status !== 200) {
  138. var docUrl = placeholderUrl.replace('PLACEHOLDER', 'admin-nginx');
  139. messages.push({
  140. msg: t('core', 'Your web server is not properly set up to deliver .woff2 files. This is typically an issue with the Nginx configuration. For Nextcloud 15 it needs an adjustement to also deliver .woff2 files. Compare your Nginx configuration to the recommended configuration in our {linkstart}documentation ↗{linkend}.', { docLink: docUrl, url: url })
  141. .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + docUrl + '">')
  142. .replace('{linkend}', '</a>'),
  143. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  144. });
  145. }
  146. deferred.resolve(messages);
  147. };
  148. $.ajax({
  149. type: 'GET',
  150. url: url,
  151. complete: afterCall,
  152. allowAuthErrors: true
  153. });
  154. return deferred.promise();
  155. },
  156. /**
  157. * Runs setup checks on the server side
  158. *
  159. * @return $.Deferred object resolved with an array of error messages
  160. */
  161. checkSetup: function() {
  162. var deferred = $.Deferred();
  163. var afterCall = function(data, statusText, xhr) {
  164. var messages = [];
  165. if (xhr.status === 200 && data) {
  166. if (!data.isGetenvServerWorking) {
  167. messages.push({
  168. msg: t('core', 'PHP does not seem to be setup properly to query system environment variables. The test with getenv("PATH") only returns an empty response.') + ' ' +
  169. t('core', 'Please check the {linkstart}installation documentation ↗{linkend} for PHP configuration notes and the PHP configuration of your server, especially when using php-fpm.')
  170. .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + OC.theme.docPlaceholderUrl.replace('PLACEHOLDER', 'admin-php-fpm') + '">')
  171. .replace('{linkend}', '</a>'),
  172. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  173. });
  174. }
  175. if (data.isReadOnlyConfig) {
  176. messages.push({
  177. msg: t('core', 'The read-only config has been enabled. This prevents setting some configurations via the web-interface. Furthermore, the file needs to be made writable manually for every update.'),
  178. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  179. });
  180. }
  181. if (!data.wasEmailTestSuccessful) {
  182. messages.push({
  183. msg: t('core', 'You have not set or verified your email server configuration, yet. Please head over to the {mailSettingsStart}Basic settings{mailSettingsEnd} in order to set them. Afterwards, use the "Send email" button below the form to verify your settings.',)
  184. .replace('{mailSettingsStart}', '<a href="' + OC.generateUrl('/settings/admin') + '">')
  185. .replace('{mailSettingsEnd}', '</a>'),
  186. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  187. });
  188. }
  189. if (!data.hasValidTransactionIsolationLevel) {
  190. messages.push({
  191. msg: t('core', 'Your database does not run with "READ COMMITTED" transaction isolation level. This can cause problems when multiple actions are executed in parallel.'),
  192. type: OC.SetupChecks.MESSAGE_TYPE_ERROR
  193. });
  194. }
  195. if(!data.hasFileinfoInstalled) {
  196. messages.push({
  197. msg: t('core', 'The PHP module "fileinfo" is missing. It is strongly recommended to enable this module to get the best results with MIME type detection.'),
  198. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  199. });
  200. }
  201. if(!data.hasWorkingFileLocking) {
  202. messages.push({
  203. msg: t('core', 'Transactional file locking is disabled, this might lead to issues with race conditions. Enable "filelocking.enabled" in config.php to avoid these problems. See the {linkstart}documentation ↗{linkend} for more information.')
  204. .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + OC.theme.docPlaceholderUrl.replace('PLACEHOLDER', 'admin-transactional-locking') + '">')
  205. .replace('{linkend}', '</a>'),
  206. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  207. });
  208. }
  209. if (data.suggestedOverwriteCliURL !== '') {
  210. messages.push({
  211. msg: t('core', 'Please make sure to set the "overwrite.cli.url" option in your config.php file to the URL that your users mainly use to access this Nextcloud. Suggestion: "{suggestedOverwriteCliURL}". Otherwise there might be problems with the URL generation via cron. (It is possible though that the suggested URL is not the URL that your users mainly use to access this Nextcloud. Best is to double check this in any case.)', {suggestedOverwriteCliURL: data.suggestedOverwriteCliURL}),
  212. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  213. });
  214. }
  215. if (!data.isDefaultPhoneRegionSet) {
  216. messages.push({
  217. msg: t('core', 'Your installation has no default phone region set. This is required to validate phone numbers in the profile settings without a country code. To allow numbers without a country code, please add "default_phone_region" with the respective {linkstart}ISO 3166-1 code ↗{linkend} of the region to your config file.')
  218. .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements">')
  219. .replace('{linkend}', '</a>'),
  220. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  221. });
  222. }
  223. if (data.cronErrors.length > 0) {
  224. var listOfCronErrors = "";
  225. data.cronErrors.forEach(function(element){
  226. listOfCronErrors += '<li>';
  227. listOfCronErrors += element.error;
  228. listOfCronErrors += ' ';
  229. listOfCronErrors += element.hint;
  230. listOfCronErrors += '</li>';
  231. });
  232. messages.push({
  233. msg: t('core', 'It was not possible to execute the cron job via CLI. The following technical errors have appeared:') + '<ul>' + listOfCronErrors + '</ul>',
  234. type: OC.SetupChecks.MESSAGE_TYPE_ERROR
  235. })
  236. }
  237. if (data.cronInfo.diffInSeconds > 3600) {
  238. messages.push({
  239. msg: t('core', 'Last background job execution ran {relativeTime}. Something seems wrong. {linkstart}Check the background job settings ↗{linkend}.', {relativeTime: data.cronInfo.relativeTime})
  240. .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + data.cronInfo.backgroundJobsUrl + '">')
  241. .replace('{linkend}', '</a>'),
  242. type: OC.SetupChecks.MESSAGE_TYPE_ERROR
  243. });
  244. }
  245. if (!data.isFairUseOfFreePushService) {
  246. messages.push({
  247. msg: t('core', 'This is the unsupported community build of Nextcloud. Given the size of this instance, performance, reliability and scalability cannot be guaranteed. Push notifications are limited to avoid overloading our free service. Learn more about the benefits of Nextcloud Enterprise at {linkstart}https://nextcloud.com/enterprise{linkend}.')
  248. .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="https://nextcloud.com/enterprise">')
  249. .replace('{linkend}', '</a>'),
  250. type: OC.SetupChecks.MESSAGE_TYPE_ERROR
  251. });
  252. }
  253. if (data.serverHasInternetConnectionProblems) {
  254. messages.push({
  255. msg: t('core', 'This server has no working internet connection: Multiple endpoints could not be reached. This means that some of the features like mounting external storage, notifications about updates or installation of third-party apps will not work. Accessing files remotely and sending of notification emails might not work, either. Establish a connection from this server to the internet to enjoy all features.'),
  256. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  257. });
  258. }
  259. if(!data.isMemcacheConfigured) {
  260. messages.push({
  261. msg: t('core', 'No memory cache has been configured. To enhance performance, please configure a memcache, if available. Further information can be found in the {linkstart}documentation ↗{linkend}.')
  262. .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + data.memcacheDocs + '">')
  263. .replace('{linkend}', '</a>'),
  264. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  265. });
  266. }
  267. if(!data.isRandomnessSecure) {
  268. messages.push({
  269. msg: t('core', 'No suitable source for randomness found by PHP which is highly discouraged for security reasons. Further information can be found in the {linkstart}documentation ↗{linkend}.')
  270. .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + data.securityDocs + '">')
  271. .replace('{linkend}', '</a>'),
  272. type: OC.SetupChecks.MESSAGE_TYPE_ERROR
  273. });
  274. }
  275. if(data.isUsedTlsLibOutdated) {
  276. messages.push({
  277. msg: data.isUsedTlsLibOutdated,
  278. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  279. });
  280. }
  281. if (data.phpSupported && data.phpSupported.eol) {
  282. messages.push({
  283. msg: t('core', 'You are currently running PHP {version}. Upgrade your PHP version to take advantage of {linkstart}performance and security updates provided by the PHP Group ↗{linkend} as soon as your distribution supports it.', { version: data.phpSupported.version })
  284. .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="https://secure.php.net/supported-versions.php">')
  285. .replace('{linkend}', '</a>'),
  286. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  287. })
  288. }
  289. if (data.phpSupported && data.phpSupported.version.substr(0, 3) === '7.3') {
  290. messages.push({
  291. msg: t('core', 'Nextcloud 23 is the last release supporting PHP 7.3. Nextcloud 24 requires at least PHP 7.4.'),
  292. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  293. })
  294. }
  295. if(!data.forwardedForHeadersWorking) {
  296. messages.push({
  297. msg: t('core', 'The reverse proxy header configuration is incorrect, or you are accessing Nextcloud from a trusted proxy. If not, this is a security issue and can allow an attacker to spoof their IP address as visible to the Nextcloud. Further information can be found in the {linkstart}documentation ↗{linkend}.')
  298. .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + data.reverseProxyDocs + '">')
  299. .replace('{linkend}', '</a>'),
  300. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  301. });
  302. }
  303. if(!data.isCorrectMemcachedPHPModuleInstalled) {
  304. messages.push({
  305. msg: t('core', 'Memcached is configured as distributed cache, but the wrong PHP module "memcache" is installed. \\OC\\Memcache\\Memcached only supports "memcached" and not "memcache". See the {linkstart}memcached wiki about both modules ↗{linkend}.')
  306. .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="https://code.google.com/p/memcached/wiki/PHPClientComparison">')
  307. .replace('{linkend}', '</a>'),
  308. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  309. });
  310. }
  311. if(!data.hasPassedCodeIntegrityCheck) {
  312. messages.push({
  313. msg: t('core', 'Some files have not passed the integrity check. Further information on how to resolve this issue can be found in the {linkstart1}documentation ↗{linkend}. ({linkstart2}List of invalid files…{linkend} / {linkstart3}Rescan…{linkend})')
  314. .replace('{linkstart1}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + data.codeIntegrityCheckerDocumentation + '">')
  315. .replace('{linkstart2}', '<a href="' + OC.generateUrl('/settings/integrity/failed') + '">')
  316. .replace('{linkstart3}', '<a href="' + OC.generateUrl('/settings/integrity/rescan?requesttoken={requesttoken}', {'requesttoken': OC.requestToken}) + '">')
  317. .replace(/{linkend}/g, '</a>'),
  318. type: OC.SetupChecks.MESSAGE_TYPE_ERROR
  319. });
  320. }
  321. if(data.OpcacheSetupRecommendations.length > 0) {
  322. var listOfOPcacheRecommendations = "";
  323. data.OpcacheSetupRecommendations.forEach(function(element){
  324. listOfOPcacheRecommendations += '<li>' + element + '</li>';
  325. });
  326. messages.push({
  327. msg: t('core', 'The PHP OPcache module is not properly configured. See the {linkstart}documentation ↗{linkend} for more information.')
  328. .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + OC.theme.docPlaceholderUrl.replace('PLACEHOLDER', 'admin-php-opcache') + '">')
  329. .replace('{linkend}', '</a>') + '<ul>' + listOfOPcacheRecommendations + '</ul>',
  330. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  331. });
  332. }
  333. if(!data.isSettimelimitAvailable) {
  334. messages.push({
  335. msg: t('core', 'The PHP function "set_time_limit" is not available. This could result in scripts being halted mid-execution, breaking your installation. Enabling this function is strongly recommended.'),
  336. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  337. });
  338. }
  339. if (!data.hasFreeTypeSupport) {
  340. messages.push({
  341. msg: t('core', 'Your PHP does not have FreeType support, resulting in breakage of profile pictures and the settings interface.'),
  342. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  343. })
  344. }
  345. if (data.missingIndexes.length > 0) {
  346. var listOfMissingIndexes = "";
  347. data.missingIndexes.forEach(function(element){
  348. listOfMissingIndexes += '<li>';
  349. listOfMissingIndexes += t('core', 'Missing index "{indexName}" in table "{tableName}".', element);
  350. listOfMissingIndexes += '</li>';
  351. });
  352. messages.push({
  353. msg: t('core', 'The database is missing some indexes. Due to the fact that adding indexes on big tables could take some time they were not added automatically. By running "occ db:add-missing-indices" those missing indexes could be added manually while the instance keeps running. Once the indexes are added queries to those tables are usually much faster.') + '<ul>' + listOfMissingIndexes + '</ul>',
  354. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  355. })
  356. }
  357. if (data.missingPrimaryKeys.length > 0) {
  358. var listOfMissingPrimaryKeys = "";
  359. data.missingPrimaryKeys.forEach(function(element){
  360. listOfMissingPrimaryKeys += '<li>';
  361. listOfMissingPrimaryKeys += t('core', 'Missing primary key on table "{tableName}".', element);
  362. listOfMissingPrimaryKeys += '</li>';
  363. });
  364. messages.push({
  365. msg: t('core', 'The database is missing some primary keys. Due to the fact that adding primary keys on big tables could take some time they were not added automatically. By running "occ db:add-missing-primary-keys" those missing primary keys could be added manually while the instance keeps running.') + '<ul>' + listOfMissingPrimaryKeys + '</ul>',
  366. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  367. })
  368. }
  369. if (data.missingColumns.length > 0) {
  370. var listOfMissingColumns = "";
  371. data.missingColumns.forEach(function(element){
  372. listOfMissingColumns += '<li>';
  373. listOfMissingColumns += t('core', 'Missing optional column "{columnName}" in table "{tableName}".', element);
  374. listOfMissingColumns += '</li>';
  375. });
  376. messages.push({
  377. msg: t('core', 'The database is missing some optional columns. Due to the fact that adding columns on big tables could take some time they were not added automatically when they can be optional. By running "occ db:add-missing-columns" those missing columns could be added manually while the instance keeps running. Once the columns are added some features might improve responsiveness or usability.') + '<ul>' + listOfMissingColumns + '</ul>',
  378. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  379. })
  380. }
  381. if (data.recommendedPHPModules.length > 0) {
  382. var listOfRecommendedPHPModules = "";
  383. data.recommendedPHPModules.forEach(function(element){
  384. listOfRecommendedPHPModules += '<li>' + element + '</li>';
  385. });
  386. messages.push({
  387. msg: t('core', 'This instance is missing some recommended PHP modules. For improved performance and better compatibility it is highly recommended to install them.') + '<ul><code>' + listOfRecommendedPHPModules + '</code></ul>',
  388. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  389. })
  390. }
  391. if (!data.isImagickEnabled) {
  392. messages.push({
  393. msg: t(
  394. 'core',
  395. 'The PHP module "imagick" is not enabled although the theming app is. For favicon generation to work correctly, you need to install and enable this module.'
  396. ),
  397. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  398. })
  399. }
  400. if (!data.areWebauthnExtensionsEnabled) {
  401. messages.push({
  402. msg: t(
  403. 'core',
  404. 'The PHP modules "gmp" and/or "bcmath" are not enabled. If you use WebAuthn passwordless authentication, these modules are required.'
  405. ),
  406. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  407. })
  408. }
  409. if (!data.is64bit) {
  410. messages.push({
  411. msg: t(
  412. 'core',
  413. 'It seems like you are running a 32-bit PHP version. Nextcloud 26 and higher require 64-bit. Please upgrade your OS and PHP to 64-bit! For further details read {linkstart}the documentation page ↗{linkend} about this.'
  414. .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + OC.theme.docPlaceholderUrl.replace('PLACEHOLDER', 'admin-system-requirements') + '">')
  415. .replace('{linkend}', '</a>'),
  416. ),
  417. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  418. })
  419. }
  420. if (data.imageMagickLacksSVGSupport) {
  421. messages.push({
  422. msg: t('core', 'Module php-imagick in this instance has no SVG support. For better compatibility it is recommended to install it.'),
  423. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  424. })
  425. }
  426. if (data.pendingBigIntConversionColumns.length > 0) {
  427. var listOfPendingBigIntConversionColumns = "";
  428. data.pendingBigIntConversionColumns.forEach(function(element){
  429. listOfPendingBigIntConversionColumns += '<li>' + element + '</li>';
  430. });
  431. messages.push({
  432. msg: t('core', 'Some columns in the database are missing a conversion to big int. Due to the fact that changing column types on big tables could take some time they were not changed automatically. By running "occ db:convert-filecache-bigint" those pending changes could be applied manually. This operation needs to be made while the instance is offline. For further details read {linkstart}the documentation page about this ↗{linkend}.')
  433. .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + OC.theme.docPlaceholderUrl.replace('PLACEHOLDER', 'admin-bigint-conversion') + '">')
  434. .replace('{linkend}', '</a>') + '<ul>' + listOfPendingBigIntConversionColumns + '</ul>',
  435. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  436. })
  437. }
  438. if (data.isSqliteUsed) {
  439. messages.push({
  440. msg: t('core', 'SQLite is currently being used as the backend database. For larger installations we recommend that you switch to a different database backend.') + ' ' + t('core', 'This is particularly recommended when using the desktop client for file synchronisation.') + ' ' +
  441. t('core', 'To migrate to another database use the command line tool: "occ db:convert-type", or see the {linkstart}documentation ↗{linkend}.')
  442. .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + data.databaseConversionDocumentation + '">')
  443. .replace('{linkend}', '</a>'),
  444. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  445. })
  446. }
  447. if (!data.isMemoryLimitSufficient) {
  448. messages.push({
  449. msg: t('core', 'The PHP memory limit is below the recommended value of 512MB.'),
  450. type: OC.SetupChecks.MESSAGE_TYPE_ERROR
  451. })
  452. }
  453. if(data.appDirsWithDifferentOwner && data.appDirsWithDifferentOwner.length > 0) {
  454. var appDirsWithDifferentOwner = data.appDirsWithDifferentOwner.reduce(
  455. function(appDirsWithDifferentOwner, directory) {
  456. return appDirsWithDifferentOwner + '<li>' + directory + '</li>';
  457. },
  458. ''
  459. );
  460. messages.push({
  461. msg: t('core', 'Some app directories are owned by a different user than the web server one. ' +
  462. 'This may be the case if apps have been installed manually. ' +
  463. 'Check the permissions of the following app directories:')
  464. + '<ul>' + appDirsWithDifferentOwner + '</ul>',
  465. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  466. });
  467. }
  468. if (data.isMysqlUsedWithoutUTF8MB4) {
  469. messages.push({
  470. msg: t('core', 'MySQL is used as database but does not support 4-byte characters. To be able to handle 4-byte characters (like emojis) without issues in filenames or comments for example it is recommended to enable the 4-byte support in MySQL. For further details read {linkstart}the documentation page about this ↗{linkend}.')
  471. .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + OC.theme.docPlaceholderUrl.replace('PLACEHOLDER', 'admin-mysql-utf8mb4') + '">')
  472. .replace('{linkend}', '</a>'),
  473. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  474. })
  475. }
  476. if (!data.isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed) {
  477. messages.push({
  478. msg: t('core', 'This instance uses an S3 based object store as primary storage. The uploaded files are stored temporarily on the server and thus it is recommended to have 50 GB of free space available in the temp directory of PHP. Check the logs for full details about the path and the available space. To improve this please change the temporary directory in the php.ini or make more space available in that path.'),
  479. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  480. })
  481. }
  482. if (!data.temporaryDirectoryWritable) {
  483. messages.push({
  484. msg: t('core', 'The temporary directory of this instance points to an either non-existing or non-writable directory.'),
  485. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  486. })
  487. }
  488. if (window.location.protocol === 'https:' && data.reverseProxyGeneratedURL.split('/')[0] !== 'https:') {
  489. messages.push({
  490. msg: t('core', 'You are accessing your instance over a secure connection, however your instance is generating insecure URLs. This most likely means that you are behind a reverse proxy and the overwrite config variables are not set correctly. Please read {linkstart}the documentation page about this ↗{linkend}.')
  491. .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + data.reverseProxyDocs + '">')
  492. .replace('{linkend}', '</a>'),
  493. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  494. })
  495. }
  496. OC.SetupChecks.addGenericSetupCheck(data, 'OCA\\Settings\\SetupChecks\\PhpDefaultCharset', messages)
  497. OC.SetupChecks.addGenericSetupCheck(data, 'OCA\\Settings\\SetupChecks\\PhpOutputBuffering', messages)
  498. OC.SetupChecks.addGenericSetupCheck(data, 'OCA\\Settings\\SetupChecks\\LegacySSEKeyFormat', messages)
  499. OC.SetupChecks.addGenericSetupCheck(data, 'OCA\\Settings\\SetupChecks\\CheckUserCertificates', messages)
  500. OC.SetupChecks.addGenericSetupCheck(data, 'OCA\\Settings\\SetupChecks\\SupportedDatabase', messages)
  501. OC.SetupChecks.addGenericSetupCheck(data, 'OCA\\Settings\\SetupChecks\\LdapInvalidUuids', messages)
  502. } else {
  503. messages.push({
  504. msg: t('core', 'Error occurred while checking server setup'),
  505. type: OC.SetupChecks.MESSAGE_TYPE_ERROR
  506. });
  507. }
  508. deferred.resolve(messages);
  509. };
  510. $.ajax({
  511. type: 'GET',
  512. url: OC.generateUrl('settings/ajax/checksetup'),
  513. allowAuthErrors: true
  514. }).then(afterCall, afterCall);
  515. return deferred.promise();
  516. },
  517. addGenericSetupCheck: function(data, check, messages) {
  518. var setupCheck = data[check] || { pass: true, description: '', severity: 'info', linkToDocumentation: null}
  519. var type = OC.SetupChecks.MESSAGE_TYPE_INFO
  520. if (setupCheck.severity === 'warning') {
  521. type = OC.SetupChecks.MESSAGE_TYPE_WARNING
  522. } else if (setupCheck.severity === 'error') {
  523. type = OC.SetupChecks.MESSAGE_TYPE_ERROR
  524. }
  525. var message = setupCheck.description;
  526. if (setupCheck.linkToDocumentation) {
  527. message += ' ' + t('core', 'For more details see the {linkstart}documentation ↗{linkend}.')
  528. .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + setupCheck.linkToDocumentation + '">')
  529. .replace('{linkend}', '</a>');
  530. }
  531. if (setupCheck.elements) {
  532. message += '<br><ul>'
  533. setupCheck.elements.forEach(function(element){
  534. message += '<li>';
  535. message += element
  536. message += '</li>';
  537. });
  538. message += '</ul>'
  539. }
  540. if (!setupCheck.pass) {
  541. messages.push({
  542. msg: message,
  543. type: type,
  544. })
  545. }
  546. },
  547. /**
  548. * Runs generic checks on the server side, the difference to dedicated
  549. * methods is that we use the same XHR object for all checks to save
  550. * requests.
  551. *
  552. * @return $.Deferred object resolved with an array of error messages
  553. */
  554. checkGeneric: function() {
  555. var self = this;
  556. var deferred = $.Deferred();
  557. var afterCall = function(data, statusText, xhr) {
  558. var messages = [];
  559. messages = messages.concat(self._checkSecurityHeaders(xhr));
  560. messages = messages.concat(self._checkSSL(xhr));
  561. deferred.resolve(messages);
  562. };
  563. $.ajax({
  564. type: 'GET',
  565. url: OC.generateUrl('heartbeat'),
  566. allowAuthErrors: true
  567. }).then(afterCall, afterCall);
  568. return deferred.promise();
  569. },
  570. checkDataProtected: function() {
  571. var deferred = $.Deferred();
  572. if(oc_dataURL === false){
  573. return deferred.resolve([]);
  574. }
  575. var afterCall = function(xhr) {
  576. var messages = [];
  577. // .ocdata is an empty file in the data directory - if this is readable then the data dir is not protected
  578. if (xhr.status === 200 && xhr.responseText === '') {
  579. messages.push({
  580. msg: t('core', 'Your data directory and files are probably accessible from the internet. The .htaccess file is not working. It is strongly recommended that you configure your web server so that the data directory is no longer accessible, or move the data directory outside the web server document root.'),
  581. type: OC.SetupChecks.MESSAGE_TYPE_ERROR
  582. });
  583. }
  584. deferred.resolve(messages);
  585. };
  586. $.ajax({
  587. type: 'GET',
  588. url: OC.linkTo('', oc_dataURL+'/.ocdata?t=' + (new Date()).getTime()),
  589. complete: afterCall,
  590. allowAuthErrors: true
  591. });
  592. return deferred.promise();
  593. },
  594. /**
  595. * Runs check for some generic security headers on the server side
  596. *
  597. * @param {Object} xhr
  598. * @return {Array} Array with error messages
  599. */
  600. _checkSecurityHeaders: function(xhr) {
  601. var messages = [];
  602. if (xhr.status === 200) {
  603. var securityHeaders = {
  604. 'X-Content-Type-Options': ['nosniff'],
  605. 'X-Robots-Tag': ['none'],
  606. 'X-Frame-Options': ['SAMEORIGIN', 'DENY'],
  607. 'X-Permitted-Cross-Domain-Policies': ['none'],
  608. };
  609. for (var header in securityHeaders) {
  610. var option = securityHeaders[header][0];
  611. if(!xhr.getResponseHeader(header) || xhr.getResponseHeader(header).toLowerCase() !== option.toLowerCase()) {
  612. var msg = t('core', 'The "{header}" HTTP header is not set to "{expected}". This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.', {header: header, expected: option});
  613. if(xhr.getResponseHeader(header) && securityHeaders[header].length > 1 && xhr.getResponseHeader(header).toLowerCase() === securityHeaders[header][1].toLowerCase()) {
  614. msg = t('core', 'The "{header}" HTTP header is not set to "{expected}". Some features might not work correctly, as it is recommended to adjust this setting accordingly.', {header: header, expected: option});
  615. }
  616. messages.push({
  617. msg: msg,
  618. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  619. });
  620. }
  621. }
  622. var xssfields = xhr.getResponseHeader('X-XSS-Protection') ? xhr.getResponseHeader('X-XSS-Protection').split(';').map(function(item) { return item.trim(); }) : [];
  623. if (xssfields.length === 0 || xssfields.indexOf('1') === -1 || xssfields.indexOf('mode=block') === -1) {
  624. messages.push({
  625. msg: t('core', 'The "{header}" HTTP header does not contain "{expected}". This is a potential security or privacy risk, as it is recommended to adjust this setting accordingly.',
  626. {
  627. header: 'X-XSS-Protection',
  628. expected: '1; mode=block'
  629. }),
  630. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  631. });
  632. }
  633. const referrerPolicy = xhr.getResponseHeader('Referrer-Policy')
  634. if (referrerPolicy === null || !/(no-referrer(-when-downgrade)?|strict-origin(-when-cross-origin)?|same-origin)(,|$)/.test(referrerPolicy)) {
  635. messages.push({
  636. msg: t('core', 'The "{header}" HTTP header is not set to "{val1}", "{val2}", "{val3}", "{val4}" or "{val5}". This can leak referer information. See the {linkstart}W3C Recommendation ↗{linkend}.',
  637. {
  638. header: 'Referrer-Policy',
  639. val1: 'no-referrer',
  640. val2: 'no-referrer-when-downgrade',
  641. val3: 'strict-origin',
  642. val4: 'strict-origin-when-cross-origin',
  643. val5: 'same-origin'
  644. })
  645. .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="https://www.w3.org/TR/referrer-policy/">')
  646. .replace('{linkend}', '</a>'),
  647. type: OC.SetupChecks.MESSAGE_TYPE_INFO
  648. })
  649. }
  650. } else {
  651. messages.push({
  652. msg: t('core', 'Error occurred while checking server setup'),
  653. type: OC.SetupChecks.MESSAGE_TYPE_ERROR
  654. });
  655. }
  656. return messages;
  657. },
  658. /**
  659. * Runs check for some SSL configuration issues on the server side
  660. *
  661. * @param {Object} xhr
  662. * @return {Array} Array with error messages
  663. */
  664. _checkSSL: function(xhr) {
  665. var messages = [];
  666. if (xhr.status === 200) {
  667. var tipsUrl = OC.theme.docPlaceholderUrl.replace('PLACEHOLDER', 'admin-security');
  668. if(OC.getProtocol() === 'https') {
  669. // Extract the value of 'Strict-Transport-Security'
  670. var transportSecurityValidity = xhr.getResponseHeader('Strict-Transport-Security');
  671. if(transportSecurityValidity !== null && transportSecurityValidity.length > 8) {
  672. var firstComma = transportSecurityValidity.indexOf(";");
  673. if(firstComma !== -1) {
  674. transportSecurityValidity = transportSecurityValidity.substring(8, firstComma);
  675. } else {
  676. transportSecurityValidity = transportSecurityValidity.substring(8);
  677. }
  678. }
  679. var minimumSeconds = 15552000;
  680. if(isNaN(transportSecurityValidity) || transportSecurityValidity <= (minimumSeconds - 1)) {
  681. messages.push({
  682. msg: t('core', 'The "Strict-Transport-Security" HTTP header is not set to at least "{seconds}" seconds. For enhanced security, it is recommended to enable HSTS as described in the {linkstart}security tips ↗{linkend}.', {'seconds': minimumSeconds})
  683. .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + tipsUrl + '">')
  684. .replace('{linkend}', '</a>'),
  685. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  686. });
  687. }
  688. } else {
  689. messages.push({
  690. msg: t('core', 'Accessing site insecurely via HTTP. You are strongly advised to set up your server to require HTTPS instead, as described in the {linkstart}security tips ↗{linkend}.')
  691. .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + tipsUrl + '">')
  692. .replace('{linkend}', '</a>'),
  693. type: OC.SetupChecks.MESSAGE_TYPE_WARNING
  694. });
  695. }
  696. } else {
  697. messages.push({
  698. msg: t('core', 'Error occurred while checking server setup'),
  699. type: OC.SetupChecks.MESSAGE_TYPE_ERROR
  700. });
  701. }
  702. return messages;
  703. }
  704. };
  705. })();