@@ -37,90 +37,90 @@ discard block |
||
37 | 37 | /** @var Application $application */ |
38 | 38 | $application = \OC::$server->query(Application::class); |
39 | 39 | $application->registerRoutes($this, [ |
40 | - 'routes' => [ |
|
41 | - ['name' => 'lost#email', 'url' => '/lostpassword/email', 'verb' => 'POST'], |
|
42 | - ['name' => 'lost#resetform', 'url' => '/lostpassword/reset/form/{token}/{userId}', 'verb' => 'GET'], |
|
43 | - ['name' => 'lost#setPassword', 'url' => '/lostpassword/set/{token}/{userId}', 'verb' => 'POST'], |
|
44 | - ['name' => 'user#getDisplayNames', 'url' => '/displaynames', 'verb' => 'POST'], |
|
45 | - ['name' => 'avatar#getAvatar', 'url' => '/avatar/{userId}/{size}', 'verb' => 'GET'], |
|
46 | - ['name' => 'avatar#deleteAvatar', 'url' => '/avatar/', 'verb' => 'DELETE'], |
|
47 | - ['name' => 'avatar#postCroppedAvatar', 'url' => '/avatar/cropped', 'verb' => 'POST'], |
|
48 | - ['name' => 'avatar#getTmpAvatar', 'url' => '/avatar/tmp', 'verb' => 'GET'], |
|
49 | - ['name' => 'avatar#postAvatar', 'url' => '/avatar/', 'verb' => 'POST'], |
|
50 | - ['name' => 'GuestAvatar#getAvatar', 'url' => '/avatar/guest/{guestName}/{size}', 'verb' => 'GET'], |
|
51 | - ['name' => 'CSRFToken#index', 'url' => '/csrftoken', 'verb' => 'GET'], |
|
52 | - ['name' => 'login#tryLogin', 'url' => '/login', 'verb' => 'POST'], |
|
53 | - ['name' => 'login#confirmPassword', 'url' => '/login/confirm', 'verb' => 'POST'], |
|
54 | - ['name' => 'login#showLoginForm', 'url' => '/login', 'verb' => 'GET'], |
|
55 | - ['name' => 'login#logout', 'url' => '/logout', 'verb' => 'GET'], |
|
56 | - // Original login flow used by all clients |
|
57 | - ['name' => 'ClientFlowLogin#showAuthPickerPage', 'url' => '/login/flow', 'verb' => 'GET'], |
|
58 | - ['name' => 'ClientFlowLogin#generateAppPassword', 'url' => '/login/flow', 'verb' => 'POST'], |
|
59 | - ['name' => 'ClientFlowLogin#grantPage', 'url' => '/login/flow/grant', 'verb' => 'GET'], |
|
60 | - ['name' => 'ClientFlowLogin#apptokenRedirect', 'url' => '/login/flow/apptoken', 'verb' => 'POST'], |
|
61 | - // NG login flow used by desktop client in case of Kerberos/fancy 2fa (smart cards for example) |
|
62 | - ['name' => 'ClientFlowLoginV2#poll', 'url' => '/login/v2/poll', 'verb' => 'POST'], |
|
63 | - ['name' => 'ClientFlowLoginV2#showAuthPickerPage', 'url' => '/login/v2/flow', 'verb' => 'GET'], |
|
64 | - ['name' => 'ClientFlowLoginV2#landing', 'url' => '/login/v2/flow/{token}', 'verb' => 'GET'], |
|
65 | - ['name' => 'ClientFlowLoginV2#grantPage', 'url' => '/login/v2/grant', 'verb' => 'GET'], |
|
66 | - ['name' => 'ClientFlowLoginV2#generateAppPassword', 'url' => '/login/v2/grant', 'verb' => 'POST'], |
|
67 | - ['name' => 'ClientFlowLoginV2#init', 'url' => '/login/v2', 'verb' => 'POST'], |
|
68 | - ['name' => 'TwoFactorChallenge#selectChallenge', 'url' => '/login/selectchallenge', 'verb' => 'GET'], |
|
69 | - ['name' => 'TwoFactorChallenge#showChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'GET'], |
|
70 | - ['name' => 'TwoFactorChallenge#solveChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'POST'], |
|
71 | - ['name' => 'TwoFactorChallenge#setupProviders', 'url' => 'login/setupchallenge', 'verb' => 'GET'], |
|
72 | - ['name' => 'TwoFactorChallenge#setupProvider', 'url' => 'login/setupchallenge/{providerId}', 'verb' => 'GET'], |
|
73 | - ['name' => 'TwoFactorChallenge#confirmProviderSetup', 'url' => 'login/setupchallenge/{providerId}', 'verb' => 'POST'], |
|
74 | - ['name' => 'OCJS#getConfig', 'url' => '/core/js/oc.js', 'verb' => 'GET'], |
|
75 | - ['name' => 'Preview#getPreviewByFileId', 'url' => '/core/preview', 'verb' => 'GET'], |
|
76 | - ['name' => 'Preview#getPreview', 'url' => '/core/preview.png', 'verb' => 'GET'], |
|
77 | - ['name' => 'RecommendedApps#index', 'url' => '/core/apps/recommended', 'verb' => 'GET'], |
|
78 | - ['name' => 'Svg#getSvgFromCore', 'url' => '/svg/core/{folder}/{fileName}', 'verb' => 'GET'], |
|
79 | - ['name' => 'Svg#getSvgFromApp', 'url' => '/svg/{app}/{fileName}', 'verb' => 'GET'], |
|
80 | - ['name' => 'Css#getCss', 'url' => '/css/{appName}/{fileName}', 'verb' => 'GET'], |
|
81 | - ['name' => 'Js#getJs', 'url' => '/js/{appName}/{fileName}', 'verb' => 'GET'], |
|
82 | - ['name' => 'contactsMenu#index', 'url' => '/contactsmenu/contacts', 'verb' => 'POST'], |
|
83 | - ['name' => 'contactsMenu#findOne', 'url' => '/contactsmenu/findOne', 'verb' => 'POST'], |
|
84 | - ['name' => 'WalledGarden#get', 'url' => '/204', 'verb' => 'GET'], |
|
85 | - ['name' => 'Search#search', 'url' => '/core/search', 'verb' => 'GET'], |
|
86 | - ['name' => 'Wipe#checkWipe', 'url' => '/core/wipe/check', 'verb' => 'POST'], |
|
87 | - ['name' => 'Wipe#wipeDone', 'url' => '/core/wipe/success', 'verb' => 'POST'], |
|
40 | + 'routes' => [ |
|
41 | + ['name' => 'lost#email', 'url' => '/lostpassword/email', 'verb' => 'POST'], |
|
42 | + ['name' => 'lost#resetform', 'url' => '/lostpassword/reset/form/{token}/{userId}', 'verb' => 'GET'], |
|
43 | + ['name' => 'lost#setPassword', 'url' => '/lostpassword/set/{token}/{userId}', 'verb' => 'POST'], |
|
44 | + ['name' => 'user#getDisplayNames', 'url' => '/displaynames', 'verb' => 'POST'], |
|
45 | + ['name' => 'avatar#getAvatar', 'url' => '/avatar/{userId}/{size}', 'verb' => 'GET'], |
|
46 | + ['name' => 'avatar#deleteAvatar', 'url' => '/avatar/', 'verb' => 'DELETE'], |
|
47 | + ['name' => 'avatar#postCroppedAvatar', 'url' => '/avatar/cropped', 'verb' => 'POST'], |
|
48 | + ['name' => 'avatar#getTmpAvatar', 'url' => '/avatar/tmp', 'verb' => 'GET'], |
|
49 | + ['name' => 'avatar#postAvatar', 'url' => '/avatar/', 'verb' => 'POST'], |
|
50 | + ['name' => 'GuestAvatar#getAvatar', 'url' => '/avatar/guest/{guestName}/{size}', 'verb' => 'GET'], |
|
51 | + ['name' => 'CSRFToken#index', 'url' => '/csrftoken', 'verb' => 'GET'], |
|
52 | + ['name' => 'login#tryLogin', 'url' => '/login', 'verb' => 'POST'], |
|
53 | + ['name' => 'login#confirmPassword', 'url' => '/login/confirm', 'verb' => 'POST'], |
|
54 | + ['name' => 'login#showLoginForm', 'url' => '/login', 'verb' => 'GET'], |
|
55 | + ['name' => 'login#logout', 'url' => '/logout', 'verb' => 'GET'], |
|
56 | + // Original login flow used by all clients |
|
57 | + ['name' => 'ClientFlowLogin#showAuthPickerPage', 'url' => '/login/flow', 'verb' => 'GET'], |
|
58 | + ['name' => 'ClientFlowLogin#generateAppPassword', 'url' => '/login/flow', 'verb' => 'POST'], |
|
59 | + ['name' => 'ClientFlowLogin#grantPage', 'url' => '/login/flow/grant', 'verb' => 'GET'], |
|
60 | + ['name' => 'ClientFlowLogin#apptokenRedirect', 'url' => '/login/flow/apptoken', 'verb' => 'POST'], |
|
61 | + // NG login flow used by desktop client in case of Kerberos/fancy 2fa (smart cards for example) |
|
62 | + ['name' => 'ClientFlowLoginV2#poll', 'url' => '/login/v2/poll', 'verb' => 'POST'], |
|
63 | + ['name' => 'ClientFlowLoginV2#showAuthPickerPage', 'url' => '/login/v2/flow', 'verb' => 'GET'], |
|
64 | + ['name' => 'ClientFlowLoginV2#landing', 'url' => '/login/v2/flow/{token}', 'verb' => 'GET'], |
|
65 | + ['name' => 'ClientFlowLoginV2#grantPage', 'url' => '/login/v2/grant', 'verb' => 'GET'], |
|
66 | + ['name' => 'ClientFlowLoginV2#generateAppPassword', 'url' => '/login/v2/grant', 'verb' => 'POST'], |
|
67 | + ['name' => 'ClientFlowLoginV2#init', 'url' => '/login/v2', 'verb' => 'POST'], |
|
68 | + ['name' => 'TwoFactorChallenge#selectChallenge', 'url' => '/login/selectchallenge', 'verb' => 'GET'], |
|
69 | + ['name' => 'TwoFactorChallenge#showChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'GET'], |
|
70 | + ['name' => 'TwoFactorChallenge#solveChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'POST'], |
|
71 | + ['name' => 'TwoFactorChallenge#setupProviders', 'url' => 'login/setupchallenge', 'verb' => 'GET'], |
|
72 | + ['name' => 'TwoFactorChallenge#setupProvider', 'url' => 'login/setupchallenge/{providerId}', 'verb' => 'GET'], |
|
73 | + ['name' => 'TwoFactorChallenge#confirmProviderSetup', 'url' => 'login/setupchallenge/{providerId}', 'verb' => 'POST'], |
|
74 | + ['name' => 'OCJS#getConfig', 'url' => '/core/js/oc.js', 'verb' => 'GET'], |
|
75 | + ['name' => 'Preview#getPreviewByFileId', 'url' => '/core/preview', 'verb' => 'GET'], |
|
76 | + ['name' => 'Preview#getPreview', 'url' => '/core/preview.png', 'verb' => 'GET'], |
|
77 | + ['name' => 'RecommendedApps#index', 'url' => '/core/apps/recommended', 'verb' => 'GET'], |
|
78 | + ['name' => 'Svg#getSvgFromCore', 'url' => '/svg/core/{folder}/{fileName}', 'verb' => 'GET'], |
|
79 | + ['name' => 'Svg#getSvgFromApp', 'url' => '/svg/{app}/{fileName}', 'verb' => 'GET'], |
|
80 | + ['name' => 'Css#getCss', 'url' => '/css/{appName}/{fileName}', 'verb' => 'GET'], |
|
81 | + ['name' => 'Js#getJs', 'url' => '/js/{appName}/{fileName}', 'verb' => 'GET'], |
|
82 | + ['name' => 'contactsMenu#index', 'url' => '/contactsmenu/contacts', 'verb' => 'POST'], |
|
83 | + ['name' => 'contactsMenu#findOne', 'url' => '/contactsmenu/findOne', 'verb' => 'POST'], |
|
84 | + ['name' => 'WalledGarden#get', 'url' => '/204', 'verb' => 'GET'], |
|
85 | + ['name' => 'Search#search', 'url' => '/core/search', 'verb' => 'GET'], |
|
86 | + ['name' => 'Wipe#checkWipe', 'url' => '/core/wipe/check', 'verb' => 'POST'], |
|
87 | + ['name' => 'Wipe#wipeDone', 'url' => '/core/wipe/success', 'verb' => 'POST'], |
|
88 | 88 | |
89 | - // Logins for passwordless auth |
|
90 | - ['name' => 'WebAuthn#startAuthentication', 'url' => 'login/webauthn/start', 'verb' => 'POST'], |
|
91 | - ['name' => 'WebAuthn#finishAuthentication', 'url' => 'login/webauthn/finish', 'verb' => 'POST'], |
|
89 | + // Logins for passwordless auth |
|
90 | + ['name' => 'WebAuthn#startAuthentication', 'url' => 'login/webauthn/start', 'verb' => 'POST'], |
|
91 | + ['name' => 'WebAuthn#finishAuthentication', 'url' => 'login/webauthn/finish', 'verb' => 'POST'], |
|
92 | 92 | |
93 | - // Well known requests https://tools.ietf.org/html/rfc5785 |
|
94 | - ['name' => 'WellKnown#handle', 'url' => '.well-known/{service}'], |
|
95 | - ], |
|
96 | - 'ocs' => [ |
|
97 | - ['root' => '/cloud', 'name' => 'OCS#getCapabilities', 'url' => '/capabilities', 'verb' => 'GET'], |
|
98 | - ['root' => '', 'name' => 'OCS#getConfig', 'url' => '/config', 'verb' => 'GET'], |
|
99 | - ['root' => '/person', 'name' => 'OCS#personCheck', 'url' => '/check', 'verb' => 'POST'], |
|
100 | - ['root' => '/identityproof', 'name' => 'OCS#getIdentityProof', 'url' => '/key/{cloudId}', 'verb' => 'GET'], |
|
101 | - ['root' => '/core', 'name' => 'Navigation#getAppsNavigation', 'url' => '/navigation/apps', 'verb' => 'GET'], |
|
102 | - ['root' => '/core', 'name' => 'Navigation#getSettingsNavigation', 'url' => '/navigation/settings', 'verb' => 'GET'], |
|
103 | - ['root' => '/core', 'name' => 'AutoComplete#get', 'url' => '/autocomplete/get', 'verb' => 'GET'], |
|
104 | - ['root' => '/core', 'name' => 'WhatsNew#get', 'url' => '/whatsnew', 'verb' => 'GET'], |
|
105 | - ['root' => '/core', 'name' => 'WhatsNew#dismiss', 'url' => '/whatsnew', 'verb' => 'POST'], |
|
106 | - ['root' => '/core', 'name' => 'AppPassword#getAppPassword', 'url' => '/getapppassword', 'verb' => 'GET'], |
|
107 | - ['root' => '/core', 'name' => 'AppPassword#rotateAppPassword', 'url' => '/apppassword/rotate', 'verb' => 'POST'], |
|
108 | - ['root' => '/core', 'name' => 'AppPassword#deleteAppPassword', 'url' => '/apppassword', 'verb' => 'DELETE'], |
|
93 | + // Well known requests https://tools.ietf.org/html/rfc5785 |
|
94 | + ['name' => 'WellKnown#handle', 'url' => '.well-known/{service}'], |
|
95 | + ], |
|
96 | + 'ocs' => [ |
|
97 | + ['root' => '/cloud', 'name' => 'OCS#getCapabilities', 'url' => '/capabilities', 'verb' => 'GET'], |
|
98 | + ['root' => '', 'name' => 'OCS#getConfig', 'url' => '/config', 'verb' => 'GET'], |
|
99 | + ['root' => '/person', 'name' => 'OCS#personCheck', 'url' => '/check', 'verb' => 'POST'], |
|
100 | + ['root' => '/identityproof', 'name' => 'OCS#getIdentityProof', 'url' => '/key/{cloudId}', 'verb' => 'GET'], |
|
101 | + ['root' => '/core', 'name' => 'Navigation#getAppsNavigation', 'url' => '/navigation/apps', 'verb' => 'GET'], |
|
102 | + ['root' => '/core', 'name' => 'Navigation#getSettingsNavigation', 'url' => '/navigation/settings', 'verb' => 'GET'], |
|
103 | + ['root' => '/core', 'name' => 'AutoComplete#get', 'url' => '/autocomplete/get', 'verb' => 'GET'], |
|
104 | + ['root' => '/core', 'name' => 'WhatsNew#get', 'url' => '/whatsnew', 'verb' => 'GET'], |
|
105 | + ['root' => '/core', 'name' => 'WhatsNew#dismiss', 'url' => '/whatsnew', 'verb' => 'POST'], |
|
106 | + ['root' => '/core', 'name' => 'AppPassword#getAppPassword', 'url' => '/getapppassword', 'verb' => 'GET'], |
|
107 | + ['root' => '/core', 'name' => 'AppPassword#rotateAppPassword', 'url' => '/apppassword/rotate', 'verb' => 'POST'], |
|
108 | + ['root' => '/core', 'name' => 'AppPassword#deleteAppPassword', 'url' => '/apppassword', 'verb' => 'DELETE'], |
|
109 | 109 | |
110 | - ['root' => '/collaboration', 'name' => 'CollaborationResources#searchCollections', 'url' => '/resources/collections/search/{filter}', 'verb' => 'GET'], |
|
111 | - ['root' => '/collaboration', 'name' => 'CollaborationResources#listCollection', 'url' => '/resources/collections/{collectionId}', 'verb' => 'GET'], |
|
112 | - ['root' => '/collaboration', 'name' => 'CollaborationResources#renameCollection', 'url' => '/resources/collections/{collectionId}', 'verb' => 'PUT'], |
|
113 | - ['root' => '/collaboration', 'name' => 'CollaborationResources#addResource', 'url' => '/resources/collections/{collectionId}', 'verb' => 'POST'], |
|
110 | + ['root' => '/collaboration', 'name' => 'CollaborationResources#searchCollections', 'url' => '/resources/collections/search/{filter}', 'verb' => 'GET'], |
|
111 | + ['root' => '/collaboration', 'name' => 'CollaborationResources#listCollection', 'url' => '/resources/collections/{collectionId}', 'verb' => 'GET'], |
|
112 | + ['root' => '/collaboration', 'name' => 'CollaborationResources#renameCollection', 'url' => '/resources/collections/{collectionId}', 'verb' => 'PUT'], |
|
113 | + ['root' => '/collaboration', 'name' => 'CollaborationResources#addResource', 'url' => '/resources/collections/{collectionId}', 'verb' => 'POST'], |
|
114 | 114 | |
115 | - ['root' => '/collaboration', 'name' => 'CollaborationResources#removeResource', 'url' => '/resources/collections/{collectionId}', 'verb' => 'DELETE'], |
|
116 | - ['root' => '/collaboration', 'name' => 'CollaborationResources#getCollectionsByResource', 'url' => '/resources/{resourceType}/{resourceId}', 'verb' => 'GET'], |
|
117 | - ['root' => '/collaboration', 'name' => 'CollaborationResources#createCollectionOnResource', 'url' => '/resources/{baseResourceType}/{baseResourceId}', 'verb' => 'POST'], |
|
115 | + ['root' => '/collaboration', 'name' => 'CollaborationResources#removeResource', 'url' => '/resources/collections/{collectionId}', 'verb' => 'DELETE'], |
|
116 | + ['root' => '/collaboration', 'name' => 'CollaborationResources#getCollectionsByResource', 'url' => '/resources/{resourceType}/{resourceId}', 'verb' => 'GET'], |
|
117 | + ['root' => '/collaboration', 'name' => 'CollaborationResources#createCollectionOnResource', 'url' => '/resources/{baseResourceType}/{baseResourceId}', 'verb' => 'POST'], |
|
118 | 118 | |
119 | - // Unified search |
|
120 | - ['root' => '/search', 'name' => 'UnifiedSearch#getProviders', 'url' => '/providers', 'verb' => 'GET'], |
|
121 | - ['root' => '/search', 'name' => 'UnifiedSearch#search', 'url' => '/providers/{providerId}/search', 'verb' => 'GET'], |
|
119 | + // Unified search |
|
120 | + ['root' => '/search', 'name' => 'UnifiedSearch#getProviders', 'url' => '/providers', 'verb' => 'GET'], |
|
121 | + ['root' => '/search', 'name' => 'UnifiedSearch#search', 'url' => '/providers/{providerId}/search', 'verb' => 'GET'], |
|
122 | 122 | |
123 | - ], |
|
123 | + ], |
|
124 | 124 | ]); |
125 | 125 | |
126 | 126 | // Post installation check |
@@ -129,4 +129,4 @@ discard block |
||
129 | 129 | // Core ajax actions |
130 | 130 | // Routing |
131 | 131 | $this->create('core_ajax_update', '/core/ajax/update.php') |
132 | - ->actionInclude('core/ajax/update.php'); |
|
132 | + ->actionInclude('core/ajax/update.php'); |
@@ -34,34 +34,34 @@ |
||
34 | 34 | |
35 | 35 | class WellKnownController extends Controller { |
36 | 36 | |
37 | - /** @var RequestManager */ |
|
38 | - private $requestManager; |
|
37 | + /** @var RequestManager */ |
|
38 | + private $requestManager; |
|
39 | 39 | |
40 | - public function __construct(IRequest $request, |
|
41 | - RequestManager $wellKnownManager) { |
|
42 | - parent::__construct('core', $request); |
|
43 | - $this->requestManager = $wellKnownManager; |
|
44 | - } |
|
40 | + public function __construct(IRequest $request, |
|
41 | + RequestManager $wellKnownManager) { |
|
42 | + parent::__construct('core', $request); |
|
43 | + $this->requestManager = $wellKnownManager; |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * @PublicPage |
|
48 | - * @NoCSRFRequired |
|
49 | - * |
|
50 | - * @return Response |
|
51 | - */ |
|
52 | - public function handle(string $service): Response { |
|
53 | - $response = $this->requestManager->process( |
|
54 | - $service, |
|
55 | - $this->request |
|
56 | - ); |
|
46 | + /** |
|
47 | + * @PublicPage |
|
48 | + * @NoCSRFRequired |
|
49 | + * |
|
50 | + * @return Response |
|
51 | + */ |
|
52 | + public function handle(string $service): Response { |
|
53 | + $response = $this->requestManager->process( |
|
54 | + $service, |
|
55 | + $this->request |
|
56 | + ); |
|
57 | 57 | |
58 | - if ($response === null) { |
|
59 | - $httpResponse = new JSONResponse(["message" => "$service not supported"], Http::STATUS_NOT_FOUND); |
|
60 | - } else { |
|
61 | - $httpResponse = $response->toHttpResponse(); |
|
62 | - } |
|
58 | + if ($response === null) { |
|
59 | + $httpResponse = new JSONResponse(["message" => "$service not supported"], Http::STATUS_NOT_FOUND); |
|
60 | + } else { |
|
61 | + $httpResponse = $response->toHttpResponse(); |
|
62 | + } |
|
63 | 63 | |
64 | - // We add a custom header so that setup checks can detect if their requests are answered by this controller |
|
65 | - return $httpResponse->addHeader('X-NEXTCLOUD-WELL-KNOWN', '1'); |
|
66 | - } |
|
64 | + // We add a custom header so that setup checks can detect if their requests are answered by this controller |
|
65 | + return $httpResponse->addHeader('X-NEXTCLOUD-WELL-KNOWN', '1'); |
|
66 | + } |
|
67 | 67 | } |
@@ -66,145 +66,145 @@ |
||
66 | 66 | use Symfony\Component\EventDispatcher\GenericEvent; |
67 | 67 | |
68 | 68 | class Application extends App implements IBootstrap { |
69 | - public const APP_ID = 'settings'; |
|
70 | - |
|
71 | - /** |
|
72 | - * @param array $urlParams |
|
73 | - */ |
|
74 | - public function __construct(array $urlParams = []) { |
|
75 | - parent::__construct(self::APP_ID, $urlParams); |
|
76 | - } |
|
77 | - |
|
78 | - public function register(IRegistrationContext $context): void { |
|
79 | - // Register Middleware |
|
80 | - $context->registerServiceAlias('SubadminMiddleware', SubadminMiddleware::class); |
|
81 | - $context->registerMiddleware(SubadminMiddleware::class); |
|
82 | - $context->registerSearchProvider(SectionSearch::class); |
|
83 | - $context->registerSearchProvider(AppSearch::class); |
|
84 | - |
|
85 | - /** |
|
86 | - * Core class wrappers |
|
87 | - */ |
|
88 | - /** FIXME: Remove once OC_User is non-static and mockable */ |
|
89 | - $context->registerService('isAdmin', function () { |
|
90 | - return \OC_User::isAdminUser(\OC_User::getUser()); |
|
91 | - }); |
|
92 | - /** FIXME: Remove once OC_SubAdmin is non-static and mockable */ |
|
93 | - $context->registerService('isSubAdmin', function () { |
|
94 | - $userObject = \OC::$server->getUserSession()->getUser(); |
|
95 | - $isSubAdmin = false; |
|
96 | - if ($userObject !== null) { |
|
97 | - $isSubAdmin = \OC::$server->getGroupManager()->getSubAdmin()->isSubAdmin($userObject); |
|
98 | - } |
|
99 | - return $isSubAdmin; |
|
100 | - }); |
|
101 | - $context->registerService(IProvider::class, function (IAppContainer $appContainer) { |
|
102 | - /** @var IServerContainer $serverContainer */ |
|
103 | - $serverContainer = $appContainer->query(IServerContainer::class); |
|
104 | - return $serverContainer->query(IProvider::class); |
|
105 | - }); |
|
106 | - $context->registerService(IManager::class, function (IAppContainer $appContainer) { |
|
107 | - /** @var IServerContainer $serverContainer */ |
|
108 | - $serverContainer = $appContainer->query(IServerContainer::class); |
|
109 | - return $serverContainer->getSettingsManager(); |
|
110 | - }); |
|
111 | - |
|
112 | - $context->registerService(NewUserMailHelper::class, function (IAppContainer $appContainer) { |
|
113 | - /** @var Server $server */ |
|
114 | - $server = $appContainer->query(IServerContainer::class); |
|
115 | - /** @var Defaults $defaults */ |
|
116 | - $defaults = $server->query(Defaults::class); |
|
117 | - |
|
118 | - return new NewUserMailHelper( |
|
119 | - $defaults, |
|
120 | - $server->getURLGenerator(), |
|
121 | - $server->getL10NFactory(), |
|
122 | - $server->getMailer(), |
|
123 | - $server->getSecureRandom(), |
|
124 | - new TimeFactory(), |
|
125 | - $server->getConfig(), |
|
126 | - $server->getCrypto(), |
|
127 | - Util::getDefaultEmailAddress('no-reply') |
|
128 | - ); |
|
129 | - }); |
|
130 | - } |
|
131 | - |
|
132 | - public function boot(IBootContext $context): void { |
|
133 | - $context->injectFn(function (EventDispatcherInterface $dispatcher, IAppContainer $appContainer) { |
|
134 | - $dispatcher->addListener('app_password_created', function (GenericEvent $event) use ($appContainer) { |
|
135 | - if (($token = $event->getSubject()) instanceof IToken) { |
|
136 | - /** @var IActivityManager $activityManager */ |
|
137 | - $activityManager = $appContainer->get(IActivityManager::class); |
|
138 | - /** @var ILogger $logger */ |
|
139 | - $logger = $appContainer->get(ILogger::class); |
|
140 | - |
|
141 | - $activity = $activityManager->generateEvent(); |
|
142 | - $activity->setApp('settings') |
|
143 | - ->setType('security') |
|
144 | - ->setAffectedUser($token->getUID()) |
|
145 | - ->setAuthor($token->getUID()) |
|
146 | - ->setSubject(Provider::APP_TOKEN_CREATED, ['name' => $token->getName()]) |
|
147 | - ->setObject('app_token', $token->getId()); |
|
148 | - |
|
149 | - try { |
|
150 | - $activityManager->publish($activity); |
|
151 | - } catch (BadMethodCallException $e) { |
|
152 | - $logger->logException($e, ['message' => 'could not publish activity', 'level' => ILogger::WARN]); |
|
153 | - } |
|
154 | - } |
|
155 | - }); |
|
156 | - }); |
|
157 | - |
|
158 | - Util::connectHook('OC_User', 'post_setPassword', $this, 'onChangePassword'); |
|
159 | - Util::connectHook('OC_User', 'changeUser', $this, 'onChangeInfo'); |
|
160 | - |
|
161 | - $context->injectFn(function (IGroupManager $groupManager) { |
|
162 | - /** @var IGroupManager|Manager $groupManager */ |
|
163 | - $groupManager->listen('\OC\Group', 'postRemoveUser', [$this, 'removeUserFromGroup']); |
|
164 | - $groupManager->listen('\OC\Group', 'postAddUser', [$this, 'addUserToGroup']); |
|
165 | - }); |
|
166 | - } |
|
167 | - |
|
168 | - public function addUserToGroup(IGroup $group, IUser $user): void { |
|
169 | - /** @var Hooks $hooks */ |
|
170 | - $hooks = $this->getContainer()->query(Hooks::class); |
|
171 | - $hooks->addUserToGroup($group, $user); |
|
172 | - } |
|
173 | - |
|
174 | - public function removeUserFromGroup(IGroup $group, IUser $user): void { |
|
175 | - /** @var Hooks $hooks */ |
|
176 | - $hooks = $this->getContainer()->query(Hooks::class); |
|
177 | - $hooks->removeUserFromGroup($group, $user); |
|
178 | - } |
|
179 | - |
|
180 | - |
|
181 | - /** |
|
182 | - * @param array $parameters |
|
183 | - * @throws \InvalidArgumentException |
|
184 | - * @throws \BadMethodCallException |
|
185 | - * @throws \Exception |
|
186 | - * @throws \OCP\AppFramework\QueryException |
|
187 | - */ |
|
188 | - public function onChangePassword(array $parameters) { |
|
189 | - /** @var Hooks $hooks */ |
|
190 | - $hooks = $this->getContainer()->query(Hooks::class); |
|
191 | - $hooks->onChangePassword($parameters['uid']); |
|
192 | - } |
|
193 | - |
|
194 | - /** |
|
195 | - * @param array $parameters |
|
196 | - * @throws \InvalidArgumentException |
|
197 | - * @throws \BadMethodCallException |
|
198 | - * @throws \Exception |
|
199 | - * @throws \OCP\AppFramework\QueryException |
|
200 | - */ |
|
201 | - public function onChangeInfo(array $parameters) { |
|
202 | - if ($parameters['feature'] !== 'eMailAddress') { |
|
203 | - return; |
|
204 | - } |
|
205 | - |
|
206 | - /** @var Hooks $hooks */ |
|
207 | - $hooks = $this->getContainer()->query(Hooks::class); |
|
208 | - $hooks->onChangeEmail($parameters['user'], $parameters['old_value']); |
|
209 | - } |
|
69 | + public const APP_ID = 'settings'; |
|
70 | + |
|
71 | + /** |
|
72 | + * @param array $urlParams |
|
73 | + */ |
|
74 | + public function __construct(array $urlParams = []) { |
|
75 | + parent::__construct(self::APP_ID, $urlParams); |
|
76 | + } |
|
77 | + |
|
78 | + public function register(IRegistrationContext $context): void { |
|
79 | + // Register Middleware |
|
80 | + $context->registerServiceAlias('SubadminMiddleware', SubadminMiddleware::class); |
|
81 | + $context->registerMiddleware(SubadminMiddleware::class); |
|
82 | + $context->registerSearchProvider(SectionSearch::class); |
|
83 | + $context->registerSearchProvider(AppSearch::class); |
|
84 | + |
|
85 | + /** |
|
86 | + * Core class wrappers |
|
87 | + */ |
|
88 | + /** FIXME: Remove once OC_User is non-static and mockable */ |
|
89 | + $context->registerService('isAdmin', function () { |
|
90 | + return \OC_User::isAdminUser(\OC_User::getUser()); |
|
91 | + }); |
|
92 | + /** FIXME: Remove once OC_SubAdmin is non-static and mockable */ |
|
93 | + $context->registerService('isSubAdmin', function () { |
|
94 | + $userObject = \OC::$server->getUserSession()->getUser(); |
|
95 | + $isSubAdmin = false; |
|
96 | + if ($userObject !== null) { |
|
97 | + $isSubAdmin = \OC::$server->getGroupManager()->getSubAdmin()->isSubAdmin($userObject); |
|
98 | + } |
|
99 | + return $isSubAdmin; |
|
100 | + }); |
|
101 | + $context->registerService(IProvider::class, function (IAppContainer $appContainer) { |
|
102 | + /** @var IServerContainer $serverContainer */ |
|
103 | + $serverContainer = $appContainer->query(IServerContainer::class); |
|
104 | + return $serverContainer->query(IProvider::class); |
|
105 | + }); |
|
106 | + $context->registerService(IManager::class, function (IAppContainer $appContainer) { |
|
107 | + /** @var IServerContainer $serverContainer */ |
|
108 | + $serverContainer = $appContainer->query(IServerContainer::class); |
|
109 | + return $serverContainer->getSettingsManager(); |
|
110 | + }); |
|
111 | + |
|
112 | + $context->registerService(NewUserMailHelper::class, function (IAppContainer $appContainer) { |
|
113 | + /** @var Server $server */ |
|
114 | + $server = $appContainer->query(IServerContainer::class); |
|
115 | + /** @var Defaults $defaults */ |
|
116 | + $defaults = $server->query(Defaults::class); |
|
117 | + |
|
118 | + return new NewUserMailHelper( |
|
119 | + $defaults, |
|
120 | + $server->getURLGenerator(), |
|
121 | + $server->getL10NFactory(), |
|
122 | + $server->getMailer(), |
|
123 | + $server->getSecureRandom(), |
|
124 | + new TimeFactory(), |
|
125 | + $server->getConfig(), |
|
126 | + $server->getCrypto(), |
|
127 | + Util::getDefaultEmailAddress('no-reply') |
|
128 | + ); |
|
129 | + }); |
|
130 | + } |
|
131 | + |
|
132 | + public function boot(IBootContext $context): void { |
|
133 | + $context->injectFn(function (EventDispatcherInterface $dispatcher, IAppContainer $appContainer) { |
|
134 | + $dispatcher->addListener('app_password_created', function (GenericEvent $event) use ($appContainer) { |
|
135 | + if (($token = $event->getSubject()) instanceof IToken) { |
|
136 | + /** @var IActivityManager $activityManager */ |
|
137 | + $activityManager = $appContainer->get(IActivityManager::class); |
|
138 | + /** @var ILogger $logger */ |
|
139 | + $logger = $appContainer->get(ILogger::class); |
|
140 | + |
|
141 | + $activity = $activityManager->generateEvent(); |
|
142 | + $activity->setApp('settings') |
|
143 | + ->setType('security') |
|
144 | + ->setAffectedUser($token->getUID()) |
|
145 | + ->setAuthor($token->getUID()) |
|
146 | + ->setSubject(Provider::APP_TOKEN_CREATED, ['name' => $token->getName()]) |
|
147 | + ->setObject('app_token', $token->getId()); |
|
148 | + |
|
149 | + try { |
|
150 | + $activityManager->publish($activity); |
|
151 | + } catch (BadMethodCallException $e) { |
|
152 | + $logger->logException($e, ['message' => 'could not publish activity', 'level' => ILogger::WARN]); |
|
153 | + } |
|
154 | + } |
|
155 | + }); |
|
156 | + }); |
|
157 | + |
|
158 | + Util::connectHook('OC_User', 'post_setPassword', $this, 'onChangePassword'); |
|
159 | + Util::connectHook('OC_User', 'changeUser', $this, 'onChangeInfo'); |
|
160 | + |
|
161 | + $context->injectFn(function (IGroupManager $groupManager) { |
|
162 | + /** @var IGroupManager|Manager $groupManager */ |
|
163 | + $groupManager->listen('\OC\Group', 'postRemoveUser', [$this, 'removeUserFromGroup']); |
|
164 | + $groupManager->listen('\OC\Group', 'postAddUser', [$this, 'addUserToGroup']); |
|
165 | + }); |
|
166 | + } |
|
167 | + |
|
168 | + public function addUserToGroup(IGroup $group, IUser $user): void { |
|
169 | + /** @var Hooks $hooks */ |
|
170 | + $hooks = $this->getContainer()->query(Hooks::class); |
|
171 | + $hooks->addUserToGroup($group, $user); |
|
172 | + } |
|
173 | + |
|
174 | + public function removeUserFromGroup(IGroup $group, IUser $user): void { |
|
175 | + /** @var Hooks $hooks */ |
|
176 | + $hooks = $this->getContainer()->query(Hooks::class); |
|
177 | + $hooks->removeUserFromGroup($group, $user); |
|
178 | + } |
|
179 | + |
|
180 | + |
|
181 | + /** |
|
182 | + * @param array $parameters |
|
183 | + * @throws \InvalidArgumentException |
|
184 | + * @throws \BadMethodCallException |
|
185 | + * @throws \Exception |
|
186 | + * @throws \OCP\AppFramework\QueryException |
|
187 | + */ |
|
188 | + public function onChangePassword(array $parameters) { |
|
189 | + /** @var Hooks $hooks */ |
|
190 | + $hooks = $this->getContainer()->query(Hooks::class); |
|
191 | + $hooks->onChangePassword($parameters['uid']); |
|
192 | + } |
|
193 | + |
|
194 | + /** |
|
195 | + * @param array $parameters |
|
196 | + * @throws \InvalidArgumentException |
|
197 | + * @throws \BadMethodCallException |
|
198 | + * @throws \Exception |
|
199 | + * @throws \OCP\AppFramework\QueryException |
|
200 | + */ |
|
201 | + public function onChangeInfo(array $parameters) { |
|
202 | + if ($parameters['feature'] !== 'eMailAddress') { |
|
203 | + return; |
|
204 | + } |
|
205 | + |
|
206 | + /** @var Hooks $hooks */ |
|
207 | + $hooks = $this->getContainer()->query(Hooks::class); |
|
208 | + $hooks->onChangeEmail($parameters['user'], $parameters['old_value']); |
|
209 | + } |
|
210 | 210 | } |
@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | * Core class wrappers |
87 | 87 | */ |
88 | 88 | /** FIXME: Remove once OC_User is non-static and mockable */ |
89 | - $context->registerService('isAdmin', function () { |
|
89 | + $context->registerService('isAdmin', function() { |
|
90 | 90 | return \OC_User::isAdminUser(\OC_User::getUser()); |
91 | 91 | }); |
92 | 92 | /** FIXME: Remove once OC_SubAdmin is non-static and mockable */ |
93 | - $context->registerService('isSubAdmin', function () { |
|
93 | + $context->registerService('isSubAdmin', function() { |
|
94 | 94 | $userObject = \OC::$server->getUserSession()->getUser(); |
95 | 95 | $isSubAdmin = false; |
96 | 96 | if ($userObject !== null) { |
@@ -98,18 +98,18 @@ discard block |
||
98 | 98 | } |
99 | 99 | return $isSubAdmin; |
100 | 100 | }); |
101 | - $context->registerService(IProvider::class, function (IAppContainer $appContainer) { |
|
101 | + $context->registerService(IProvider::class, function(IAppContainer $appContainer) { |
|
102 | 102 | /** @var IServerContainer $serverContainer */ |
103 | 103 | $serverContainer = $appContainer->query(IServerContainer::class); |
104 | 104 | return $serverContainer->query(IProvider::class); |
105 | 105 | }); |
106 | - $context->registerService(IManager::class, function (IAppContainer $appContainer) { |
|
106 | + $context->registerService(IManager::class, function(IAppContainer $appContainer) { |
|
107 | 107 | /** @var IServerContainer $serverContainer */ |
108 | 108 | $serverContainer = $appContainer->query(IServerContainer::class); |
109 | 109 | return $serverContainer->getSettingsManager(); |
110 | 110 | }); |
111 | 111 | |
112 | - $context->registerService(NewUserMailHelper::class, function (IAppContainer $appContainer) { |
|
112 | + $context->registerService(NewUserMailHelper::class, function(IAppContainer $appContainer) { |
|
113 | 113 | /** @var Server $server */ |
114 | 114 | $server = $appContainer->query(IServerContainer::class); |
115 | 115 | /** @var Defaults $defaults */ |
@@ -130,8 +130,8 @@ discard block |
||
130 | 130 | } |
131 | 131 | |
132 | 132 | public function boot(IBootContext $context): void { |
133 | - $context->injectFn(function (EventDispatcherInterface $dispatcher, IAppContainer $appContainer) { |
|
134 | - $dispatcher->addListener('app_password_created', function (GenericEvent $event) use ($appContainer) { |
|
133 | + $context->injectFn(function(EventDispatcherInterface $dispatcher, IAppContainer $appContainer) { |
|
134 | + $dispatcher->addListener('app_password_created', function(GenericEvent $event) use ($appContainer) { |
|
135 | 135 | if (($token = $event->getSubject()) instanceof IToken) { |
136 | 136 | /** @var IActivityManager $activityManager */ |
137 | 137 | $activityManager = $appContainer->get(IActivityManager::class); |
@@ -158,10 +158,10 @@ discard block |
||
158 | 158 | Util::connectHook('OC_User', 'post_setPassword', $this, 'onChangePassword'); |
159 | 159 | Util::connectHook('OC_User', 'changeUser', $this, 'onChangeInfo'); |
160 | 160 | |
161 | - $context->injectFn(function (IGroupManager $groupManager) { |
|
161 | + $context->injectFn(function(IGroupManager $groupManager) { |
|
162 | 162 | /** @var IGroupManager|Manager $groupManager */ |
163 | - $groupManager->listen('\OC\Group', 'postRemoveUser', [$this, 'removeUserFromGroup']); |
|
164 | - $groupManager->listen('\OC\Group', 'postAddUser', [$this, 'addUserToGroup']); |
|
163 | + $groupManager->listen('\OC\Group', 'postRemoveUser', [$this, 'removeUserFromGroup']); |
|
164 | + $groupManager->listen('\OC\Group', 'postAddUser', [$this, 'addUserToGroup']); |
|
165 | 165 | }); |
166 | 166 | } |
167 | 167 |
@@ -39,132 +39,132 @@ |
||
39 | 39 | */ |
40 | 40 | final class JrdResponse implements IResponse { |
41 | 41 | |
42 | - /** @var string */ |
|
43 | - private $subject; |
|
44 | - |
|
45 | - /** @var string|null */ |
|
46 | - private $expires; |
|
47 | - |
|
48 | - /** @var string[] */ |
|
49 | - private $aliases = []; |
|
50 | - |
|
51 | - /** @var (string|null)[] */ |
|
52 | - private $properties = []; |
|
53 | - |
|
54 | - /** @var mixed[] */ |
|
55 | - private $links; |
|
56 | - |
|
57 | - /** |
|
58 | - * @param string $subject https://tools.ietf.org/html/rfc7033#section-4.4.1 |
|
59 | - * |
|
60 | - * @since 21.0.0 |
|
61 | - */ |
|
62 | - public function __construct(string $subject) { |
|
63 | - $this->subject = $subject; |
|
64 | - } |
|
65 | - |
|
66 | - /** |
|
67 | - * @param string $expires |
|
68 | - * |
|
69 | - * @return $this |
|
70 | - * |
|
71 | - * @since 21.0.0 |
|
72 | - */ |
|
73 | - public function setExpires(string $expires): self { |
|
74 | - $this->expires = $expires; |
|
75 | - |
|
76 | - return $this; |
|
77 | - } |
|
78 | - |
|
79 | - /** |
|
80 | - * Add an alias |
|
81 | - * |
|
82 | - * @ref https://tools.ietf.org/html/rfc7033#section-4.4.2 |
|
83 | - * |
|
84 | - * @param string $alias |
|
85 | - * |
|
86 | - * @return $this |
|
87 | - * |
|
88 | - * @since 21.0.0 |
|
89 | - */ |
|
90 | - public function addAlias(string $alias): self { |
|
91 | - $this->aliases[] = $alias; |
|
92 | - |
|
93 | - return $this; |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * Add a property |
|
98 | - * |
|
99 | - * @ref https://tools.ietf.org/html/rfc7033#section-4.4.3 |
|
100 | - * |
|
101 | - * @param string $property |
|
102 | - * @param string|null $value |
|
103 | - * |
|
104 | - * @return $this |
|
105 | - * |
|
106 | - * @since 21.0.0 |
|
107 | - */ |
|
108 | - public function addProperty(string $property, ?string $value): self { |
|
109 | - $this->properties[$property] = $value; |
|
110 | - |
|
111 | - return $this; |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * Add a link |
|
116 | - * |
|
117 | - * @ref https://tools.ietf.org/html/rfc7033#section-8.4 |
|
118 | - * |
|
119 | - * @param string $rel https://tools.ietf.org/html/rfc7033#section-4.4.4.1 |
|
120 | - * @param string|null $type https://tools.ietf.org/html/rfc7033#section-4.4.4.2 |
|
121 | - * @param string|null $href https://tools.ietf.org/html/rfc7033#section-4.4.4.3 |
|
122 | - * @param string[]|null $titles https://tools.ietf.org/html/rfc7033#section-4.4.4.4 |
|
123 | - * @param string|null $properties https://tools.ietf.org/html/rfc7033#section-4.4.4.5 |
|
124 | - * |
|
125 | - * @psalm-param array<string,(string|null)>|null $properties https://tools.ietf.org/html/rfc7033#section-4.4.4.5 |
|
126 | - * |
|
127 | - * @return JrdResponse |
|
128 | - * @since 21.0.0 |
|
129 | - */ |
|
130 | - public function addLink(string $rel, |
|
131 | - ?string $type, |
|
132 | - ?string $href, |
|
133 | - ?array $titles = [], |
|
134 | - ?array $properties = []): self { |
|
135 | - $this->links[] = array_filter([ |
|
136 | - 'rel' => $rel, |
|
137 | - 'type' => $type, |
|
138 | - 'href' => $href, |
|
139 | - 'titles' => $titles, |
|
140 | - 'properties' => $properties, |
|
141 | - ]); |
|
142 | - |
|
143 | - return $this; |
|
144 | - } |
|
145 | - |
|
146 | - /** |
|
147 | - * @since 21.0.0 |
|
148 | - */ |
|
149 | - public function toHttpResponse(): Response { |
|
150 | - return new JSONResponse(array_filter([ |
|
151 | - 'subject' => $this->subject, |
|
152 | - 'expires' => $this->expires, |
|
153 | - 'aliases' => $this->aliases, |
|
154 | - 'properties' => $this->properties, |
|
155 | - 'links' => $this->links, |
|
156 | - ])); |
|
157 | - } |
|
158 | - |
|
159 | - /** |
|
160 | - * Does this response have any data attached to it? |
|
161 | - * |
|
162 | - * @since 21.0.0 |
|
163 | - */ |
|
164 | - public function isEmpty(): bool { |
|
165 | - return $this->expires === null |
|
166 | - && empty($this->aliases) |
|
167 | - && empty($this->properties) |
|
168 | - && empty($this->links); |
|
169 | - } |
|
42 | + /** @var string */ |
|
43 | + private $subject; |
|
44 | + |
|
45 | + /** @var string|null */ |
|
46 | + private $expires; |
|
47 | + |
|
48 | + /** @var string[] */ |
|
49 | + private $aliases = []; |
|
50 | + |
|
51 | + /** @var (string|null)[] */ |
|
52 | + private $properties = []; |
|
53 | + |
|
54 | + /** @var mixed[] */ |
|
55 | + private $links; |
|
56 | + |
|
57 | + /** |
|
58 | + * @param string $subject https://tools.ietf.org/html/rfc7033#section-4.4.1 |
|
59 | + * |
|
60 | + * @since 21.0.0 |
|
61 | + */ |
|
62 | + public function __construct(string $subject) { |
|
63 | + $this->subject = $subject; |
|
64 | + } |
|
65 | + |
|
66 | + /** |
|
67 | + * @param string $expires |
|
68 | + * |
|
69 | + * @return $this |
|
70 | + * |
|
71 | + * @since 21.0.0 |
|
72 | + */ |
|
73 | + public function setExpires(string $expires): self { |
|
74 | + $this->expires = $expires; |
|
75 | + |
|
76 | + return $this; |
|
77 | + } |
|
78 | + |
|
79 | + /** |
|
80 | + * Add an alias |
|
81 | + * |
|
82 | + * @ref https://tools.ietf.org/html/rfc7033#section-4.4.2 |
|
83 | + * |
|
84 | + * @param string $alias |
|
85 | + * |
|
86 | + * @return $this |
|
87 | + * |
|
88 | + * @since 21.0.0 |
|
89 | + */ |
|
90 | + public function addAlias(string $alias): self { |
|
91 | + $this->aliases[] = $alias; |
|
92 | + |
|
93 | + return $this; |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * Add a property |
|
98 | + * |
|
99 | + * @ref https://tools.ietf.org/html/rfc7033#section-4.4.3 |
|
100 | + * |
|
101 | + * @param string $property |
|
102 | + * @param string|null $value |
|
103 | + * |
|
104 | + * @return $this |
|
105 | + * |
|
106 | + * @since 21.0.0 |
|
107 | + */ |
|
108 | + public function addProperty(string $property, ?string $value): self { |
|
109 | + $this->properties[$property] = $value; |
|
110 | + |
|
111 | + return $this; |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * Add a link |
|
116 | + * |
|
117 | + * @ref https://tools.ietf.org/html/rfc7033#section-8.4 |
|
118 | + * |
|
119 | + * @param string $rel https://tools.ietf.org/html/rfc7033#section-4.4.4.1 |
|
120 | + * @param string|null $type https://tools.ietf.org/html/rfc7033#section-4.4.4.2 |
|
121 | + * @param string|null $href https://tools.ietf.org/html/rfc7033#section-4.4.4.3 |
|
122 | + * @param string[]|null $titles https://tools.ietf.org/html/rfc7033#section-4.4.4.4 |
|
123 | + * @param string|null $properties https://tools.ietf.org/html/rfc7033#section-4.4.4.5 |
|
124 | + * |
|
125 | + * @psalm-param array<string,(string|null)>|null $properties https://tools.ietf.org/html/rfc7033#section-4.4.4.5 |
|
126 | + * |
|
127 | + * @return JrdResponse |
|
128 | + * @since 21.0.0 |
|
129 | + */ |
|
130 | + public function addLink(string $rel, |
|
131 | + ?string $type, |
|
132 | + ?string $href, |
|
133 | + ?array $titles = [], |
|
134 | + ?array $properties = []): self { |
|
135 | + $this->links[] = array_filter([ |
|
136 | + 'rel' => $rel, |
|
137 | + 'type' => $type, |
|
138 | + 'href' => $href, |
|
139 | + 'titles' => $titles, |
|
140 | + 'properties' => $properties, |
|
141 | + ]); |
|
142 | + |
|
143 | + return $this; |
|
144 | + } |
|
145 | + |
|
146 | + /** |
|
147 | + * @since 21.0.0 |
|
148 | + */ |
|
149 | + public function toHttpResponse(): Response { |
|
150 | + return new JSONResponse(array_filter([ |
|
151 | + 'subject' => $this->subject, |
|
152 | + 'expires' => $this->expires, |
|
153 | + 'aliases' => $this->aliases, |
|
154 | + 'properties' => $this->properties, |
|
155 | + 'links' => $this->links, |
|
156 | + ])); |
|
157 | + } |
|
158 | + |
|
159 | + /** |
|
160 | + * Does this response have any data attached to it? |
|
161 | + * |
|
162 | + * @since 21.0.0 |
|
163 | + */ |
|
164 | + public function isEmpty(): bool { |
|
165 | + return $this->expires === null |
|
166 | + && empty($this->aliases) |
|
167 | + && empty($this->properties) |
|
168 | + && empty($this->links); |
|
169 | + } |
|
170 | 170 | } |
@@ -32,20 +32,20 @@ |
||
32 | 32 | */ |
33 | 33 | final class GenericResponse implements IResponse { |
34 | 34 | |
35 | - /** @var Response */ |
|
36 | - private $response; |
|
37 | - |
|
38 | - /** |
|
39 | - * @since 21.0.0 |
|
40 | - */ |
|
41 | - public function __construct(Response $response) { |
|
42 | - $this->response = $response; |
|
43 | - } |
|
44 | - |
|
45 | - /** |
|
46 | - * @since 21.0.0 |
|
47 | - */ |
|
48 | - public function toHttpResponse(): Response { |
|
49 | - return $this->response; |
|
50 | - } |
|
35 | + /** @var Response */ |
|
36 | + private $response; |
|
37 | + |
|
38 | + /** |
|
39 | + * @since 21.0.0 |
|
40 | + */ |
|
41 | + public function __construct(Response $response) { |
|
42 | + $this->response = $response; |
|
43 | + } |
|
44 | + |
|
45 | + /** |
|
46 | + * @since 21.0.0 |
|
47 | + */ |
|
48 | + public function toHttpResponse(): Response { |
|
49 | + return $this->response; |
|
50 | + } |
|
51 | 51 | } |
@@ -37,10 +37,10 @@ |
||
37 | 37 | */ |
38 | 38 | interface IRequestContext { |
39 | 39 | |
40 | - /** |
|
41 | - * @return IRequest |
|
42 | - * |
|
43 | - * @since 21.0.0 |
|
44 | - */ |
|
45 | - public function getHttpRequest(): IRequest; |
|
40 | + /** |
|
41 | + * @return IRequest |
|
42 | + * |
|
43 | + * @since 21.0.0 |
|
44 | + */ |
|
45 | + public function getHttpRequest(): IRequest; |
|
46 | 46 | } |
@@ -32,8 +32,8 @@ |
||
32 | 32 | */ |
33 | 33 | interface IResponse { |
34 | 34 | |
35 | - /** |
|
36 | - * @since 21.0.0 |
|
37 | - */ |
|
38 | - public function toHttpResponse(): Response; |
|
35 | + /** |
|
36 | + * @since 21.0.0 |
|
37 | + */ |
|
38 | + public function toHttpResponse(): Response; |
|
39 | 39 | } |
@@ -35,14 +35,14 @@ |
||
35 | 35 | */ |
36 | 36 | interface IHandler { |
37 | 37 | |
38 | - /** |
|
39 | - * @param string $service the name of the well known service, e.g. 'webfinger' |
|
40 | - * @param IRequestContext $context |
|
41 | - * @param IResponse|null $previousResponse the response of the previous handler, if any |
|
42 | - * |
|
43 | - * @return IResponse|null a response object if the request could be handled, null otherwise |
|
44 | - * |
|
45 | - * @since 21.0.0 |
|
46 | - */ |
|
47 | - public function handle(string $service, IRequestContext $context, ?IResponse $previousResponse): ?IResponse; |
|
38 | + /** |
|
39 | + * @param string $service the name of the well known service, e.g. 'webfinger' |
|
40 | + * @param IRequestContext $context |
|
41 | + * @param IResponse|null $previousResponse the response of the previous handler, if any |
|
42 | + * |
|
43 | + * @return IResponse|null a response object if the request could be handled, null otherwise |
|
44 | + * |
|
45 | + * @since 21.0.0 |
|
46 | + */ |
|
47 | + public function handle(string $service, IRequestContext $context, ?IResponse $previousResponse): ?IResponse; |
|
48 | 48 | } |
@@ -41,158 +41,158 @@ |
||
41 | 41 | */ |
42 | 42 | interface IRegistrationContext { |
43 | 43 | |
44 | - /** |
|
45 | - * @param string $capability |
|
46 | - * @see IAppContainer::registerCapability |
|
47 | - * |
|
48 | - * @since 20.0.0 |
|
49 | - */ |
|
50 | - public function registerCapability(string $capability): void; |
|
51 | - |
|
52 | - /** |
|
53 | - * Register an implementation of \OCP\Support\CrashReport\IReporter that |
|
54 | - * will receive unhandled exceptions and throwables |
|
55 | - * |
|
56 | - * @param string $reporterClass |
|
57 | - * @psalm-param class-string<\OCP\Support\CrashReport\IReporter> $reporterClass |
|
58 | - * @return void |
|
59 | - * @since 20.0.0 |
|
60 | - */ |
|
61 | - public function registerCrashReporter(string $reporterClass): void; |
|
62 | - |
|
63 | - /** |
|
64 | - * Register an implementation of \OCP\Dashboard\IWidget that |
|
65 | - * will handle the implementation of a dashboard widget |
|
66 | - * |
|
67 | - * @param string $widgetClass |
|
68 | - * @psalm-param class-string<\OCP\Dashboard\IWidget> $widgetClass |
|
69 | - * @return void |
|
70 | - * @since 20.0.0 |
|
71 | - */ |
|
72 | - public function registerDashboardWidget(string $widgetClass): void; |
|
73 | - /** |
|
74 | - * Register a service |
|
75 | - * |
|
76 | - * @param string $name |
|
77 | - * @param callable $factory |
|
78 | - * @psalm-param callable(\Psr\Container\ContainerInterface): mixed $factory |
|
79 | - * @param bool $shared |
|
80 | - * |
|
81 | - * @return void |
|
82 | - * @see IContainer::registerService() |
|
83 | - * |
|
84 | - * @since 20.0.0 |
|
85 | - */ |
|
86 | - public function registerService(string $name, callable $factory, bool $shared = true): void; |
|
87 | - |
|
88 | - /** |
|
89 | - * @param string $alias |
|
90 | - * @psalm-param string|class-string $alias |
|
91 | - * @param string $target |
|
92 | - * @psalm-param string|class-string $target |
|
93 | - * |
|
94 | - * @return void |
|
95 | - * @see IContainer::registerAlias() |
|
96 | - * |
|
97 | - * @since 20.0.0 |
|
98 | - */ |
|
99 | - public function registerServiceAlias(string $alias, string $target): void; |
|
100 | - |
|
101 | - /** |
|
102 | - * @param string $name |
|
103 | - * @param mixed $value |
|
104 | - * |
|
105 | - * @return void |
|
106 | - * @see IContainer::registerParameter() |
|
107 | - * |
|
108 | - * @since 20.0.0 |
|
109 | - */ |
|
110 | - public function registerParameter(string $name, $value): void; |
|
111 | - |
|
112 | - /** |
|
113 | - * Register a service listener |
|
114 | - * |
|
115 | - * This is equivalent to calling IEventDispatcher::addServiceListener |
|
116 | - * |
|
117 | - * @template T of \OCP\EventDispatcher\Event |
|
118 | - * @param string $event preferably the fully-qualified class name of the Event sub class to listen for |
|
119 | - * @psalm-param string|class-string<T> $event preferably the fully-qualified class name of the Event sub class to listen for |
|
120 | - * @param string $listener fully qualified class name (or ::class notation) of a \OCP\EventDispatcher\IEventListener that can be built by the DI container |
|
121 | - * @psalm-param class-string<\OCP\EventDispatcher\IEventListener<T>> $listener fully qualified class name that can be built by the DI container |
|
122 | - * @param int $priority |
|
123 | - * |
|
124 | - * @see IEventDispatcher::addServiceListener() |
|
125 | - * |
|
126 | - * @since 20.0.0 |
|
127 | - */ |
|
128 | - public function registerEventListener(string $event, string $listener, int $priority = 0): void; |
|
129 | - |
|
130 | - /** |
|
131 | - * @param string $class |
|
132 | - * @psalm-param class-string<\OCP\AppFramework\Middleware> $class |
|
133 | - * |
|
134 | - * @return void |
|
135 | - * @see IAppContainer::registerMiddleWare() |
|
136 | - * |
|
137 | - * @since 20.0.0 |
|
138 | - */ |
|
139 | - public function registerMiddleware(string $class): void; |
|
140 | - |
|
141 | - /** |
|
142 | - * Register a search provider for the unified search |
|
143 | - * |
|
144 | - * It is allowed to register more than one provider per app as the search |
|
145 | - * results can go into distinct sections, e.g. "Files" and "Files shared |
|
146 | - * with you" in the Files app. |
|
147 | - * |
|
148 | - * @param string $class |
|
149 | - * @psalm-param class-string<\OCP\Search\IProvider> $class |
|
150 | - * |
|
151 | - * @return void |
|
152 | - * |
|
153 | - * @since 20.0.0 |
|
154 | - */ |
|
155 | - public function registerSearchProvider(string $class): void; |
|
156 | - |
|
157 | - /** |
|
158 | - * Register an alternative login option |
|
159 | - * |
|
160 | - * It is allowed to register more than one option per app. |
|
161 | - * |
|
162 | - * @param string $class |
|
163 | - * @psalm-param class-string<\OCP\Authentication\IAlternativeLogin> $class |
|
164 | - * |
|
165 | - * @return void |
|
166 | - * |
|
167 | - * @since 20.0.0 |
|
168 | - */ |
|
169 | - public function registerAlternativeLogin(string $class): void; |
|
170 | - |
|
171 | - /** |
|
172 | - * Register an initialstate provider |
|
173 | - * |
|
174 | - * It is allowed to register more than one provider per app. |
|
175 | - * |
|
176 | - * @param string $class |
|
177 | - * @psalm-param class-string<\OCP\AppFramework\Services\InitialStateProvider> $class |
|
178 | - * |
|
179 | - * @return void |
|
180 | - * |
|
181 | - * @since 21.0.0 |
|
182 | - */ |
|
183 | - public function registerInitialStateProvider(string $class): void; |
|
184 | - |
|
185 | - /** |
|
186 | - * Register a well known protocol handler |
|
187 | - * |
|
188 | - * It is allowed to register more than one handler per app. |
|
189 | - * |
|
190 | - * @param string $class |
|
191 | - * @psalm-param class-string<\OCP\Http\WellKnown\IHandler> $class |
|
192 | - * |
|
193 | - * @return void |
|
194 | - * |
|
195 | - * @since 21.0.0 |
|
196 | - */ |
|
197 | - public function registerWellKnownHandler(string $class): void; |
|
44 | + /** |
|
45 | + * @param string $capability |
|
46 | + * @see IAppContainer::registerCapability |
|
47 | + * |
|
48 | + * @since 20.0.0 |
|
49 | + */ |
|
50 | + public function registerCapability(string $capability): void; |
|
51 | + |
|
52 | + /** |
|
53 | + * Register an implementation of \OCP\Support\CrashReport\IReporter that |
|
54 | + * will receive unhandled exceptions and throwables |
|
55 | + * |
|
56 | + * @param string $reporterClass |
|
57 | + * @psalm-param class-string<\OCP\Support\CrashReport\IReporter> $reporterClass |
|
58 | + * @return void |
|
59 | + * @since 20.0.0 |
|
60 | + */ |
|
61 | + public function registerCrashReporter(string $reporterClass): void; |
|
62 | + |
|
63 | + /** |
|
64 | + * Register an implementation of \OCP\Dashboard\IWidget that |
|
65 | + * will handle the implementation of a dashboard widget |
|
66 | + * |
|
67 | + * @param string $widgetClass |
|
68 | + * @psalm-param class-string<\OCP\Dashboard\IWidget> $widgetClass |
|
69 | + * @return void |
|
70 | + * @since 20.0.0 |
|
71 | + */ |
|
72 | + public function registerDashboardWidget(string $widgetClass): void; |
|
73 | + /** |
|
74 | + * Register a service |
|
75 | + * |
|
76 | + * @param string $name |
|
77 | + * @param callable $factory |
|
78 | + * @psalm-param callable(\Psr\Container\ContainerInterface): mixed $factory |
|
79 | + * @param bool $shared |
|
80 | + * |
|
81 | + * @return void |
|
82 | + * @see IContainer::registerService() |
|
83 | + * |
|
84 | + * @since 20.0.0 |
|
85 | + */ |
|
86 | + public function registerService(string $name, callable $factory, bool $shared = true): void; |
|
87 | + |
|
88 | + /** |
|
89 | + * @param string $alias |
|
90 | + * @psalm-param string|class-string $alias |
|
91 | + * @param string $target |
|
92 | + * @psalm-param string|class-string $target |
|
93 | + * |
|
94 | + * @return void |
|
95 | + * @see IContainer::registerAlias() |
|
96 | + * |
|
97 | + * @since 20.0.0 |
|
98 | + */ |
|
99 | + public function registerServiceAlias(string $alias, string $target): void; |
|
100 | + |
|
101 | + /** |
|
102 | + * @param string $name |
|
103 | + * @param mixed $value |
|
104 | + * |
|
105 | + * @return void |
|
106 | + * @see IContainer::registerParameter() |
|
107 | + * |
|
108 | + * @since 20.0.0 |
|
109 | + */ |
|
110 | + public function registerParameter(string $name, $value): void; |
|
111 | + |
|
112 | + /** |
|
113 | + * Register a service listener |
|
114 | + * |
|
115 | + * This is equivalent to calling IEventDispatcher::addServiceListener |
|
116 | + * |
|
117 | + * @template T of \OCP\EventDispatcher\Event |
|
118 | + * @param string $event preferably the fully-qualified class name of the Event sub class to listen for |
|
119 | + * @psalm-param string|class-string<T> $event preferably the fully-qualified class name of the Event sub class to listen for |
|
120 | + * @param string $listener fully qualified class name (or ::class notation) of a \OCP\EventDispatcher\IEventListener that can be built by the DI container |
|
121 | + * @psalm-param class-string<\OCP\EventDispatcher\IEventListener<T>> $listener fully qualified class name that can be built by the DI container |
|
122 | + * @param int $priority |
|
123 | + * |
|
124 | + * @see IEventDispatcher::addServiceListener() |
|
125 | + * |
|
126 | + * @since 20.0.0 |
|
127 | + */ |
|
128 | + public function registerEventListener(string $event, string $listener, int $priority = 0): void; |
|
129 | + |
|
130 | + /** |
|
131 | + * @param string $class |
|
132 | + * @psalm-param class-string<\OCP\AppFramework\Middleware> $class |
|
133 | + * |
|
134 | + * @return void |
|
135 | + * @see IAppContainer::registerMiddleWare() |
|
136 | + * |
|
137 | + * @since 20.0.0 |
|
138 | + */ |
|
139 | + public function registerMiddleware(string $class): void; |
|
140 | + |
|
141 | + /** |
|
142 | + * Register a search provider for the unified search |
|
143 | + * |
|
144 | + * It is allowed to register more than one provider per app as the search |
|
145 | + * results can go into distinct sections, e.g. "Files" and "Files shared |
|
146 | + * with you" in the Files app. |
|
147 | + * |
|
148 | + * @param string $class |
|
149 | + * @psalm-param class-string<\OCP\Search\IProvider> $class |
|
150 | + * |
|
151 | + * @return void |
|
152 | + * |
|
153 | + * @since 20.0.0 |
|
154 | + */ |
|
155 | + public function registerSearchProvider(string $class): void; |
|
156 | + |
|
157 | + /** |
|
158 | + * Register an alternative login option |
|
159 | + * |
|
160 | + * It is allowed to register more than one option per app. |
|
161 | + * |
|
162 | + * @param string $class |
|
163 | + * @psalm-param class-string<\OCP\Authentication\IAlternativeLogin> $class |
|
164 | + * |
|
165 | + * @return void |
|
166 | + * |
|
167 | + * @since 20.0.0 |
|
168 | + */ |
|
169 | + public function registerAlternativeLogin(string $class): void; |
|
170 | + |
|
171 | + /** |
|
172 | + * Register an initialstate provider |
|
173 | + * |
|
174 | + * It is allowed to register more than one provider per app. |
|
175 | + * |
|
176 | + * @param string $class |
|
177 | + * @psalm-param class-string<\OCP\AppFramework\Services\InitialStateProvider> $class |
|
178 | + * |
|
179 | + * @return void |
|
180 | + * |
|
181 | + * @since 21.0.0 |
|
182 | + */ |
|
183 | + public function registerInitialStateProvider(string $class): void; |
|
184 | + |
|
185 | + /** |
|
186 | + * Register a well known protocol handler |
|
187 | + * |
|
188 | + * It is allowed to register more than one handler per app. |
|
189 | + * |
|
190 | + * @param string $class |
|
191 | + * @psalm-param class-string<\OCP\Http\WellKnown\IHandler> $class |
|
192 | + * |
|
193 | + * @return void |
|
194 | + * |
|
195 | + * @since 21.0.0 |
|
196 | + */ |
|
197 | + public function registerWellKnownHandler(string $class): void; |
|
198 | 198 | } |