From ae63384dfb7ef19a412caef03276d07a349e35ea Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Mon, 7 Dec 2020 22:20:49 -0100 Subject: [PATCH] event on some .well-known/ request Signed-off-by: Maxence Lange --- lib/composer/composer/autoload_classmap.php | 7 + lib/composer/composer/autoload_static.php | 41 ++-- .../NotManagedWellKnownRequestException.php | 67 ++++++ .../Exceptions/WellKnownRequestException.php | 67 ++++++ lib/private/WellKnown/Model/WellKnown.php | 207 ++++++++++++++++++ lib/private/WellKnown/WellKnownManager.php | 121 ++++++++++ lib/public/WellKnown/Event/WellKnownEvent.php | 69 ++++++ lib/public/WellKnown/IWellKnownManager.php | 55 +++++ lib/public/WellKnown/Model/IWellKnown.php | 121 ++++++++++ public.php | 30 ++- 10 files changed, 754 insertions(+), 31 deletions(-) create mode 100644 lib/private/WellKnown/Exceptions/NotManagedWellKnownRequestException.php create mode 100644 lib/private/WellKnown/Exceptions/WellKnownRequestException.php create mode 100644 lib/private/WellKnown/Model/WellKnown.php create mode 100644 lib/private/WellKnown/WellKnownManager.php create mode 100644 lib/public/WellKnown/Event/WellKnownEvent.php create mode 100644 lib/public/WellKnown/IWellKnownManager.php create mode 100644 lib/public/WellKnown/Model/IWellKnown.php diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 0400e68109056..f433b8c9dbd7d 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -536,6 +536,8 @@ 'OCP\\User\\Events\\UserLoggedOutEvent' => $baseDir . '/lib/public/User/Events/UserLoggedOutEvent.php', 'OCP\\User\\GetQuotaEvent' => $baseDir . '/lib/public/User/GetQuotaEvent.php', 'OCP\\Util' => $baseDir . '/lib/public/Util.php', + 'OCP\\WellKnown\\IWellKnownManager' => $baseDir . '/lib/public/WellKnown/IWellKnownManager.php', + 'OCP\\WellKnown\\Model\\IWellKnown' => $baseDir . '/lib/public/WellKnown/Model/IWellKnown.php', 'OCP\\WorkflowEngine\\EntityContext\\IContextPortation' => $baseDir . '/lib/public/WorkflowEngine/EntityContext/IContextPortation.php', 'OCP\\WorkflowEngine\\EntityContext\\IDisplayName' => $baseDir . '/lib/public/WorkflowEngine/EntityContext/IDisplayName.php', 'OCP\\WorkflowEngine\\EntityContext\\IDisplayText' => $baseDir . '/lib/public/WorkflowEngine/EntityContext/IDisplayText.php', @@ -1383,6 +1385,11 @@ 'OC\\User\\NoUserException' => $baseDir . '/lib/private/User/NoUserException.php', 'OC\\User\\Session' => $baseDir . '/lib/private/User/Session.php', 'OC\\User\\User' => $baseDir . '/lib/private/User/User.php', + 'OC\\WellKnown\\Event\\WellKnownEvent' => $baseDir . '/lib/private/WellKnown/Event/WellKnownEvent.php', + 'OC\\WellKnown\\Exceptions\\NotManagedWellKnownRequestException' => $baseDir . '/lib/private/WellKnown/Exceptions/NotManagedWellKnownRequestException.php', + 'OC\\WellKnown\\Exceptions\\WellKnownRequestException' => $baseDir . '/lib/private/WellKnown/Exceptions/WellKnownRequestException.php', + 'OC\\WellKnown\\Model\\WellKnown' => $baseDir . '/lib/private/WellKnown/Model/WellKnown.php', + 'OC\\WellKnown\\WellKnownManager' => $baseDir . '/lib/private/WellKnown/WellKnownManager.php', 'OC_API' => $baseDir . '/lib/private/legacy/OC_API.php', 'OC_App' => $baseDir . '/lib/private/legacy/OC_App.php', 'OC_DB' => $baseDir . '/lib/private/legacy/OC_DB.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index b9b4f2f307b8c..df2f7a980706b 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -7,7 +7,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c { public static $prefixLengthsPsr4 = array ( - 'O' => + 'O' => array ( 'OC\\Core\\' => 8, 'OC\\' => 3, @@ -16,15 +16,15 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c ); public static $prefixDirsPsr4 = array ( - 'OC\\Core\\' => + 'OC\\Core\\' => array ( 0 => __DIR__ . '/../../..' . '/core', ), - 'OC\\' => + 'OC\\' => array ( 0 => __DIR__ . '/../../..' . '/lib/private', ), - 'OCP\\' => + 'OCP\\' => array ( 0 => __DIR__ . '/../../..' . '/lib/public', ), @@ -41,7 +41,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OCP\\Accounts\\IAccountManager' => __DIR__ . '/../../..' . '/lib/public/Accounts/IAccountManager.php', 'OCP\\Accounts\\IAccountProperty' => __DIR__ . '/../../..' . '/lib/public/Accounts/IAccountProperty.php', 'OCP\\Accounts\\PropertyDoesNotExistException' => __DIR__ . '/../../..' . '/lib/public/Accounts/PropertyDoesNotExistException.php', - 'OCP\\Activity\\ActivitySettings' => __DIR__ . '/../../..' . '/lib/public/Activity/ActivitySettings.php', 'OCP\\Activity\\IConsumer' => __DIR__ . '/../../..' . '/lib/public/Activity/IConsumer.php', 'OCP\\Activity\\IEvent' => __DIR__ . '/../../..' . '/lib/public/Activity/IEvent.php', 'OCP\\Activity\\IEventMerger' => __DIR__ . '/../../..' . '/lib/public/Activity/IEventMerger.php', @@ -93,7 +92,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OCP\\AppFramework\\Http\\Template\\LinkMenuAction' => __DIR__ . '/../../..' . '/lib/public/AppFramework/Http/Template/LinkMenuAction.php', 'OCP\\AppFramework\\Http\\Template\\PublicTemplateResponse' => __DIR__ . '/../../..' . '/lib/public/AppFramework/Http/Template/PublicTemplateResponse.php', 'OCP\\AppFramework\\Http\\Template\\SimpleMenuAction' => __DIR__ . '/../../..' . '/lib/public/AppFramework/Http/Template/SimpleMenuAction.php', - 'OCP\\AppFramework\\Http\\TooManyRequestsResponse' => __DIR__ . '/../../..' . '/lib/public/AppFramework/Http/TooManyRequestsResponse.php', 'OCP\\AppFramework\\Http\\ZipResponse' => __DIR__ . '/../../..' . '/lib/public/AppFramework/Http/ZipResponse.php', 'OCP\\AppFramework\\IAppContainer' => __DIR__ . '/../../..' . '/lib/public/AppFramework/IAppContainer.php', 'OCP\\AppFramework\\Middleware' => __DIR__ . '/../../..' . '/lib/public/AppFramework/Middleware.php', @@ -132,7 +130,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OCP\\Authentication\\TwoFactorAuth\\IRegistry' => __DIR__ . '/../../..' . '/lib/public/Authentication/TwoFactorAuth/IRegistry.php', 'OCP\\Authentication\\TwoFactorAuth\\RegistryEvent' => __DIR__ . '/../../..' . '/lib/public/Authentication/TwoFactorAuth/RegistryEvent.php', 'OCP\\Authentication\\TwoFactorAuth\\TwoFactorException' => __DIR__ . '/../../..' . '/lib/public/Authentication/TwoFactorAuth/TwoFactorException.php', - 'OCP\\Authentication\\TwoFactorAuth\\TwoFactorProviderDisabled' => __DIR__ . '/../../..' . '/lib/public/Authentication/TwoFactorAuth/TwoFactorProviderDisabled.php', 'OCP\\AutoloadNotAllowedException' => __DIR__ . '/../../..' . '/lib/public/AutoloadNotAllowedException.php', 'OCP\\BackgroundJob' => __DIR__ . '/../../..' . '/lib/public/BackgroundJob.php', 'OCP\\BackgroundJob\\IJob' => __DIR__ . '/../../..' . '/lib/public/BackgroundJob/IJob.php', @@ -202,13 +199,13 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OCP\\Dashboard\\IDashboardManager' => __DIR__ . '/../../..' . '/lib/public/Dashboard/IDashboardManager.php', 'OCP\\Dashboard\\IDashboardWidget' => __DIR__ . '/../../..' . '/lib/public/Dashboard/IDashboardWidget.php', 'OCP\\Dashboard\\IManager' => __DIR__ . '/../../..' . '/lib/public/Dashboard/IManager.php', - 'OCP\\Dashboard\\IWidget' => __DIR__ . '/../../..' . '/lib/public/Dashboard/IWidget.php', + 'OCP\\Dashboard\\IPanel' => __DIR__ . '/../../..' . '/lib/public/Dashboard/IPanel.php', 'OCP\\Dashboard\\Model\\IWidgetConfig' => __DIR__ . '/../../..' . '/lib/public/Dashboard/Model/IWidgetConfig.php', 'OCP\\Dashboard\\Model\\IWidgetRequest' => __DIR__ . '/../../..' . '/lib/public/Dashboard/Model/IWidgetRequest.php', 'OCP\\Dashboard\\Model\\WidgetSetting' => __DIR__ . '/../../..' . '/lib/public/Dashboard/Model/WidgetSetting.php', 'OCP\\Dashboard\\Model\\WidgetSetup' => __DIR__ . '/../../..' . '/lib/public/Dashboard/Model/WidgetSetup.php', 'OCP\\Dashboard\\Model\\WidgetTemplate' => __DIR__ . '/../../..' . '/lib/public/Dashboard/Model/WidgetTemplate.php', - 'OCP\\Dashboard\\RegisterWidgetEvent' => __DIR__ . '/../../..' . '/lib/public/Dashboard/RegisterWidgetEvent.php', + 'OCP\\Dashboard\\RegisterPanelEvent' => __DIR__ . '/../../..' . '/lib/public/Dashboard/RegisterPanelEvent.php', 'OCP\\Dashboard\\Service\\IEventsService' => __DIR__ . '/../../..' . '/lib/public/Dashboard/Service/IEventsService.php', 'OCP\\Dashboard\\Service\\IWidgetsService' => __DIR__ . '/../../..' . '/lib/public/Dashboard/Service/IWidgetsService.php', 'OCP\\Defaults' => __DIR__ . '/../../..' . '/lib/public/Defaults.php', @@ -265,7 +262,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OCP\\Files\\Config\\IHomeMountProvider' => __DIR__ . '/../../..' . '/lib/public/Files/Config/IHomeMountProvider.php', 'OCP\\Files\\Config\\IMountProvider' => __DIR__ . '/../../..' . '/lib/public/Files/Config/IMountProvider.php', 'OCP\\Files\\Config\\IMountProviderCollection' => __DIR__ . '/../../..' . '/lib/public/Files/Config/IMountProviderCollection.php', - 'OCP\\Files\\Config\\IRootMountProvider' => __DIR__ . '/../../..' . '/lib/public/Files/Config/IRootMountProvider.php', 'OCP\\Files\\Config\\IUserMountCache' => __DIR__ . '/../../..' . '/lib/public/Files/Config/IUserMountCache.php', 'OCP\\Files\\EmptyFileNameException' => __DIR__ . '/../../..' . '/lib/public/Files/EmptyFileNameException.php', 'OCP\\Files\\EntityTooLargeException' => __DIR__ . '/../../..' . '/lib/public/Files/EntityTooLargeException.php', @@ -477,14 +473,13 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OCP\\Route\\IRouter' => __DIR__ . '/../../..' . '/lib/public/Route/IRouter.php', 'OCP\\SabrePluginEvent' => __DIR__ . '/../../..' . '/lib/public/SabrePluginEvent.php', 'OCP\\SabrePluginException' => __DIR__ . '/../../..' . '/lib/public/SabrePluginException.php', + 'OCP\\Search\\ASearchResultEntry' => __DIR__ . '/../../..' . '/lib/public/Search/ASearchResultEntry.php', 'OCP\\Search\\IProvider' => __DIR__ . '/../../..' . '/lib/public/Search/IProvider.php', 'OCP\\Search\\ISearchQuery' => __DIR__ . '/../../..' . '/lib/public/Search/ISearchQuery.php', 'OCP\\Search\\PagedProvider' => __DIR__ . '/../../..' . '/lib/public/Search/PagedProvider.php', 'OCP\\Search\\Provider' => __DIR__ . '/../../..' . '/lib/public/Search/Provider.php', 'OCP\\Search\\Result' => __DIR__ . '/../../..' . '/lib/public/Search/Result.php', 'OCP\\Search\\SearchResult' => __DIR__ . '/../../..' . '/lib/public/Search/SearchResult.php', - 'OCP\\Search\\SearchResultEntry' => __DIR__ . '/../../..' . '/lib/public/Search/SearchResultEntry.php', - 'OCP\\Security\\Bruteforce\\MaxDelayReached' => __DIR__ . '/../../..' . '/lib/public/Security/Bruteforce/MaxDelayReached.php', 'OCP\\Security\\CSP\\AddContentSecurityPolicyEvent' => __DIR__ . '/../../..' . '/lib/public/Security/CSP/AddContentSecurityPolicyEvent.php', 'OCP\\Security\\Events\\GenerateSecurePasswordEvent' => __DIR__ . '/../../..' . '/lib/public/Security/Events/GenerateSecurePasswordEvent.php', 'OCP\\Security\\Events\\ValidatePasswordPolicyEvent' => __DIR__ . '/../../..' . '/lib/public/Security/Events/ValidatePasswordPolicyEvent.php', @@ -533,9 +528,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OCP\\Template' => __DIR__ . '/../../..' . '/lib/public/Template.php', 'OCP\\User' => __DIR__ . '/../../..' . '/lib/public/User.php', 'OCP\\UserInterface' => __DIR__ . '/../../..' . '/lib/public/UserInterface.php', - 'OCP\\UserStatus\\IManager' => __DIR__ . '/../../..' . '/lib/public/UserStatus/IManager.php', - 'OCP\\UserStatus\\IProvider' => __DIR__ . '/../../..' . '/lib/public/UserStatus/IProvider.php', - 'OCP\\UserStatus\\IUserStatus' => __DIR__ . '/../../..' . '/lib/public/UserStatus/IUserStatus.php', 'OCP\\User\\Backend\\ABackend' => __DIR__ . '/../../..' . '/lib/public/User/Backend/ABackend.php', 'OCP\\User\\Backend\\ICheckPasswordBackend' => __DIR__ . '/../../..' . '/lib/public/User/Backend/ICheckPasswordBackend.php', 'OCP\\User\\Backend\\ICountUsersBackend' => __DIR__ . '/../../..' . '/lib/public/User/Backend/ICountUsersBackend.php', @@ -559,13 +551,12 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OCP\\User\\Events\\UserChangedEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/UserChangedEvent.php', 'OCP\\User\\Events\\UserCreatedEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/UserCreatedEvent.php', 'OCP\\User\\Events\\UserDeletedEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/UserDeletedEvent.php', - 'OCP\\User\\Events\\UserLiveStatusEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/UserLiveStatusEvent.php', 'OCP\\User\\Events\\UserLoggedInEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/UserLoggedInEvent.php', 'OCP\\User\\Events\\UserLoggedInWithCookieEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/UserLoggedInWithCookieEvent.php', 'OCP\\User\\Events\\UserLoggedOutEvent' => __DIR__ . '/../../..' . '/lib/public/User/Events/UserLoggedOutEvent.php', - 'OCP\\User\\GetQuotaEvent' => __DIR__ . '/../../..' . '/lib/public/User/GetQuotaEvent.php', 'OCP\\Util' => __DIR__ . '/../../..' . '/lib/public/Util.php', - 'OCP\\WorkflowEngine\\EntityContext\\IContextPortation' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/EntityContext/IContextPortation.php', + 'OCP\\WellKnown\\IWellKnownManager' => __DIR__ . '/../../..' . '/lib/public/WellKnown/IWellKnownManager.php', + 'OCP\\WellKnown\\Model\\IWellKnown' => __DIR__ . '/../../..' . '/lib/public/WellKnown/Model/IWellKnown.php', 'OCP\\WorkflowEngine\\EntityContext\\IDisplayName' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/EntityContext/IDisplayName.php', 'OCP\\WorkflowEngine\\EntityContext\\IDisplayText' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/EntityContext/IDisplayText.php', 'OCP\\WorkflowEngine\\EntityContext\\IIcon' => __DIR__ . '/../../..' . '/lib/public/WorkflowEngine/EntityContext/IIcon.php', @@ -591,7 +582,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\Accounts\\AccountManager' => __DIR__ . '/../../..' . '/lib/private/Accounts/AccountManager.php', 'OC\\Accounts\\AccountProperty' => __DIR__ . '/../../..' . '/lib/private/Accounts/AccountProperty.php', 'OC\\Accounts\\Hooks' => __DIR__ . '/../../..' . '/lib/private/Accounts/Hooks.php', - 'OC\\Activity\\ActivitySettingsAdapter' => __DIR__ . '/../../..' . '/lib/private/Activity/ActivitySettingsAdapter.php', 'OC\\Activity\\Event' => __DIR__ . '/../../..' . '/lib/private/Activity/Event.php', 'OC\\Activity\\EventMerger' => __DIR__ . '/../../..' . '/lib/private/Activity/EventMerger.php', 'OC\\Activity\\Manager' => __DIR__ . '/../../..' . '/lib/private/Activity/Manager.php', @@ -700,7 +690,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\Authentication\\Listeners\\RemoteWipeNotificationsListener' => __DIR__ . '/../../..' . '/lib/private/Authentication/Listeners/RemoteWipeNotificationsListener.php', 'OC\\Authentication\\Listeners\\UserDeletedStoreCleanupListener' => __DIR__ . '/../../..' . '/lib/private/Authentication/Listeners/UserDeletedStoreCleanupListener.php', 'OC\\Authentication\\Listeners\\UserDeletedTokenCleanupListener' => __DIR__ . '/../../..' . '/lib/private/Authentication/Listeners/UserDeletedTokenCleanupListener.php', - 'OC\\Authentication\\Listeners\\UserLoggedInListener' => __DIR__ . '/../../..' . '/lib/private/Authentication/Listeners/UserLoggedInListener.php', 'OC\\Authentication\\LoginCredentials\\Credentials' => __DIR__ . '/../../..' . '/lib/private/Authentication/LoginCredentials/Credentials.php', 'OC\\Authentication\\LoginCredentials\\Store' => __DIR__ . '/../../..' . '/lib/private/Authentication/LoginCredentials/Store.php', 'OC\\Authentication\\Login\\ALoginCommand' => __DIR__ . '/../../..' . '/lib/private/Authentication/Login/ALoginCommand.php', @@ -846,7 +835,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\Core\\Command\\Encryption\\Enable' => __DIR__ . '/../../..' . '/core/Command/Encryption/Enable.php', 'OC\\Core\\Command\\Encryption\\EncryptAll' => __DIR__ . '/../../..' . '/core/Command/Encryption/EncryptAll.php', 'OC\\Core\\Command\\Encryption\\ListModules' => __DIR__ . '/../../..' . '/core/Command/Encryption/ListModules.php', - 'OC\\Core\\Command\\Encryption\\MigrateKeyStorage' => __DIR__ . '/../../..' . '/core/Command/Encryption/MigrateKeyStorage.php', 'OC\\Core\\Command\\Encryption\\SetDefaultModule' => __DIR__ . '/../../..' . '/core/Command/Encryption/SetDefaultModule.php', 'OC\\Core\\Command\\Encryption\\ShowKeyStorageRoot' => __DIR__ . '/../../..' . '/core/Command/Encryption/ShowKeyStorageRoot.php', 'OC\\Core\\Command\\Encryption\\Status' => __DIR__ . '/../../..' . '/core/Command/Encryption/Status.php', @@ -872,7 +860,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\Core\\Command\\Maintenance\\Repair' => __DIR__ . '/../../..' . '/core/Command/Maintenance/Repair.php', 'OC\\Core\\Command\\Maintenance\\UpdateHtaccess' => __DIR__ . '/../../..' . '/core/Command/Maintenance/UpdateHtaccess.php', 'OC\\Core\\Command\\Maintenance\\UpdateTheme' => __DIR__ . '/../../..' . '/core/Command/Maintenance/UpdateTheme.php', - 'OC\\Core\\Command\\Preview\\Repair' => __DIR__ . '/../../..' . '/core/Command/Preview/Repair.php', 'OC\\Core\\Command\\Security\\ImportCertificate' => __DIR__ . '/../../..' . '/core/Command/Security/ImportCertificate.php', 'OC\\Core\\Command\\Security\\ListCertificates' => __DIR__ . '/../../..' . '/core/Command/Security/ListCertificates.php', 'OC\\Core\\Command\\Security\\RemoveCertificate' => __DIR__ . '/../../..' . '/core/Command/Security/RemoveCertificate.php', @@ -1053,7 +1040,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\Files\\Cache\\HomePropagator' => __DIR__ . '/../../..' . '/lib/private/Files/Cache/HomePropagator.php', 'OC\\Files\\Cache\\LocalRootScanner' => __DIR__ . '/../../..' . '/lib/private/Files/Cache/LocalRootScanner.php', 'OC\\Files\\Cache\\MoveFromCacheTrait' => __DIR__ . '/../../..' . '/lib/private/Files/Cache/MoveFromCacheTrait.php', - 'OC\\Files\\Cache\\NullWatcher' => __DIR__ . '/../../..' . '/lib/private/Files/Cache/NullWatcher.php', 'OC\\Files\\Cache\\Propagator' => __DIR__ . '/../../..' . '/lib/private/Files/Cache/Propagator.php', 'OC\\Files\\Cache\\QuerySearchHelper' => __DIR__ . '/../../..' . '/lib/private/Files/Cache/QuerySearchHelper.php', 'OC\\Files\\Cache\\Scanner' => __DIR__ . '/../../..' . '/lib/private/Files/Cache/Scanner.php', @@ -1079,7 +1065,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\Files\\Mount\\MountPoint' => __DIR__ . '/../../..' . '/lib/private/Files/Mount/MountPoint.php', 'OC\\Files\\Mount\\MoveableMount' => __DIR__ . '/../../..' . '/lib/private/Files/Mount/MoveableMount.php', 'OC\\Files\\Mount\\ObjectHomeMountProvider' => __DIR__ . '/../../..' . '/lib/private/Files/Mount/ObjectHomeMountProvider.php', - 'OC\\Files\\Mount\\ObjectStorePreviewCacheMountProvider' => __DIR__ . '/../../..' . '/lib/private/Files/Mount/ObjectStorePreviewCacheMountProvider.php', 'OC\\Files\\Node\\File' => __DIR__ . '/../../..' . '/lib/private/Files/Node/File.php', 'OC\\Files\\Node\\Folder' => __DIR__ . '/../../..' . '/lib/private/Files/Node/Folder.php', 'OC\\Files\\Node\\HookConnector' => __DIR__ . '/../../..' . '/lib/private/Files/Node/HookConnector.php', @@ -1091,7 +1076,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\Files\\Node\\Root' => __DIR__ . '/../../..' . '/lib/private/Files/Node/Root.php', 'OC\\Files\\Notify\\Change' => __DIR__ . '/../../..' . '/lib/private/Files/Notify/Change.php', 'OC\\Files\\Notify\\RenameChange' => __DIR__ . '/../../..' . '/lib/private/Files/Notify/RenameChange.php', - 'OC\\Files\\ObjectStore\\AppdataPreviewObjectStoreStorage' => __DIR__ . '/../../..' . '/lib/private/Files/ObjectStore/AppdataPreviewObjectStoreStorage.php', 'OC\\Files\\ObjectStore\\Azure' => __DIR__ . '/../../..' . '/lib/private/Files/ObjectStore/Azure.php', 'OC\\Files\\ObjectStore\\HomeObjectStoreStorage' => __DIR__ . '/../../..' . '/lib/private/Files/ObjectStore/HomeObjectStoreStorage.php', 'OC\\Files\\ObjectStore\\Mapper' => __DIR__ . '/../../..' . '/lib/private/Files/ObjectStore/Mapper.php', @@ -1368,7 +1352,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\Share20\\ProviderFactory' => __DIR__ . '/../../..' . '/lib/private/Share20/ProviderFactory.php', 'OC\\Share20\\Share' => __DIR__ . '/../../..' . '/lib/private/Share20/Share.php', 'OC\\Share20\\ShareHelper' => __DIR__ . '/../../..' . '/lib/private/Share20/ShareHelper.php', - 'OC\\Share20\\UserRemovedListener' => __DIR__ . '/../../..' . '/lib/private/Share20/UserRemovedListener.php', 'OC\\Share\\Constants' => __DIR__ . '/../../..' . '/lib/private/Share/Constants.php', 'OC\\Share\\Helper' => __DIR__ . '/../../..' . '/lib/private/Share/Helper.php', 'OC\\Share\\SearchResultSorter' => __DIR__ . '/../../..' . '/lib/private/Share/SearchResultSorter.php', @@ -1404,7 +1387,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\Updater\\ChangesMapper' => __DIR__ . '/../../..' . '/lib/private/Updater/ChangesMapper.php', 'OC\\Updater\\ChangesResult' => __DIR__ . '/../../..' . '/lib/private/Updater/ChangesResult.php', 'OC\\Updater\\VersionCheck' => __DIR__ . '/../../..' . '/lib/private/Updater/VersionCheck.php', - 'OC\\UserStatus\\Manager' => __DIR__ . '/../../..' . '/lib/private/UserStatus/Manager.php', 'OC\\User\\Backend' => __DIR__ . '/../../..' . '/lib/private/User/Backend.php', 'OC\\User\\Database' => __DIR__ . '/../../..' . '/lib/private/User/Database.php', 'OC\\User\\LoginException' => __DIR__ . '/../../..' . '/lib/private/User/LoginException.php', @@ -1412,6 +1394,11 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\User\\NoUserException' => __DIR__ . '/../../..' . '/lib/private/User/NoUserException.php', 'OC\\User\\Session' => __DIR__ . '/../../..' . '/lib/private/User/Session.php', 'OC\\User\\User' => __DIR__ . '/../../..' . '/lib/private/User/User.php', + 'OC\\WellKnown\\Event\\WellKnownEvent' => __DIR__ . '/../../..' . '/lib/private/WellKnown/Event/WellKnownEvent.php', + 'OC\\WellKnown\\Exceptions\\NotManagedWellKnownRequestException' => __DIR__ . '/../../..' . '/lib/private/WellKnown/Exceptions/NotManagedWellKnownRequestException.php', + 'OC\\WellKnown\\Exceptions\\WellKnownRequestException' => __DIR__ . '/../../..' . '/lib/private/WellKnown/Exceptions/WellKnownRequestException.php', + 'OC\\WellKnown\\Model\\WellKnown' => __DIR__ . '/../../..' . '/lib/private/WellKnown/Model/WellKnown.php', + 'OC\\WellKnown\\WellKnownManager' => __DIR__ . '/../../..' . '/lib/private/WellKnown/WellKnownManager.php', 'OC_API' => __DIR__ . '/../../..' . '/lib/private/legacy/OC_API.php', 'OC_App' => __DIR__ . '/../../..' . '/lib/private/legacy/OC_App.php', 'OC_DB' => __DIR__ . '/../../..' . '/lib/private/legacy/OC_DB.php', diff --git a/lib/private/WellKnown/Exceptions/NotManagedWellKnownRequestException.php b/lib/private/WellKnown/Exceptions/NotManagedWellKnownRequestException.php new file mode 100644 index 0000000000000..4feeb46833caf --- /dev/null +++ b/lib/private/WellKnown/Exceptions/NotManagedWellKnownRequestException.php @@ -0,0 +1,67 @@ + + * + * @author Maxence Lange + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + + +namespace OC\WellKnown\Exceptions; + +use Exception; +use Throwable; + +/** + * Class NotManagedWellKnownRequestException + * + * @package OC\WellKnown\Exceptions + * @since 21.0.0 + */ +class NotManagedWellKnownRequestException extends Exception { + + + /** @var int */ + private $errorCode; + + + /** + * WellKnownRequestException constructor. + * + * @param int $errorCode + * @param string $message + * @param int $code + * @param Throwable|null $previous + */ + public function __construct($errorCode = 404, $message = "", $code = 0, Throwable $previous = null) { + parent::__construct($message, $code, $previous); + $this->errorCode = $errorCode; + } + + + /** + * @return int + * @since 21.0.0 + */ + public function getErrorCode(): int { + return $this->errorCode; + } +} diff --git a/lib/private/WellKnown/Exceptions/WellKnownRequestException.php b/lib/private/WellKnown/Exceptions/WellKnownRequestException.php new file mode 100644 index 0000000000000..bbe73f73bd887 --- /dev/null +++ b/lib/private/WellKnown/Exceptions/WellKnownRequestException.php @@ -0,0 +1,67 @@ + + * + * @author Maxence Lange + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + + +namespace OC\WellKnown\Exceptions; + +use Exception; +use Throwable; + +/** + * Class WellKnownRequestException + * + * @package OC\WellKnown\Exceptions + * @since 21.0.0 + */ +class WellKnownRequestException extends Exception { + + + /** @var int */ + private $errorCode; + + + /** + * WellKnownRequestException constructor. + * + * @param int $errorCode + * @param string $message + * @param int $code + * @param Throwable|null $previous + */ + public function __construct($errorCode = 404, $message = "", $code = 0, Throwable $previous = null) { + parent::__construct($message, $code, $previous); + $this->errorCode = $errorCode; + } + + + /** + * @return int + * @since 21.0.0 + */ + public function getErrorCode(): int { + return $this->errorCode; + } +} diff --git a/lib/private/WellKnown/Model/WellKnown.php b/lib/private/WellKnown/Model/WellKnown.php new file mode 100644 index 0000000000000..ddf19c41bb5d9 --- /dev/null +++ b/lib/private/WellKnown/Model/WellKnown.php @@ -0,0 +1,207 @@ + + * + * @author Maxence Lange + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + + +namespace OC\WellKnown\Model; + +use JsonSerializable; +use OCP\IRequest; +use OCP\WellKnown\Model\IWellKnown; + +/** + * @since 21.0.0 + * + * @package OC\WellKnown\Model + */ +final class WellKnown implements IWellKnown, JsonSerializable { + + + /** @var string */ + private $service; + + /** @var IRequest */ + private $request; + + /** @var string */ + private $subject = ''; + + /** @var array */ + private $aliases = []; + + /** @var array */ + private $properties = []; + + /** @var array */ + private $rels = []; + + /** @var array */ + private $links = []; + + + /** + * WellKnown constructor. + * + * @param string $service + * @param IRequest $request + * + * @since 21.0.0 + */ + public function __construct(string $service, IRequest $request) { + $this->request = $request; + $this->service = $service; + $this->subject = $request->getParam('resource', ''); + } + + + /** + * @return string + * @since 21.0.0 + */ + public function getService(): string { + return $this->service; + } + + + /** + * @return IRequest + * @since 21.0.0 + */ + public function getRequest(): IRequest { + return $this->request; + } + + + /** + * @return string + * @since 21.0.0 + */ + public function getSubject(): string { + return $this->subject; + } + + + /** + * @return array + * @since 21.0.0 + */ + public function getRels(): array { + return $this->rels; + } + + + /** + * @param string $alias + * + * @return $this + * @since 21.0.0 + */ + public function addAlias(string $alias): IWellKnown { + if (!in_array($alias, $this->aliases)) { + $this->aliases[] = $alias; + } + + return $this; + } + + /** + * @return array + * @since 21.0.0 + */ + public function getAliases(): array { + return $this->aliases; + } + + + /** + * @param string $property + * @param $value + * + * @return IWellKnown + * @since 21.0.0 + */ + public function addProperty(string $property, $value): IWellKnown { + $this->properties[$property] = $value; + + return $this; + } + + /** + * @return array + * @since 21.0.0 + */ + public function getProperties(): array { + return $this->properties; + } + + + /** + * @param array $arr + * + * @return IWellKnown + * @since 21.0.0 + */ + public function addLink(array $arr): IWellKnown { + $this->links[] = $arr; + + return $this; + } + + /** + * @param JsonSerializable $object + * + * @return IWellKnown + * @since 21.0.0 + */ + public function addLinkSerialized(JsonSerializable $object): IWellKnown { + $this->links[] = $object; + + return $this; + } + + /** + * @return array + * @since 21.0.0 + */ + public function getLinks(): array { + return $this->links; + } + + + /** + * @return array + * @since 21.0.0 + */ + public function jsonSerialize(): array { + $data = [ + 'subject' => $this->getSubject(), + 'properties' => $this->getProperties(), + 'aliases' => $this->getAliases(), + 'links' => $this->getLinks() + ]; + + return array_filter($data); + } +} diff --git a/lib/private/WellKnown/WellKnownManager.php b/lib/private/WellKnown/WellKnownManager.php new file mode 100644 index 0000000000000..d3f2a7cd13180 --- /dev/null +++ b/lib/private/WellKnown/WellKnownManager.php @@ -0,0 +1,121 @@ + + * + * @author Maxence Lange + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + + +namespace OC\WellKnown; + +use OC\WellKnown\Exceptions\NotManagedWellKnownRequestException; +use OC\WellKnown\Exceptions\WellKnownRequestException; +use OC\WellKnown\Model\WellKnown; +use OCP\EventDispatcher\IEventDispatcher; +use OCP\IRequest; +use OCP\WellKnown\Event\WellKnownEvent; +use OCP\WellKnown\IWellKnownManager; +use OCP\WellKnown\Model\IWellKnown; + + +/** + * @since 21.0.0 + * + * Class WellKnownManager + * + * @package OC\WellKnown + */ +class WellKnownManager implements IWellKnownManager { + + + /** @var IEventDispatcher */ + private $eventDispatcher; + + + /** @var array */ + private $managedServices = + [ + self::WEBFINGER, + self::NODEINFO + ]; + + + /** + * WellKnownManager constructor. + * + * @param IEventDispatcher $eventDispatcher + * + * @since 21.0.0 + * + */ + public function __construct(IEventDispatcher $eventDispatcher) { + $this->eventDispatcher = $eventDispatcher; + } + + + /** + * @param IRequest $request + * + * @return IWellKnown + * @throws WellKnownRequestException + * @throws NotManagedWellKnownRequestException + * @since 21.0.0 + */ + public function manageRequest(IRequest $request): IWellKnown { + $service = $request->getParam('service', ''); + if (!in_array($service, $this->managedServices)) { + throw new NotManagedWellKnownRequestException(404); + } + + $wellKnown = new WellKnown($service, $request); + $this->eventDispatcher->dispatchTyped(new WellKnownEvent($wellKnown)); + + if ($this->isEmpty($wellKnown)) { + throw new WellKnownRequestException(404); + } + + return $wellKnown; + } + + + /** + * @param WellKnown $wellKnown + * + * @return bool + * @since 21.0.0 + */ + private function isEmpty(WellKnown $wellKnown): bool { + if (!empty($wellKnown->getLinks())) { + return false; + } + + if (!empty($wellKnown->getProperties())) { + return false; + } + + if (!empty($wellKnown->getAliases())) { + return false; + } + + return true; + } +} diff --git a/lib/public/WellKnown/Event/WellKnownEvent.php b/lib/public/WellKnown/Event/WellKnownEvent.php new file mode 100644 index 0000000000000..bd252762dd66d --- /dev/null +++ b/lib/public/WellKnown/Event/WellKnownEvent.php @@ -0,0 +1,69 @@ + + * + * @author Maxence Lange + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCP\WellKnown\Event; + +use OCP\EventDispatcher\Event; +use OCP\WellKnown\Model\IWellKnown; + + +/** + * Class WellKnownEvent + * + * Emitted on a request on /.well-known/ + * + * @package OCP\WellKnown\Events + * @since 21.0.0 + */ +class WellKnownEvent extends Event { + + + /** @var IWellKnown */ + private $wellKnown; + + + /** + * WellKnownEvent constructor. + * + * @param IWellKnown $wellKnown + * + * @since 21.0.0 + */ + public function __construct(IWellKnown $wellKnown) { + parent::__construct(); + + $this->wellKnown = $wellKnown; + } + + + /** + * @return IWellKnown + * @since 21.0.0 + */ + public function getWellKnown(): IWellKnown { + return $this->wellKnown; + } +} diff --git a/lib/public/WellKnown/IWellKnownManager.php b/lib/public/WellKnown/IWellKnownManager.php new file mode 100644 index 0000000000000..41dd588f10f1f --- /dev/null +++ b/lib/public/WellKnown/IWellKnownManager.php @@ -0,0 +1,55 @@ + + * + * @author Maxence Lange + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCP\WellKnown; + +use OC\WellKnown\Exceptions\NotManagedWellKnownRequestException; +use OC\WellKnown\Exceptions\WellKnownRequestException; +use OCP\IRequest; +use OCP\WellKnown\Model\IWellKnown; + +/** + * @since 21.0.0 + * + * Interface IWellKnownManager + * + * @package OCP\WellKnown + */ +interface IWellKnownManager { + public const WEBFINGER = 'webfinger'; + public const NODEINFO = 'nodeinfo'; + + + /** + * @param IRequest $request + * + * @return IWellKnown + * @throws WellKnownRequestException + * @throws NotManagedWellKnownRequestException + * @since 21.0.0 + */ + public function manageRequest(IRequest $request): IWellKnown; +} diff --git a/lib/public/WellKnown/Model/IWellKnown.php b/lib/public/WellKnown/Model/IWellKnown.php new file mode 100644 index 0000000000000..4ebc71c46db04 --- /dev/null +++ b/lib/public/WellKnown/Model/IWellKnown.php @@ -0,0 +1,121 @@ + + * + * @author Maxence Lange + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + + +namespace OCP\WellKnown\Model; + +use JsonSerializable; +use OCP\IRequest; + +/** + * @since 21.0.0 + * + * @package OCP\WellKnown\Model + */ +interface IWellKnown { + + + /** + * @return string + * @since 21.0.0 + */ + public function getService(): string; + + + /** + * @return IRequest + * @since 21.0.0 + */ + public function getRequest(): IRequest; + + + /** + * @return string + * @since 21.0.0 + */ + public function getSubject(): string; + + + /** + * @return array + * @since 21.0.0 + */ + public function getRels(): array; + + + /** + * @param string $alias + * + * @return IWellKnown + * @since 21.0.0 + */ + public function addAlias(string $alias): IWellKnown; + + /** + * @return array + * @since 21.0.0 + */ + public function getAliases(): array; + + + /** + * @param string $property + * @param $value + * + * @return IWellKnown + * @since 21.0.0 + */ + public function addProperty(string $property, $value): IWellKnown; + + /** + * @return array + * @since 21.0.0 + */ + public function getProperties(): array; + + + /** + * @param array $arr + * + * @return IWellKnown + * @since 21.0.0 + */ + public function addLink(array $arr): IWellKnown; + + /** + * @param JsonSerializable $object + * + * @return IWellKnown + * @since 21.0.0 + */ + public function addLinkSerialized(JsonSerializable $object): IWellKnown; + + /** + * @return array + * @since 21.0.0 + */ + public function getLinks(): array; +} diff --git a/public.php b/public.php index 90bfdaac5d700..2bc72af300070 100644 --- a/public.php +++ b/public.php @@ -31,6 +31,11 @@ * */ +use OC\WellKnown\Exceptions\NotManagedWellKnownRequestException; +use OC\WellKnown\Exceptions\WellKnownRequestException; +use OC\WellKnown\WellKnownManager; +use OCP\WellKnown\IWellKnownManager; + require_once __DIR__ . '/lib/versioncheck.php'; try { @@ -55,7 +60,24 @@ $pathInfo = trim($pathInfo, '/'); list($service) = explode('/', $pathInfo); } - $file = \OC::$server->getConfig()->getAppValue('core', 'public_' . strip_tags($service)); + + // Managing some .well-known request + OC_App::loadApps(); + try { + /** @var IWellKnownManager $manager */ + $manager = \OC::$server->query(WellKnownManager::class); + $wellKnown = $manager->manageRequest($request); + header('Content-type: application/json'); + echo json_encode($wellKnown); + exit; + } catch (NotManagedWellKnownRequestException $e) { + } catch (WellKnownRequestException $e) { + http_response_code($e->getErrorCode()); + exit; + } + + $file = \OC::$server->getConfig() + ->getAppValue('core', 'public_' . strip_tags($service)); if ($file === '') { http_response_code(404); exit; @@ -66,14 +88,14 @@ // Load all required applications \OC::$REQUESTEDAPP = $app; - OC_App::loadApps(['authentication']); - OC_App::loadApps(['filesystem', 'logging']); +// OC_App::loadApps(['authentication']); // should not be needed anymore +// OC_App::loadApps(['filesystem', 'logging']); if (!\OC::$server->getAppManager()->isInstalled($app)) { http_response_code(404); exit; } - OC_App::loadApp($app); +// OC_App::loadApp($app); OC_User::setIncognitoMode(true); $baseuri = OC::$WEBROOT . '/public.php/' . $service . '/';