You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

routes.php 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Bart Visscher <bartv@thisnet.nl>
  6. * @author Bernhard Posselt <dev@bernhard-posselt.com>
  7. * @author Christoph Wurst <christoph@owncloud.com>
  8. * @author Christopher Schäpers <kondou@ts.unde.re>
  9. * @author Georg Ehrke <oc.list@georgehrke.com>
  10. * @author Joas Schilling <coding@schilljs.com>
  11. * @author John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
  12. * @author Lukas Reschke <lukas@statuscode.ch>
  13. * @author Morris Jobke <hey@morrisjobke.de>
  14. * @author Roeland Jago Douma <roeland@famdouma.nl>
  15. * @author Thomas Müller <thomas.mueller@tmit.eu>
  16. * @author Victor Dubiniuk <dubiniuk@owncloud.com>
  17. * @author Vincent Petry <pvince81@owncloud.com>
  18. *
  19. * @license AGPL-3.0
  20. *
  21. * This code is free software: you can redistribute it and/or modify
  22. * it under the terms of the GNU Affero General Public License, version 3,
  23. * as published by the Free Software Foundation.
  24. *
  25. * This program is distributed in the hope that it will be useful,
  26. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  27. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  28. * GNU Affero General Public License for more details.
  29. *
  30. * You should have received a copy of the GNU Affero General Public License, version 3,
  31. * along with this program. If not, see <http://www.gnu.org/licenses/>
  32. *
  33. */
  34. use OC\Core\Application;
  35. $application = new Application();
  36. $application->registerRoutes($this, [
  37. 'routes' => [
  38. ['name' => 'lost#email', 'url' => '/lostpassword/email', 'verb' => 'POST'],
  39. ['name' => 'lost#resetform', 'url' => '/lostpassword/reset/form/{token}/{userId}', 'verb' => 'GET'],
  40. ['name' => 'lost#setPassword', 'url' => '/lostpassword/set/{token}/{userId}', 'verb' => 'POST'],
  41. ['name' => 'user#getDisplayNames', 'url' => '/displaynames', 'verb' => 'POST'],
  42. ['name' => 'avatar#getAvatar', 'url' => '/avatar/{userId}/{size}', 'verb' => 'GET'],
  43. ['name' => 'avatar#deleteAvatar', 'url' => '/avatar/', 'verb' => 'DELETE'],
  44. ['name' => 'avatar#postCroppedAvatar', 'url' => '/avatar/cropped', 'verb' => 'POST'],
  45. ['name' => 'avatar#getTmpAvatar', 'url' => '/avatar/tmp', 'verb' => 'GET'],
  46. ['name' => 'avatar#postAvatar', 'url' => '/avatar/', 'verb' => 'POST'],
  47. ['name' => 'GuestAvatar#getAvatar', 'url' => '/avatar/guest/{guestName}/{size}', 'verb' => 'GET'],
  48. ['name' => 'CSRFToken#index', 'url' => '/csrftoken', 'verb' => 'GET'],
  49. ['name' => 'login#tryLogin', 'url' => '/login', 'verb' => 'POST'],
  50. ['name' => 'login#confirmPassword', 'url' => '/login/confirm', 'verb' => 'POST'],
  51. ['name' => 'login#showLoginForm', 'url' => '/login', 'verb' => 'GET'],
  52. ['name' => 'login#logout', 'url' => '/logout', 'verb' => 'GET'],
  53. // Original login flow used by all clients
  54. ['name' => 'ClientFlowLogin#showAuthPickerPage', 'url' => '/login/flow', 'verb' => 'GET'],
  55. ['name' => 'ClientFlowLogin#generateAppPassword', 'url' => '/login/flow', 'verb' => 'POST'],
  56. ['name' => 'ClientFlowLogin#grantPage', 'url' => '/login/flow/grant', 'verb' => 'GET'],
  57. ['name' => 'ClientFlowLogin#apptokenRedirect', 'url' => '/login/flow/apptoken', 'verb' => 'POST'],
  58. // NG login flow used by desktop client in case of Kerberos/fancy 2fa (smart cards for example)
  59. ['name' => 'ClientFlowLoginV2#poll', 'url' => '/login/v2/poll', 'verb' => 'POST'],
  60. ['name' => 'ClientFlowLoginV2#showAuthPickerPage', 'url' => '/login/v2/flow', 'verb' => 'GET'],
  61. ['name' => 'ClientFlowLoginV2#landing', 'url' => '/login/v2/flow/{token}', 'verb' => 'GET'],
  62. ['name' => 'ClientFlowLoginV2#grantPage', 'url' => '/login/v2/grant', 'verb' => 'GET'],
  63. ['name' => 'ClientFlowLoginV2#generateAppPassword', 'url' => '/login/v2/grant', 'verb' => 'POST'],
  64. ['name' => 'ClientFlowLoginV2#init', 'url' => '/login/v2', 'verb' => 'POST'],
  65. ['name' => 'TwoFactorChallenge#selectChallenge', 'url' => '/login/selectchallenge', 'verb' => 'GET'],
  66. ['name' => 'TwoFactorChallenge#showChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'GET'],
  67. ['name' => 'TwoFactorChallenge#solveChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'POST'],
  68. ['name' => 'OCJS#getConfig', 'url' => '/core/js/oc.js', 'verb' => 'GET'],
  69. ['name' => 'Preview#getPreviewByFileId', 'url' => '/core/preview', 'verb' => 'GET'],
  70. ['name' => 'Preview#getPreview', 'url' => '/core/preview.png', 'verb' => 'GET'],
  71. ['name' => 'Svg#getSvgFromCore', 'url' => '/svg/core/{folder}/{fileName}', 'verb' => 'GET'],
  72. ['name' => 'Svg#getSvgFromApp', 'url' => '/svg/{app}/{fileName}', 'verb' => 'GET'],
  73. ['name' => 'Css#getCss', 'url' => '/css/{appName}/{fileName}', 'verb' => 'GET'],
  74. ['name' => 'Js#getJs', 'url' => '/js/{appName}/{fileName}', 'verb' => 'GET'],
  75. ['name' => 'contactsMenu#index', 'url' => '/contactsmenu/contacts', 'verb' => 'POST'],
  76. ['name' => 'contactsMenu#findOne', 'url' => '/contactsmenu/findOne', 'verb' => 'POST'],
  77. ['name' => 'WalledGarden#get', 'url' => '/204', 'verb' => 'GET'],
  78. ['name' => 'Search#search', 'url' => '/core/search', 'verb' => 'GET'],
  79. ],
  80. 'ocs' => [
  81. ['root' => '/cloud', 'name' => 'OCS#getCapabilities', 'url' => '/capabilities', 'verb' => 'GET'],
  82. ['root' => '', 'name' => 'OCS#getConfig', 'url' => '/config', 'verb' => 'GET'],
  83. ['root' => '/person', 'name' => 'OCS#personCheck', 'url' => '/check', 'verb' => 'POST'],
  84. ['root' => '/identityproof', 'name' => 'OCS#getIdentityProof', 'url' => '/key/{cloudId}', 'verb' => 'GET'],
  85. ['root' => '/core', 'name' => 'Navigation#getAppsNavigation', 'url' => '/navigation/apps', 'verb' => 'GET'],
  86. ['root' => '/core', 'name' => 'Navigation#getSettingsNavigation', 'url' => '/navigation/settings', 'verb' => 'GET'],
  87. ['root' => '/core', 'name' => 'AutoComplete#get', 'url' => '/autocomplete/get', 'verb' => 'GET'],
  88. ['root' => '/core', 'name' => 'WhatsNew#get', 'url' => '/whatsnew', 'verb' => 'GET'],
  89. ['root' => '/core', 'name' => 'WhatsNew#dismiss', 'url' => '/whatsnew', 'verb' => 'POST'],
  90. ['root' => '/core', 'name' => 'AppPassword#getAppPassword', 'url' => '/getapppassword', 'verb' => 'GET'],
  91. ['root' => '/collaboration', 'name' => 'CollaborationResources#searchCollections', 'url' => '/resources/collections/search/{filter}', 'verb' => 'GET'],
  92. ['root' => '/collaboration', 'name' => 'CollaborationResources#listCollection', 'url' => '/resources/collections/{collectionId}', 'verb' => 'GET'],
  93. ['root' => '/collaboration', 'name' => 'CollaborationResources#renameCollection', 'url' => '/resources/collections/{collectionId}', 'verb' => 'PUT'],
  94. ['root' => '/collaboration', 'name' => 'CollaborationResources#addResource', 'url' => '/resources/collections/{collectionId}', 'verb' => 'POST'],
  95. ['root' => '/collaboration', 'name' => 'CollaborationResources#removeResource', 'url' => '/resources/collections/{collectionId}', 'verb' => 'DELETE'],
  96. ['root' => '/collaboration', 'name' => 'CollaborationResources#getCollectionsByResource', 'url' => '/resources/{resourceType}/{resourceId}', 'verb' => 'GET'],
  97. ['root' => '/collaboration', 'name' => 'CollaborationResources#createCollectionOnResource', 'url' => '/resources/{baseResourceType}/{baseResourceId}', 'verb' => 'POST'],
  98. ],
  99. ]);
  100. // Post installation check
  101. /** @var $this OCP\Route\IRouter */
  102. // Core ajax actions
  103. // Routing
  104. $this->create('core_ajax_update', '/core/ajax/update.php')
  105. ->actionInclude('core/ajax/update.php');
  106. // File routes
  107. $this->create('files.viewcontroller.showFile', '/f/{fileid}')->action(function($urlParams) {
  108. $app = new \OCA\Files\AppInfo\Application($urlParams);
  109. $app->dispatch('ViewController', 'index');
  110. });
  111. // Call routes
  112. /**
  113. * @suppress PhanUndeclaredClassConstant
  114. * @suppress PhanUndeclaredClassMethod
  115. */
  116. $this->create('spreed.pagecontroller.showCall', '/call/{token}')->action(function($urlParams) {
  117. if (class_exists(\OCA\Spreed\AppInfo\Application::class, false)) {
  118. $app = new \OCA\Spreed\AppInfo\Application($urlParams);
  119. $app->dispatch('PageController', 'index');
  120. } else {
  121. throw new \OC\HintException('App spreed is not enabled');
  122. }
  123. });
  124. // OCM routes
  125. /**
  126. * @suppress PhanUndeclaredClassConstant
  127. * @suppress PhanUndeclaredClassMethod
  128. */
  129. $this->create('cloud_federation_api.requesthandlercontroller.addShare', '/ocm/shares')->post()->action(function($urlParams) {
  130. if (class_exists(\OCA\CloudFederationAPI\AppInfo\Application::class, false)) {
  131. $app = new \OCA\CloudFederationAPI\AppInfo\Application($urlParams);
  132. $app->dispatch('RequestHandlerController', 'addShare');
  133. } else {
  134. throw new \OC\HintException('Cloud Federation API not enabled');
  135. }
  136. });
  137. /**
  138. * @suppress PhanUndeclaredClassConstant
  139. * @suppress PhanUndeclaredClassMethod
  140. */
  141. $this->create('cloud_federation_api.requesthandlercontroller.receiveNotification', '/ocm/notifications')->post()->action(function($urlParams) {
  142. if (class_exists(\OCA\CloudFederationAPI\AppInfo\Application::class, false)) {
  143. $app = new \OCA\CloudFederationAPI\AppInfo\Application($urlParams);
  144. $app->dispatch('RequestHandlerController', 'receiveNotification');
  145. } else {
  146. throw new \OC\HintException('Cloud Federation API not enabled');
  147. }
  148. });
  149. // Sharing routes
  150. $this->create('files_sharing.sharecontroller.showShare', '/s/{token}')->action(function($urlParams) {
  151. if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
  152. $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
  153. $app->dispatch('ShareController', 'showShare');
  154. } else {
  155. throw new \OC\HintException('App file sharing is not enabled');
  156. }
  157. });
  158. $this->create('files_sharing.sharecontroller.authenticate', '/s/{token}/authenticate/{redirect}')->post()->action(function($urlParams) {
  159. if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
  160. $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
  161. $app->dispatch('ShareController', 'authenticate');
  162. } else {
  163. throw new \OC\HintException('App file sharing is not enabled');
  164. }
  165. });
  166. $this->create('files_sharing.sharecontroller.showAuthenticate', '/s/{token}/authenticate/{redirect}')->get()->action(function($urlParams) {
  167. if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
  168. $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
  169. $app->dispatch('ShareController', 'showAuthenticate');
  170. } else {
  171. throw new \OC\HintException('App file sharing is not enabled');
  172. }
  173. });
  174. $this->create('files_sharing.sharecontroller.downloadShare', '/s/{token}/download')->get()->action(function($urlParams) {
  175. if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
  176. $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
  177. $app->dispatch('ShareController', 'downloadShare');
  178. } else {
  179. throw new \OC\HintException('App file sharing is not enabled');
  180. }
  181. });
  182. $this->create('files_sharing.publicpreview.directLink', '/s/{token}/preview')->get()->action(function($urlParams) {
  183. if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
  184. $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
  185. $app->dispatch('PublicPreviewController', 'directLink');
  186. } else {
  187. throw new \OC\HintException('App file sharing is not enabled');
  188. }
  189. });